added loadtextureimagebumpasnmap
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 2 Dec 2002 01:33:33 +0000 (01:33 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 2 Dec 2002 01:33:33 +0000 (01:33 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2667 d7cf8633-e32d-0410-b094-e92efae38249

image.c
image.h

diff --git a/image.c b/image.c
index 2b17283..8bb3d4d 100644 (file)
--- 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 5ff6738..2d26d29 100644 (file)
--- 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);