diff --git a/Quake/gl_model.c b/Quake/gl_model.c index 1f9d7fa6..6fc3c181 100644 --- a/Quake/gl_model.c +++ b/Quake/gl_model.c @@ -466,6 +466,7 @@ static void Mod_LoadTextures (lump_t *l) byte *data; extern byte *hunk_base; //johnfitz + unsigned int flags; //johnfitz -- don't return early if no textures; still need to create dummy texture if (!l->filelen) @@ -585,8 +586,11 @@ static void Mod_LoadTextures (lump_t *l) Hunk_Alloc (gl_warpimagesize*gl_warpimagesize*4); //make sure hunk is big enough so we don't reach an illegal address Hunk_FreeToLowMark (mark); q_snprintf (texturename, sizeof(texturename), "%s_warp", texturename); + flags = TEXPREF_NOPICMIP | TEXPREF_WARPIMAGE; + if (GL_GenerateMipmap) + flags |= TEXPREF_MIPMAP; tx->warpimage = TexMgr_LoadImage (loadmodel, texturename, gl_warpimagesize, - gl_warpimagesize, SRC_RGBA, hunk_base, "", (src_offset_t)hunk_base, TEXPREF_NOPICMIP | TEXPREF_WARPIMAGE); + gl_warpimagesize, SRC_RGBA, hunk_base, "", (src_offset_t)hunk_base, flags); tx->update_warp = true; } else //regular texture diff --git a/Quake/gl_texmgr.c b/Quake/gl_texmgr.c index 4e4b3b58..0479cf0e 100644 --- a/Quake/gl_texmgr.c +++ b/Quake/gl_texmgr.c @@ -1051,7 +1051,7 @@ static void TexMgr_LoadImage32 (gltexture_t *glt, unsigned *data) glTexImage2D (GL_TEXTURE_2D, 0, internalformat, glt->width, glt->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); // upload mipmaps - if (glt->flags & TEXPREF_MIPMAP) + if (glt->flags & TEXPREF_MIPMAP && !(glt->flags & TEXPREF_WARPIMAGE)) // warp image mipmaps are generated later { mipwidth = glt->width; mipheight = glt->height; diff --git a/Quake/gl_vidsdl.c b/Quake/gl_vidsdl.c index 273dc756..c447a600 100644 --- a/Quake/gl_vidsdl.c +++ b/Quake/gl_vidsdl.c @@ -143,6 +143,8 @@ QS_PFNGLUNIFORM1FPROC GL_Uniform1fFunc = NULL; //ericw QS_PFNGLUNIFORM3FPROC GL_Uniform3fFunc = NULL; //ericw QS_PFNGLUNIFORM4FPROC GL_Uniform4fFunc = NULL; //ericw +QS_PFNGENERATEMIPMAP GL_GenerateMipmap = NULL; + //==================================== //johnfitz -- new cvars @@ -1268,6 +1270,14 @@ static void GL_CheckExtensions (void) { Con_Warning ("GLSL alias model rendering not available, using Fitz renderer\n"); } + + // glGenerateMipmap for warp textures + if (COM_CheckParm("-nowarpmipmaps")) + Con_Warning ("glGenerateMipmap disabled at command line\n"); + else if ((GL_GenerateMipmap = SDL_GL_GetProcAddress("glGenerateMipmap"))) + Con_Printf ("FOUND: glGenerateMipmap\n"); + else + Con_Warning ("glGenerateMipmap not available, liquids won't have mipmaps\n"); } /* diff --git a/Quake/gl_warp.c b/Quake/gl_warp.c index 93fd6501..a95edb6b 100644 --- a/Quake/gl_warp.c +++ b/Quake/gl_warp.c @@ -254,6 +254,8 @@ void R_UpdateWarpTextures (void) //copy to texture GL_Bind (tx->warpimage); glCopyTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, glx, gly+glheight-gl_warpimagesize, gl_warpimagesize, gl_warpimagesize); + if (GL_GenerateMipmap) + GL_GenerateMipmap (GL_TEXTURE_2D); tx->update_warp = false; } diff --git a/Quake/glquake.h b/Quake/glquake.h index 43c4131d..a9600cca 100644 --- a/Quake/glquake.h +++ b/Quake/glquake.h @@ -208,6 +208,7 @@ typedef void (APIENTRYP QS_PFNGLUNIFORM1IPROC) (GLint location, GLint v0); typedef void (APIENTRYP QS_PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); typedef void (APIENTRYP QS_PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); typedef void (APIENTRYP QS_PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP QS_PFNGENERATEMIPMAP) (GLenum type); extern QS_PFNGLCREATESHADERPROC GL_CreateShaderFunc; extern QS_PFNGLDELETESHADERPROC GL_DeleteShaderFunc; @@ -237,6 +238,9 @@ extern qboolean gl_glsl_gamma_able; extern qboolean gl_glsl_alias_able; // ericw -- +//mipmapped warp textures +extern QS_PFNGENERATEMIPMAP GL_GenerateMipmap; + //ericw -- NPOT texture support extern qboolean gl_texture_NPOT;