int blendfunc2;
int blend;
GLboolean depthmask;
+ int colormask; // stored as bottom 4 bits: r g b a (3 2 1 0 order)
int depthtest;
int scissortest;
int unit;
gl_state.blendfunc2 = GL_ZERO;
gl_state.blend = false;
gl_state.depthmask = GL_TRUE;
+ gl_state.colormask = 15;
gl_state.color4f[0] = gl_state.color4f[1] = gl_state.color4f[2] = gl_state.color4f[3] = 1;
gl_state.lockrange_first = 0;
gl_state.lockrange_count = 0;
CHECKGLERROR
+ qglColorMask(1, 1, 1, 1);
qglEnable(GL_CULL_FACE);CHECKGLERROR
qglCullFace(GL_FRONT);CHECKGLERROR
qglEnable(GL_DEPTH_TEST);CHECKGLERROR
}
}
+void GL_ColorMask(int r, int g, int b, int a)
+{
+ int state = r*8 + g*4 + b*2 + a*1;
+ if (gl_state.colormask != state)
+ {
+ if (r_showtrispass)
+ return;
+ gl_state.colormask = state;
+ qglColorMask(r, g, b, a);CHECKGLERROR
+ }
+}
+
void GL_VertexPointer(const float *p)
{
if (gl_state.pointer_vertex != p)
}
}
+void GL_ShowTrisColor(float cr, float cg, float cb, float ca)
+{
+ if (!r_showtrispass)
+ return;
+ r_showtrispass = false;
+ GL_Color(cr,cg,cb,ca);
+ r_showtrispass = true;
+}
+
+
void GL_LockArrays(int first, int count)
{
if (gl_state.lockrange_count != count || gl_state.lockrange_first != first)
CHECKGLERROR
}
+void GL_Clear(int mask)
+{
+ if (r_showtrispass)
+ return;
+ qglClear(mask);CHECKGLERROR
+}
+
void GL_TransformToScreen(const vec4_t in, vec4_t out)
{
vec4_t temp;
qglClearStencil(128);CHECKGLERROR
}
// clear the screen
- qglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | (gl_stencil ? GL_STENCIL_BUFFER_BIT : 0));CHECKGLERROR
+ GL_Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | (gl_stencil ? GL_STENCIL_BUFFER_BIT : 0));
// set dithering mode
if (gl_dither.integer)
{
{
if (gl_delayfinish.integer)
{
- VID_Finish ();
-
+ R_Mesh_Finish();
+ R_TimeReport("meshfinish");
+ VID_Finish();
R_TimeReport("finish");
}
+ R_Mesh_Start();
+
if (r_textureunits.integer > gl_textureunits)
Cvar_SetValueQuick(&r_textureunits, gl_textureunits);
if (r_textureunits.integer < 1)
if (gl_combine.integer && (!gl_combine_extension || r_textureunits.integer < 2))
Cvar_SetValueQuick(&gl_combine, 0);
+showtris:
R_TimeReport("setup");
R_ClearScreen();
// draw 2D stuff
R_DrawQueue();
+ if (r_showtrispass)
+ r_showtrispass = false;
+ else if (r_showtris.integer)
+ {
+ rmeshstate_t m;
+ GL_BlendFunc(GL_ONE, GL_ONE);
+ GL_DepthTest(GL_FALSE);
+ GL_DepthMask(GL_FALSE);
+ memset(&m, 0, sizeof(m));
+ R_Mesh_State_Texture(&m);
+ r_showtrispass = true;
+ GL_ShowTrisColor(0.2,0.2,0.2,1);
+ goto showtris;
+ }
+
if (gl_delayfinish.integer)
{
// tell driver to commit it's partially full geometry queue to the rendering queue
}
else
{
- VID_Finish ();
-
+ R_Mesh_Finish();
+ R_TimeReport("meshfinish");
+ VID_Finish();
R_TimeReport("finish");
}
}
GL_Scissor(r_view_x, r_view_y, r_view_width, r_view_height);
GL_ScissorTest(true);
R_ClearScreen();
-
- R_Mesh_Start();
R_TimeReport("setup");
qglDepthFunc(GL_LEQUAL);
qglEnable(GL_POLYGON_OFFSET_FILL);
R_RenderScene();
- if (r_showtris.integer)
- {
- rmeshstate_t m;
- GL_Color(1,1,1,1);
- GL_BlendFunc(GL_ONE, GL_ZERO);
- GL_DepthTest(GL_FALSE);
- GL_DepthMask(GL_FALSE);
- memset(&m, 0, sizeof(m));
- R_Mesh_State_Texture(&m);
- r_showtrispass = true;
- R_RenderScene();
- r_showtrispass = false;
- }
qglPolygonOffset(0, 0);
qglDisable(GL_POLYGON_OFFSET_FILL);
R_BlendView();
R_TimeReport("blendview");
- R_Mesh_Finish();
- R_TimeReport("meshfinish");
-
GL_Scissor(0, 0, vid.realwidth, vid.realheight);
GL_ScissorTest(false);
}
r_framecount++;
+ GL_ShowTrisColor(0.05, 0.05, 0.05, 1);
+
R_SetFrustum();
r_farclip = R_FarClip(r_vieworigin, r_viewforward, 768.0f) + 256.0f;
if (!intimerefresh && !r_speeds.integer)
S_ExtraUpdate ();
+ GL_ShowTrisColor(0, 0.015, 0, 1);
+
R_DrawModels();
R_TimeReport("models");
if (!intimerefresh && !r_speeds.integer)
S_ExtraUpdate ();
+ GL_ShowTrisColor(0, 0, 0.033, 1);
R_ShadowVolumeLighting(false);
R_TimeReport("rtlights");
if (!intimerefresh && !r_speeds.integer)
S_ExtraUpdate ();
+ GL_ShowTrisColor(0.1, 0, 0, 1);
+
R_DrawLightningBeams();
R_TimeReport("lightning");
R_MeshQueue_Render();
R_MeshQueue_EndScene();
- if (r_shadow_visiblevolumes.integer)
+ if (r_shadow_visiblevolumes.integer && !r_showtrispass)
{
R_ShadowVolumeLighting(true);
R_TimeReport("shadowvolume");
}
+ GL_ShowTrisColor(0.05, 0.05, 0.05, 1);
+
// don't let sound skip if going slow
if (!intimerefresh && !r_speeds.integer)
S_ExtraUpdate ();
memset(&m, 0, sizeof(m));
R_Mesh_State_Texture(&m);
GL_Color(1, 1, 1, 1);
- qglColorMask(0, 0, 0, 0);
+ GL_ColorMask(0, 0, 0, 0);
GL_BlendFunc(GL_ONE, GL_ZERO);
GL_DepthMask(false);
GL_DepthTest(true);
qglStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
qglStencilFunc(GL_ALWAYS, 128, 0xFF);
r_shadowstage = SHADOWSTAGE_STENCIL;
- qglClear(GL_STENCIL_BUFFER_BIT);
+ GL_Clear(GL_STENCIL_BUFFER_BIT);
c_rt_clears++;
// LordHavoc note: many shadow volumes reside entirely inside the world
// (that is to say they are entirely bounded by their lit surfaces),
qglPolygonOffset(0, 0);
//qglDisable(GL_POLYGON_OFFSET_FILL);
GL_Color(1, 1, 1, 1);
- qglColorMask(1, 1, 1, 1);
+ GL_ColorMask(1, 1, 1, 1);
qglDepthFunc(GL_EQUAL);
qglCullFace(GL_FRONT); // quake is backwards, this culls back faces
qglDisable(GL_STENCIL_TEST);
qglPolygonOffset(0, 0);
//qglDisable(GL_POLYGON_OFFSET_FILL);
GL_Color(1, 1, 1, 1);
- qglColorMask(1, 1, 1, 1);
+ GL_ColorMask(1, 1, 1, 1);
qglDepthFunc(GL_EQUAL);
qglCullFace(GL_FRONT); // quake is backwards, this culls back faces
qglEnable(GL_STENCIL_TEST);
qglPolygonOffset(0, 0);
//qglDisable(GL_POLYGON_OFFSET_FILL);
GL_Color(1, 1, 1, 1);
- qglColorMask(1, 1, 1, 1);
+ GL_ColorMask(1, 1, 1, 1);
GL_Scissor(r_view_x, r_view_y, r_view_width, r_view_height);
qglDepthFunc(GL_LEQUAL);
qglCullFace(GL_FRONT); // quake is backwards, this culls back faces
m.pointer_texcoord[1] = varray_texcoord3f[1];
m.pointer_texcoord[2] = varray_texcoord3f[2];
R_Mesh_State_Texture(&m);
- qglColorMask(0,0,0,1);
+ GL_ColorMask(0,0,0,1);
GL_BlendFunc(GL_ONE, GL_ZERO);
R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(varray_texcoord3f[1], numverts, vertex3f, svector3f, tvector3f, normal3f, relativelightorigin);
R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[2], numverts, vertex3f, matrix_modeltoattenuationxyz);
R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[1], numverts, vertex3f, matrix_modeltolight);
}
R_Mesh_State_Texture(&m);
- qglColorMask(1,1,1,0);
+ GL_ColorMask(1,1,1,0);
GL_BlendFunc(GL_DST_ALPHA, GL_ONE);
VectorScale(lightcolor, r_shadow_lightintensityscale.value, color2);
for (renders = 0;renders < 64 && (color2[0] > 0 || color2[1] > 0 || color2[2] > 0);renders++, color2[0]--, color2[1]--, color2[2]--)
m.tex3d[0] = R_GetTexture(r_shadow_attenuation3dtexture);
m.pointer_texcoord[0] = varray_texcoord3f[0];
R_Mesh_State_Texture(&m);
- qglColorMask(0,0,0,1);
+ GL_ColorMask(0,0,0,1);
GL_BlendFunc(GL_ONE, GL_ZERO);
R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[0], numverts, vertex3f, matrix_modeltoattenuationxyz);
R_Mesh_Draw(numverts, numtriangles, elements);
R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[1], numverts, vertex3f, matrix_modeltolight);
}
R_Mesh_State_Texture(&m);
- qglColorMask(1,1,1,0);
+ GL_ColorMask(1,1,1,0);
GL_BlendFunc(GL_DST_ALPHA, GL_ONE);
VectorScale(lightcolor, r_shadow_lightintensityscale.value, color2);
for (renders = 0;renders < 64 && (color2[0] > 0 || color2[1] > 0 || color2[2] > 0);renders++, color2[0]--, color2[1]--, color2[2]--)
m.pointer_texcoord[0] = texcoord2f;
m.pointer_texcoord[1] = varray_texcoord3f[1];
R_Mesh_State_Texture(&m);
- qglColorMask(0,0,0,1);
+ GL_ColorMask(0,0,0,1);
GL_BlendFunc(GL_ONE, GL_ZERO);
R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(varray_texcoord3f[1], numverts, vertex3f, svector3f, tvector3f, normal3f, relativelightorigin);
R_Mesh_Draw(numverts, numtriangles, elements);
m.pointer_texcoord[0] = texcoord2f;
m.pointer_texcoord[1] = varray_texcoord3f[1];
R_Mesh_State_Texture(&m);
- qglColorMask(1,1,1,0);
+ GL_ColorMask(1,1,1,0);
GL_BlendFunc(GL_DST_ALPHA, GL_ONE);
R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[1], numverts, vertex3f, matrix_modeltoattenuationxyz);
VectorScale(lightcolor, r_shadow_lightintensityscale.value, color2);
m.pointer_texcoord[2] = varray_texcoord2f[2];
m.pointer_texcoord[3] = varray_texcoord2f[3];
R_Mesh_State_Texture(&m);
- qglColorMask(0,0,0,1);
+ GL_ColorMask(0,0,0,1);
GL_BlendFunc(GL_ONE, GL_ZERO);
R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(varray_texcoord3f[1], numverts, vertex3f, svector3f, tvector3f, normal3f, relativelightorigin);
R_Shadow_Transform_Vertex3f_TexCoord2f(varray_texcoord2f[2], numverts, vertex3f, matrix_modeltoattenuationxyz);
R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[1], numverts, vertex3f, matrix_modeltolight);
}
R_Mesh_State_Texture(&m);
- qglColorMask(1,1,1,0);
+ GL_ColorMask(1,1,1,0);
GL_BlendFunc(GL_DST_ALPHA, GL_ONE);
VectorScale(lightcolor, r_shadow_lightintensityscale.value, color2);
for (renders = 0;renders < 64 && (color2[0] > 0 || color2[1] > 0 || color2[2] > 0);renders++, color2[0]--, color2[1]--, color2[2]--)
m.pointer_texcoord[0] = varray_texcoord2f[0];
m.pointer_texcoord[1] = varray_texcoord2f[1];
R_Mesh_State_Texture(&m);
- qglColorMask(0,0,0,1);
+ GL_ColorMask(0,0,0,1);
GL_BlendFunc(GL_ONE, GL_ZERO);
R_Shadow_Transform_Vertex3f_TexCoord2f(varray_texcoord2f[0], numverts, vertex3f, matrix_modeltoattenuationxyz);
R_Shadow_Transform_Vertex3f_TexCoord2f(varray_texcoord2f[1], numverts, vertex3f, matrix_modeltoattenuationz);
R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[1], numverts, vertex3f, matrix_modeltolight);
}
R_Mesh_State_Texture(&m);
- qglColorMask(1,1,1,0);
+ GL_ColorMask(1,1,1,0);
GL_BlendFunc(GL_DST_ALPHA, GL_ONE);
VectorScale(lightcolor, r_shadow_lightintensityscale.value, color2);
for (renders = 0;renders < 64 && (color2[0] > 0 || color2[1] > 0 || color2[2] > 0);renders++, color2[0]--, color2[1]--, color2[2]--)
m.pointer_texcoord[0] = texcoord2f;
m.pointer_texcoord[1] = varray_texcoord3f[1];
R_Mesh_State_Texture(&m);
- qglColorMask(0,0,0,1);
+ GL_ColorMask(0,0,0,1);
// this squares the result
GL_BlendFunc(GL_SRC_ALPHA, GL_ZERO);
R_Shadow_GenTexCoords_Specular_NormalCubeMap(varray_texcoord3f[1], numverts, vertex3f, svector3f, tvector3f, normal3f, relativelightorigin, relativeeyeorigin);
}
m.pointer_texcoord[0] = texcoord2f;
R_Mesh_State_Texture(&m);
- qglColorMask(1,1,1,0);
+ GL_ColorMask(1,1,1,0);
GL_BlendFunc(GL_DST_ALPHA, GL_ONE);
VectorScale(lightcolor, colorscale, color2);
for (renders = 0;renders < 64 && (color2[0] > 0 || color2[1] > 0 || color2[2] > 0);renders++, color2[0]--, color2[1]--, color2[2]--)
m.pointer_texcoord[0] = texcoord2f;
m.pointer_texcoord[1] = varray_texcoord3f[1];
R_Mesh_State_Texture(&m);
- qglColorMask(0,0,0,1);
+ GL_ColorMask(0,0,0,1);
// this squares the result
GL_BlendFunc(GL_SRC_ALPHA, GL_ZERO);
R_Shadow_GenTexCoords_Specular_NormalCubeMap(varray_texcoord3f[1], numverts, vertex3f, svector3f, tvector3f, normal3f, relativelightorigin, relativeeyeorigin);
m.pointer_texcoord[0] = texcoord2f;
m.pointer_texcoord[1] = varray_texcoord3f[1];
R_Mesh_State_Texture(&m);
- qglColorMask(1,1,1,0);
+ GL_ColorMask(1,1,1,0);
GL_BlendFunc(GL_DST_ALPHA, GL_ONE);
R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[1], numverts, vertex3f, matrix_modeltoattenuationxyz);
VectorScale(lightcolor, colorscale, color2);
m.pointer_texcoord[0] = texcoord2f;
m.pointer_texcoord[1] = varray_texcoord3f[1];
R_Mesh_State_Texture(&m);
- qglColorMask(0,0,0,1);
+ GL_ColorMask(0,0,0,1);
// this squares the result
GL_BlendFunc(GL_SRC_ALPHA, GL_ZERO);
R_Shadow_GenTexCoords_Specular_NormalCubeMap(varray_texcoord3f[1], numverts, vertex3f, svector3f, tvector3f, normal3f, relativelightorigin, relativeeyeorigin);
}
m.pointer_texcoord[0] = texcoord2f;
R_Mesh_State_Texture(&m);
- qglColorMask(1,1,1,0);
+ GL_ColorMask(1,1,1,0);
GL_BlendFunc(GL_DST_ALPHA, GL_ONE);
VectorScale(lightcolor, colorscale, color2);
for (renders = 0;renders < 64 && (color2[0] > 0 || color2[1] > 0 || color2[2] > 0);renders++, color2[0]--, color2[1]--, color2[2]--)
qglDisable(GL_DEPTH_TEST);
qglDisable(GL_STENCIL_TEST);
//qglDisable(GL_CULL_FACE);
- qglColorMask(1,1,1,1);
+ GL_ColorMask(1,1,1,1);
memset(&m, 0, sizeof(m));
R_Mesh_State_Texture(&m);
GL_Color(0,0.1,0,1);
if (stencilenabled)
{
qglEnable(GL_STENCIL_TEST);
- qglColorMask(0,0,0,0);
+ GL_ColorMask(0,0,0,0);
}
}
R_Shadow_RenderShadowMeshVolume(rtlight->static_meshchain_shadow);