diff --git a/Quake/gl_draw.c b/Quake/gl_draw.c index 8de27f57..e1b8e43c 100644 --- a/Quake/gl_draw.c +++ b/Quake/gl_draw.c @@ -944,10 +944,6 @@ void GL_SetCanvas (canvastype newcanvas) glViewport (glx + (glwidth - 320*s) / 2, gly, 320*s, 48*s); } break; - case CANVAS_WARPIMAGE: - glOrtho (0, 128, 0, 128, -99999, 99999); - glViewport (glx, gly+glheight-gl_warpimagesize, gl_warpimagesize, gl_warpimagesize); - break; case CANVAS_CROSSHAIR: //0,0 is center of viewport s = CLAMP (1.0, scr_crosshairscale.value, 10.0); glOrtho (scr_vrect.width/-2/s, scr_vrect.width/2/s, scr_vrect.height/2/s, scr_vrect.height/-2/s, -99999, 99999); diff --git a/Quake/gl_model.c b/Quake/gl_model.c index c9d4c632..7176b5f9 100644 --- a/Quake/gl_model.c +++ b/Quake/gl_model.c @@ -823,13 +823,7 @@ void Mod_LoadTextures (lump_t *l) fmt, (byte *)(tx+1), loadmodel->name, offset, TEXPREF_NONE); } - //now create the warpimage, using dummy data from the hunk to create the initial image - 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); - tx->warpimage = TexMgr_LoadImage (loadmodel, texturename, gl_warpimagesize, - gl_warpimagesize, SRC_RGBA, hunk_base, "", (src_offset_t)hunk_base, TEXPREF_NOPICMIP | TEXPREF_WARPIMAGE); - tx->update_warp = true; if (malloced) free(data); } @@ -1700,11 +1694,13 @@ void Mod_LoadFaces (lump_t *l, qboolean bsp2) if (!q_strncasecmp(out->texinfo->texture->name,"sky",3)) // sky surface //also note -- was Q_strncmp, changed to match qbsp { out->flags |= (SURF_DRAWSKY | SURF_DRAWTILED); - Mod_PolyForUnlitSurface (out); //no more subdivision } else if (out->texinfo->texture->name[0] == '*') // warp surface { - out->flags |= (SURF_DRAWTURB | SURF_DRAWTILED); + out->flags |= SURF_DRAWTURB; + if (out->texinfo->flags & TEX_SPECIAL) + out->flags |= SURF_DRAWTILED; //unlit water + out->lightmaptexturenum = -1; // detect special liquid types if (!strncmp (out->texinfo->texture->name, "*lava", 5)) @@ -1714,9 +1710,6 @@ void Mod_LoadFaces (lump_t *l, qboolean bsp2) else if (!strncmp (out->texinfo->texture->name, "*tele", 5)) out->flags |= SURF_DRAWTELE; else out->flags |= SURF_DRAWWATER; - - Mod_PolyForUnlitSurface (out); - GL_SubdivideSurface (out); } else if (out->texinfo->texture->name[0] == '{') // ericw -- fence textures { @@ -1731,7 +1724,6 @@ void Mod_LoadFaces (lump_t *l, qboolean bsp2) else // not lightmapped { out->flags |= (SURF_NOTEXTURE | SURF_DRAWTILED); - Mod_PolyForUnlitSurface (out); } } //johnfitz diff --git a/Quake/gl_model.h b/Quake/gl_model.h index 21eb92bf..c8150ea2 100644 --- a/Quake/gl_model.h +++ b/Quake/gl_model.h @@ -81,8 +81,6 @@ typedef struct texture_s unsigned shift; // Q64 struct gltexture_s *gltexture; //johnfitz -- pointer to gltexture struct gltexture_s *fullbright; //johnfitz -- fullbright mask texture - struct gltexture_s *warpimage; //johnfitz -- for water animation - qboolean update_warp; //johnfitz -- update warp this frame struct msurface_s *texturechains[2]; // for texture chains int anim_total; // total tenths in sequence ( 0 = no) int anim_min, anim_max; // time for this frame min <=time< max diff --git a/Quake/gl_rmain.c b/Quake/gl_rmain.c index 351897f7..cbefdd46 100644 --- a/Quake/gl_rmain.c +++ b/Quake/gl_rmain.c @@ -622,9 +622,6 @@ void R_SetupView (void) currententity = &r_worldentity; R_MarkSurfaces (); //johnfitz -- create texture chains from PVS currententity = NULL; - - if (!skyroom_drawn) - R_UpdateWarpTextures (); //johnfitz -- do this before R_Clear } R_Clear (); diff --git a/Quake/gl_rmisc.c b/Quake/gl_rmisc.c index fb03f304..b8dc2480 100644 --- a/Quake/gl_rmisc.c +++ b/Quake/gl_rmisc.c @@ -35,7 +35,6 @@ extern cvar_t gl_farclip; extern cvar_t gl_overbright; extern cvar_t gl_overbright_models; extern cvar_t r_waterquality; -extern cvar_t r_oldwater; extern cvar_t r_waterwarp; extern cvar_t r_oldskyleaf; extern cvar_t r_drawworld; @@ -206,7 +205,6 @@ void R_Init (void) Cvar_RegisterVariable (&r_clearcolor); Cvar_SetCallback (&r_clearcolor, R_SetClearColor_f); Cvar_RegisterVariable (&r_waterquality); - Cvar_RegisterVariable (&r_oldwater); Cvar_RegisterVariable (&r_waterwarp); Cvar_RegisterVariable (&r_drawflat); Cvar_RegisterVariable (&r_flatlightstyles); diff --git a/Quake/gl_texmgr.c b/Quake/gl_texmgr.c index 6cfe500b..df2edf1f 100644 --- a/Quake/gl_texmgr.c +++ b/Quake/gl_texmgr.c @@ -621,54 +621,6 @@ void TexMgr_NewGame (void) TexMgr_LoadPalette (); } -/* -============= -TexMgr_RecalcWarpImageSize -- called during init, and after a vid_restart - -choose safe warpimage size and resize existing warpimage textures -============= -*/ -void TexMgr_RecalcWarpImageSize (void) -{ -// int oldsize = gl_warpimagesize; - int mark; - gltexture_t *glt; - byte *dummy; - - // - // find the new correct size - // - gl_warpimagesize = TexMgr_SafeTextureSize (512); - - while (gl_warpimagesize > vid.width) - gl_warpimagesize >>= 1; - while (gl_warpimagesize > vid.height) - gl_warpimagesize >>= 1; - - // ericw -- removed early exit if (gl_warpimagesize == oldsize). - // after vid_restart TexMgr_ReloadImage reloads textures - // to tx->source_width/source_height, which might not match oldsize. - // fixes: https://sourceforge.net/p/quakespasm/bugs/13/ - - // - // resize the textures in opengl - // - mark = Hunk_LowMark(); - dummy = (byte *) Hunk_Alloc (gl_warpimagesize*gl_warpimagesize*4); - - for (glt = active_gltextures; glt; glt = glt->next) - { - if (glt->flags & TEXPREF_WARPIMAGE) - { - GL_Bind (glt); - glTexImage2D (GL_TEXTURE_2D, 0, gl_solid_format, gl_warpimagesize, gl_warpimagesize, 0, GL_RGBA, GL_UNSIGNED_BYTE, dummy); - glt->width = glt->height = gl_warpimagesize; - } - } - - Hunk_FreeToLowMark (mark); -} - /* ================ TexMgr_Init @@ -715,10 +667,6 @@ void TexMgr_Init (void) //have to assign these here becuase Mod_Init is called before TexMgr_Init r_notexture_mip->gltexture = r_notexture_mip2->gltexture = notexture; - - //set safe size for warpimages - gl_warpimagesize = 0; - TexMgr_RecalcWarpImageSize (); } /* diff --git a/Quake/gl_vidsdl.c b/Quake/gl_vidsdl.c index 7288ded8..543acf6d 100644 --- a/Quake/gl_vidsdl.c +++ b/Quake/gl_vidsdl.c @@ -110,6 +110,7 @@ qboolean gl_glsl_able = false; //ericw GLint gl_max_texture_units = 0; //ericw qboolean gl_glsl_gamma_able = false; //ericw qboolean gl_glsl_alias_able = false; //ericw +qboolean gl_glsl_water_able = false; //Spoike int gl_stencilbits; PFNGLMULTITEXCOORD2FARBPROC GL_MTexCoord2fFunc = NULL; //johnfitz @@ -829,9 +830,6 @@ static void VID_Restart (void) GL_SetupState (); Fog_SetupState (); - //warpimages needs to be recalculated - TexMgr_RecalcWarpImageSize (); - //conwidth and conheight need to be recalculated vid.conwidth = (scr_conwidth.value > 0) ? (int)scr_conwidth.value : (scr_conscale.value > 0) ? (int)(vid.width/scr_conscale.value) : vid.width; vid.conwidth = CLAMP (320, vid.conwidth, vid.width); diff --git a/Quake/gl_warp.c b/Quake/gl_warp.c index c2faa938..8c7a52ec 100644 --- a/Quake/gl_warp.c +++ b/Quake/gl_warp.c @@ -206,67 +206,4 @@ void DrawWaterPoly (glpoly_t *p) } } -//============================================================================== -// -// RENDER-TO-FRAMEBUFFER WATER -// -//============================================================================== -/* -============= -R_UpdateWarpTextures -- johnfitz -- each frame, update warping textures -============= -*/ -void R_UpdateWarpTextures (void) -{ - texture_t *tx; - int i; - float x, y, x2, warptess; - - if (r_oldwater.value || cl.paused || r_drawflat_cheatsafe || r_lightmap_cheatsafe) - return; - - warptess = 128.0/CLAMP (3.0, floor(r_waterquality.value), 64.0); - - for (i=0; inumtextures; i++) - { - if (!(tx = cl.worldmodel->textures[i])) - continue; - - if (!tx->update_warp) - continue; - - //render warp - GL_SetCanvas (CANVAS_WARPIMAGE); - GL_Bind (tx->gltexture); - for (x=0.0; x<128.0; x=x2) - { - x2 = x + warptess; - glBegin (GL_TRIANGLE_STRIP); - for (y=0.0; y<128.01; y+=warptess) // .01 for rounding errors - { - glTexCoord2f (WARPCALC(x,y), WARPCALC(y,x)); - glVertex2f (x,y); - glTexCoord2f (WARPCALC(x2,y), WARPCALC(y,x2)); - glVertex2f (x2,y); - } - glEnd(); - } - - //copy to texture - GL_Bind (tx->warpimage); - glCopyTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, glx, gly+glheight-gl_warpimagesize, gl_warpimagesize, gl_warpimagesize); - - tx->update_warp = false; - } - - // ericw -- workaround for osx 10.6 driver bug when using FSAA. R_Clear only clears the warpimage part of the screen. - GL_SetCanvas(CANVAS_DEFAULT); - - //if warp render went down into sbar territory, we need to be sure to refresh it next frame - if (gl_warpimagesize + sb_lines > glheight) - Sbar_Changed (); - - //if viewsize is less than 100, we need to redraw the frame around the viewport - scr_tileclear_updates = 0; -} diff --git a/Quake/glquake.h b/Quake/glquake.h index f9733151..3ca57f08 100644 --- a/Quake/glquake.h +++ b/Quake/glquake.h @@ -264,6 +264,7 @@ extern QS_PFNGLUNIFORM4FVPROC GL_Uniform4fvFunc; extern qboolean gl_glsl_able; extern qboolean gl_glsl_gamma_able; extern qboolean gl_glsl_alias_able; +extern qboolean gl_glsl_water_able; // ericw -- //ericw -- NPOT texture support @@ -348,8 +349,6 @@ struct lightmap_s extern struct lightmap_s *lightmaps; extern int lightmap_count; //allocated lightmaps -extern int gl_warpimagesize; //johnfitz -- for water warp - extern qboolean r_drawflat_cheatsafe, r_fullbright_cheatsafe, r_lightmap_cheatsafe, r_drawworld_cheatsafe; //johnfitz typedef struct glsl_attrib_binding_s { diff --git a/Quake/r_brush.c b/Quake/r_brush.c index b0d09c89..d7946a40 100644 --- a/Quake/r_brush.c +++ b/Quake/r_brush.c @@ -790,6 +790,12 @@ void GL_CreateSurfaceLightmap (qmodel_t *model, msurface_t *surf) int smax, tmax; byte *base; + if (surf->flags & SURF_DRAWTILED) + { + surf->lightmaptexturenum = -1; + return; + } + smax = (surf->extents[0]>>surf->lmshift)+1; tmax = (surf->extents[1]>>surf->lmshift)+1; @@ -878,6 +884,10 @@ void BuildSurfaceDisplayList (msurface_t *fa) //johnfitz -- removed gl_keeptjunctions code poly->numverts = lnumverts; + + //oldwater is lame. subdivide it now. + if ((fa->flags & SURF_DRAWTURB) && !gl_glsl_water_able) + GL_SubdivideSurface (fa); } /* @@ -893,8 +903,6 @@ void GL_BuildModel (qmodel_t *m) for (i=0 ; inumsurfaces ; i++) { //johnfitz -- rewritten to use SURF_DRAWTILED instead of the sky/water flags - if (m->surfaces[i].flags & SURF_DRAWTILED) - continue; GL_CreateSurfaceLightmap (m, m->surfaces + i); BuildSurfaceDisplayList (m->surfaces + i); //johnfitz diff --git a/Quake/r_world.c b/Quake/r_world.c index 164fbb18..01beb7e9 100644 --- a/Quake/r_world.c +++ b/Quake/r_world.c @@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "quakedef.h" -extern cvar_t gl_fullbrights, r_drawflat, gl_overbright, r_oldwater, r_oldskyleaf, r_showtris; //johnfitz +extern cvar_t gl_fullbrights, r_drawflat, gl_overbright, r_oldskyleaf, r_showtris; //johnfitz byte *SV_FatPVS (vec3_t org, qmodel_t *worldmodel); @@ -147,8 +147,6 @@ void R_MarkSurfaces (void) rs_brushpolys++; //count wpolys here R_ChainSurface(surf, chain_world); R_RenderDynamicLightmaps(cl.worldmodel, surf); - if (surf->texinfo->texture->warpimage) - surf->texinfo->texture->update_warp = true; } } } @@ -216,7 +214,7 @@ void R_DrawTextureChains_ShowTris (qmodel_t *model, texchain_t chain) if (!t) continue; - if (r_oldwater.value && t->texturechains[chain] && (t->texturechains[chain]->flags & SURF_DRAWTURB)) + if (!gl_glsl_water_able && t->texturechains[chain] && (t->texturechains[chain]->flags & SURF_DRAWTURB)) { for (s = t->texturechains[chain]; s; s = s->texturechain) for (p = s->polys->next; p; p = p->next) @@ -252,7 +250,7 @@ void R_DrawTextureChains_Drawflat (qmodel_t *model, texchain_t chain) if (!t) continue; - if (r_oldwater.value && t->texturechains[chain] && (t->texturechains[chain]->flags & SURF_DRAWTURB)) + if (!gl_glsl_water_able && t->texturechains[chain] && (t->texturechains[chain]->flags & SURF_DRAWTURB)) { for (s = t->texturechains[chain]; s; s = s->texturechain) for (p = s->polys->next; p; p = p->next) @@ -412,7 +410,7 @@ void R_DrawTextureChains_Multitexture (qmodel_t *model, entity_t *ent, texchain_ { t = model->textures[i]; - if (!t || !t->texturechains[chain] || t->texturechains[chain]->flags & (SURF_DRAWTILED | SURF_NOTEXTURE)) + if (!t || !t->texturechains[chain] || t->texturechains[chain]->flags & (SURF_DRAWTURB | SURF_DRAWTILED | SURF_NOTEXTURE)) continue; bound = false; @@ -541,6 +539,151 @@ float GL_WaterAlphaForEntitySurface (entity_t *ent, msurface_t *s) return entalpha; } + +static struct +{ + GLuint program; + + GLuint light_scale; + GLuint alpha_scale; + GLuint time; +} r_water[2]; + +#define vertAttrIndex 0 +#define texCoordsAttrIndex 1 +#define LMCoordsAttrIndex 2 + +/* +============= +GLWorld_CreateShaders +============= +*/ +static void GLWater_CreateShaders (void) +{ + const char *modedefines[countof(r_water)] = { + "", + "#define LIT\n" + }; + const glsl_attrib_binding_t bindings[] = { + { "Vert", vertAttrIndex }, + { "TexCoords", texCoordsAttrIndex }, + { "LMCoords", LMCoordsAttrIndex } + }; + + // Driver bug workarounds: + // - "Intel(R) UHD Graphics 600" version "4.6.0 - Build 26.20.100.7263" + // crashing on glUseProgram with `vec3 Vert` and + // `gl_ModelViewProjectionMatrix * vec4(Vert, 1.0);`. Work around with + // making Vert a vec4. (https://sourceforge.net/p/quakespasm/bugs/39/) + const GLchar *vertSource = \ + "#version 110\n" + "%s" + "\n" + "attribute vec4 Vert;\n" + "attribute vec2 TexCoords;\n" +"#ifdef LIT\n" + "attribute vec2 LMCoords;\n" + "varying vec2 tc_lm;\n" +"#endif\n" + "\n" + "varying float FogFragCoord;\n" + "varying vec2 tc_tex;\n" + "\n" + "void main()\n" + "{\n" + " tc_tex = TexCoords;\n" +"#ifdef LIT\n" + " tc_lm = LMCoords;\n" +"#endif\n" + " gl_Position = gl_ModelViewProjectionMatrix * Vert;\n" + " FogFragCoord = gl_Position.w;\n" + "}\n"; + + const GLchar *fragSource = \ + "#version 110\n" + "%s" + "\n" + "uniform sampler2D Tex;\n" +"#ifdef LIT\n" + "uniform sampler2D LMTex;\n" + "uniform float LightScale;\n" + "varying vec2 tc_lm;\n" +"#endif\n" + "uniform float Alpha;\n" + "uniform float WarpTime;\n" + "\n" + "varying float FogFragCoord;\n" + "varying vec2 tc_tex;\n" + "\n" + "void main()\n" + "{\n" + " vec2 ntc = tc_tex;\n" + //CYCLE 128 + //AMP 8*0x10000 + //SPEED 20 + // sintable[i] = AMP + sin(i*3.14159*2/CYCLE)*AMP; + // + // r_turb_turb = sintable + ((int)(cl.time*SPEED)&(CYCLE-1)); + // + // sturb = ((r_turb_s + r_turb_turb[(r_turb_t>>16)&(CYCLE-1)])>>16)&63; + // tturb = ((r_turb_t + r_turb_turb[(r_turb_s>>16)&(CYCLE-1)])>>16)&63; + //The following 4 lines SHOULD match the software renderer, except normalised coords rather than snapped texels + "#define M_PI 3.14159\n" + "#define TIMEBIAS (((WarpTime*20.0)*M_PI*2.0)/128.0)\n" + " ntc.s += 0.125 + sin(tc_tex.t*M_PI + TIMEBIAS)*0.125;\n" + " ntc.t += 0.125 + sin(tc_tex.s*M_PI + TIMEBIAS)*0.125;\n" + " vec4 result = texture2D(Tex, ntc.st);\n" +"#ifdef LIT\n" + " result *= texture2D(LMTex, tc_lm.xy);\n" + " result.rgb *= LightScale;\n" +"#endif\n" + " result.a *= Alpha;\n" + " result = clamp(result, 0.0, 1.0);\n" + " float fog = exp(-gl_Fog.density * gl_Fog.density * FogFragCoord * FogFragCoord);\n" + " fog = clamp(fog, 0.0, 1.0);\n" + " result.rgb = mix(gl_Fog.color.rgb, result.rgb, fog);\n" + " gl_FragColor = result;\n" + "}\n"; + + size_t i; + char vtext[1024]; + char ftext[1024]; + gl_glsl_water_able = false; + + if (!gl_glsl_able) + return; + + for (i = 0; i < countof(r_water); i++) + { + snprintf(vtext, sizeof(vtext), vertSource, modedefines[i]); + snprintf(ftext, sizeof(ftext), fragSource, modedefines[i]); + r_water[i].program = GL_CreateProgram (vtext, ftext, sizeof(bindings)/sizeof(bindings[0]), bindings); + + if (r_water[i].program != 0) + { + // get uniform locations + GLuint texLoc = GL_GetUniformLocation (&r_water[i].program, "Tex"); + GLuint LMTexLoc = (i?GL_GetUniformLocation (&r_water[i].program, "LMTex"):-1); + r_water[i].light_scale = (i?GL_GetUniformLocation (&r_water[i].program, "LightScale"):-1); + r_water[i].alpha_scale = GL_GetUniformLocation (&r_water[i].program, "Alpha"); + r_water[i].time = GL_GetUniformLocation (&r_water[i].program, "WarpTime"); + + if (!r_water[i].program) + return; + + //bake constants here. + GL_UseProgramFunc (r_water[i].program); + GL_Uniform1iFunc (texLoc, 0); + if (LMTexLoc != -1) + GL_Uniform1iFunc (LMTexLoc, 1); + GL_UseProgramFunc (0); + } + else + return; //erk? + } + gl_glsl_water_able = true; +} + /* ================ R_DrawTextureChains_Water -- johnfitz @@ -558,7 +701,82 @@ void R_DrawTextureChains_Water (qmodel_t *model, entity_t *ent, texchain_t chain if (r_drawflat_cheatsafe || r_lightmap_cheatsafe) // ericw -- !r_drawworld_cheatsafe check moved to R_DrawWorld_Water () return; - if (r_oldwater.value) + if (gl_glsl_water_able) + { + extern GLuint gl_bmodel_vbo; + int lastlightmap = -2; + int mode = -1; + for (i=0 ; inumtextures ; i++) + { + t = model->textures[i]; + if (!t || !t->texturechains[chain] || !(t->texturechains[chain]->flags & SURF_DRAWTURB)) + continue; + s = t->texturechains[chain]; + + entalpha = GL_WaterAlphaForEntitySurface (ent, s); + if (entalpha < 1.0f) + { + glDepthMask (GL_FALSE); + glEnable (GL_BLEND); + } + +// Bind the buffers + GL_BindBuffer (GL_ARRAY_BUFFER, gl_bmodel_vbo); + GL_BindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0); // indices come from client memory! + GL_VertexAttribPointerFunc (vertAttrIndex, 3, GL_FLOAT, GL_FALSE, VERTEXSIZE * sizeof(float), ((float *)0)); + GL_VertexAttribPointerFunc (texCoordsAttrIndex, 2, GL_FLOAT, GL_FALSE, VERTEXSIZE * sizeof(float), ((float *)0) + 3); + GL_VertexAttribPointerFunc (LMCoordsAttrIndex, 2, GL_FLOAT, GL_FALSE, VERTEXSIZE * sizeof(float), ((float *)0) + 5); + + //actually use the buffers... + GL_EnableVertexAttribArrayFunc (vertAttrIndex); + GL_EnableVertexAttribArrayFunc (texCoordsAttrIndex); + + GL_SelectTexture (GL_TEXTURE0); + GL_Bind (t->gltexture); + GL_SelectTexture (GL_TEXTURE1); + for (; s; s = s->texturechain) + { + if (s->lightmaptexturenum != lastlightmap) + { + R_FlushBatch (); + + mode = s->lightmaptexturenum>=0 && !r_fullbright_cheatsafe; + if (mode) + { + GL_EnableVertexAttribArrayFunc (LMCoordsAttrIndex); + GL_Bind (lightmaps[s->lightmaptexturenum].texture); + } + else + GL_DisableVertexAttribArrayFunc (LMCoordsAttrIndex); + + GL_UseProgramFunc (r_water[mode].program); + GL_Uniform1fFunc (r_water[mode].time, cl.time); + if (r_water[mode].light_scale != -1) + GL_Uniform1fFunc (r_water[mode].light_scale, gl_overbright.value?2:1); + GL_Uniform1fFunc (r_water[mode].alpha_scale, entalpha); + lastlightmap = s->lightmaptexturenum; + } + R_BatchSurface (s); + + rs_brushpasses++; + } + + R_FlushBatch (); + GL_UseProgramFunc (0); + GL_DisableVertexAttribArrayFunc (vertAttrIndex); + GL_DisableVertexAttribArrayFunc (texCoordsAttrIndex); + GL_DisableVertexAttribArrayFunc (LMCoordsAttrIndex); + GL_SelectTexture (GL_TEXTURE0); + lastlightmap = -2; + + if (entalpha < 1.0f) + { + glDepthMask (GL_TRUE); + glDisable (GL_BLEND); + } + } + } + else { for (i=0 ; inumtextures ; i++) { @@ -585,39 +803,6 @@ void R_DrawTextureChains_Water (qmodel_t *model, entity_t *ent, texchain_t chain R_EndTransparentDrawing (entalpha); } } - else - { - for (i=0 ; inumtextures ; i++) - { - t = model->textures[i]; - if (!t || !t->texturechains[chain] || !(t->texturechains[chain]->flags & SURF_DRAWTURB)) - continue; - bound = false; - entalpha = 1.0f; - for (s = t->texturechains[chain]; s; s = s->texturechain) - { - if (!bound) //only bind once we are sure we need this texture - { - entalpha = GL_WaterAlphaForEntitySurface (ent, s); - R_BeginTransparentDrawing (entalpha); - GL_Bind (t->warpimage); - - if (model != cl.worldmodel) - { - // ericw -- this is copied from R_DrawSequentialPoly. - // If the poly is not part of the world we have to - // set this flag - t->update_warp = true; // FIXME: one frame too late! - } - - bound = true; - } - DrawGLPoly (s->polys); - rs_brushpasses++; - } - R_EndTransparentDrawing (entalpha); - } - } } /* @@ -783,6 +968,8 @@ void GLWorld_CreateShaders (void) useAlphaTestLoc = GL_GetUniformLocation (&r_world_program, "UseAlphaTest"); alphaLoc = GL_GetUniformLocation (&r_world_program, "Alpha"); } + + GLWater_CreateShaders(); } extern GLuint gl_bmodel_vbo; @@ -841,7 +1028,7 @@ void R_DrawTextureChains_GLSL (qmodel_t *model, entity_t *ent, texchain_t chain) { t = model->textures[i]; - if (!t || !t->texturechains[chain] || t->texturechains[chain]->flags & (SURF_DRAWTILED | SURF_NOTEXTURE)) + if (!t || !t->texturechains[chain] || t->texturechains[chain]->flags & (SURF_DRAWTURB | SURF_DRAWTILED | SURF_NOTEXTURE)) continue; // Enable/disable TMU 2 (fullbrights) diff --git a/Quake/screen.h b/Quake/screen.h index 1830360b..5b73591f 100644 --- a/Quake/screen.h +++ b/Quake/screen.h @@ -63,7 +63,6 @@ typedef enum { CANVAS_CONSOLE, CANVAS_MENU, CANVAS_SBAR, - CANVAS_WARPIMAGE, CANVAS_CROSSHAIR, CANVAS_BOTTOMLEFT, CANVAS_BOTTOMRIGHT,