From 9eed14a34e6f2a05afa0f57d9490837cf20df9ec Mon Sep 17 00:00:00 2001 From: havoc Date: Mon, 2 Dec 2002 01:33:33 +0000 Subject: [PATCH] added loadtextureimagebumpasnmap git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2667 d7cf8633-e32d-0410-b094-e92efae38249 --- image.c | 16 ++++++++++++++++ image.h | 1 + 2 files changed, 17 insertions(+) diff --git a/image.c b/image.c index 2b17283d..8bb3d4d7 100644 --- a/image.c +++ b/image.c @@ -723,6 +723,22 @@ rtexture_t *loadtextureimagewithmaskandnmap (rtexturepool_t *pool, const char *f return rt; } +rtexture_t *loadtextureimagebumpasnmap (rtexturepool_t *pool, const char *filename, int matchwidth, int matchheight, qboolean complain, int flags, float bumpscale) +{ + qbyte *data, *data2; + rtexture_t *rt; + if (!(data = loadimagepixels (filename, complain, matchwidth, matchheight))) + return 0; + data2 = Mem_Alloc(tempmempool, image_width * image_height * 4); + + Image_HeightmapToNormalmap(data, data2, image_width, image_height, (flags & TEXF_CLAMP) != 0, bumpscale); + rt = R_LoadTexture2D(pool, filename, image_width, image_height, data2, TEXTYPE_RGBA, flags, NULL); + + Mem_Free(data2); + Mem_Free(data); + return rt; +} + qboolean Image_WriteTGARGB_preflipped (const char *filename, int width, int height, const qbyte *data) { qboolean ret; diff --git a/image.h b/image.h index 5ff67384..2d26d29e 100644 --- a/image.h +++ b/image.h @@ -28,6 +28,7 @@ rtexture_t *image_masktex; rtexture_t *image_nmaptex; rtexture_t *loadtextureimagewithmask (rtexturepool_t *pool, const char *filename, int matchwidth, int matchheight, qboolean complain, int flags); rtexture_t *loadtextureimagewithmaskandnmap (rtexturepool_t *pool, const char *filename, int matchwidth, int matchheight, qboolean complain, int flags, float bumpscale); +rtexture_t *loadtextureimagebumpasnmap (rtexturepool_t *pool, const char *filename, int matchwidth, int matchheight, qboolean complain, int flags, float bumpscale); // writes a RGB TGA that is already upside down (which TGA wants) qboolean Image_WriteTGARGB_preflipped (const char *filename, int width, int height, const qbyte *data); -- 2.39.2