From 6b4a10819abe111f70d27cd05e8b24075d00f35d Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Mon, 2 Jan 2012 13:15:19 +0900 Subject: [PATCH] Add an RGB texture loader. --- include/QF/GLSL/qf_textures.h | 2 ++ libs/video/renderer/glsl/glsl_textures.c | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/QF/GLSL/qf_textures.h b/include/QF/GLSL/qf_textures.h index 19ccae1f9..bb5f7978e 100644 --- a/include/QF/GLSL/qf_textures.h +++ b/include/QF/GLSL/qf_textures.h @@ -33,6 +33,8 @@ int GL_LoadQuakeTexture (const char *identifier, int width, int height, byte *data); +int GL_LoadRGBTexture (const char *identifier, int width, int height, + byte *data); void GL_ReleaseTexture (int tex); int GL_LoadTexture (const char *identifier, int width, int height, byte *data, qboolean mipmap, qboolean alpha, int bytesperpixel); diff --git a/libs/video/renderer/glsl/glsl_textures.c b/libs/video/renderer/glsl/glsl_textures.c index 0f15b70f9..15bd9dab4 100644 --- a/libs/video/renderer/glsl/glsl_textures.c +++ b/libs/video/renderer/glsl/glsl_textures.c @@ -63,6 +63,24 @@ GL_LoadQuakeTexture (const char *identifier, int width, int height, byte *data) return tnum; } +int +GL_LoadRGBTexture (const char *identifier, int width, int height, byte *data) +{ + GLuint tnum; + + qfglGenTextures (1, &tnum); + qfglBindTexture (GL_TEXTURE_2D, tnum); + qfglTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, + width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data); + qfglTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + qfglTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + qfglTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + qfglTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + qfglGenerateMipmap (GL_TEXTURE_2D); + + return tnum; +} + void GL_ReleaseTexture (int tex) {