From d1b68af738f16910d737bf64658c64c7f1005871 Mon Sep 17 00:00:00 2001 From: havoc Date: Thu, 27 Feb 2003 00:00:31 +0000 Subject: [PATCH] changed TEXF_CLAMP to use GL_CLAMP_TO_EDGE (GL_EXT_texture_edge_clamp or GL_SGIS_texture_edge_clamp) instead of GL_CLAMP because it's a more useful behavior all-round, also fixed normalization cubemap on non-NVIDIA cards by doing this (I was properly using GL_CLAMP for attenuation texture, but not for normalization cubemap... *slaps self*) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2787 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_textures.c | 2 +- glquake.h | 6 ++++++ vid_shared.c | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/gl_textures.c b/gl_textures.c index 710d2164..f0b74a3c 100644 --- a/gl_textures.c +++ b/gl_textures.c @@ -558,7 +558,7 @@ void R_MakeResizeBufferBigger(int size) static void GL_SetupTextureParameters(int flags, int texturetype) { int textureenum = gltexturetypeenums[texturetype]; - int wrapmode = (flags & TEXF_CLAMP) ? GL_CLAMP : GL_REPEAT; + int wrapmode = ((flags & TEXF_CLAMP) && gl_support_clamptoedge) ? GL_CLAMP_TO_EDGE : GL_REPEAT; CHECKGLERROR diff --git a/glquake.h b/glquake.h index ee2fb7a9..4ad25be5 100644 --- a/glquake.h +++ b/glquake.h @@ -348,6 +348,12 @@ extern int gl_dot3ext; #define GL_SCISSOR_BOX 0x0C10 #endif +// GL_SGIS_texture_edge_clamp or GL_EXT_texture_edge_clamp +extern int gl_support_clamptoedge; +#ifndef GL_CLAMP_TO_EDGE +#define GL_CLAMP_TO_EDGE 0x812F +#endif + extern void (GLAPIENTRY *qglScissor)(GLint x, GLint y, GLsizei width, GLsizei height); extern void (GLAPIENTRY *qglClearColor)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); diff --git a/vid_shared.c b/vid_shared.c index 1bfff451..2260f240 100644 --- a/vid_shared.c +++ b/vid_shared.c @@ -24,6 +24,8 @@ int gl_texture3d = false; int gl_texturecubemap = false; // GL_ARB_texture_env_dot3 int gl_dot3arb = false; +// GL_SGIS_texture_edge_clamp +int gl_support_clamptoedge = false; // LordHavoc: if window is hidden, don't update screen int vid_hidden = true; @@ -353,6 +355,7 @@ void VID_CheckExtensions(void) gl_dot3arb = false; gl_supportslockarrays = false; gl_textureunits = 1; + gl_support_clamptoedge = false; if (!GL_CheckExtension("OpenGL 1.1.0", opengl110funcs, NULL, false)) Sys_Error("OpenGL 1.1.0 functions not found\n"); @@ -379,6 +382,7 @@ void VID_CheckExtensions(void) gl_texture3d = GL_CheckExtension("GL_EXT_texture3D", texture3dextfuncs, "-notexture3d", false); gl_texturecubemap = GL_CheckExtension("GL_ARB_texture_cube_map", NULL, "-nocubemap", false); gl_supportslockarrays = GL_CheckExtension("GL_EXT_compiled_vertex_array", compiledvertexarrayfuncs, "-nocva", false); + gl_support_clamptoedge = GL_CheckExtension("GL_EXT_texture_edge_clamp", NULL, "-noedgeclamp", false) || GL_CheckExtension("GL_SGIS_texture_edge_clamp", NULL, "-noedgeclamp", false); // we don't care if it's an extension or not, they are identical functions, so keep it simple in the rendering code if (qglDrawRangeElements == NULL) -- 2.39.2