From f2033ea3754b3531a570ec7d407f154415047db5 Mon Sep 17 00:00:00 2001 From: havoc Date: Sun, 26 Mar 2006 06:43:50 +0000 Subject: [PATCH] eliminated the hacky r_showtris code, now r_glsl 1 mode works with r_showtris rewrote r_showtris and r_shownormals to use opaque lines that write to the depth buffer, this makes them show up quite clearly in all cases moved r_showtris and r_shownormals code into R_DrawSurfaces git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6192 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_screen.c | 5 +- gl_backend.c | 45 -------- gl_backend.h | 1 - gl_rmain.c | 300 +++++++++++++++++++++++++-------------------------- gl_rsurf.c | 6 +- glquake.h | 4 + r_shadow.c | 22 +--- render.h | 6 +- todo | 7 +- vid_shared.c | 2 + 10 files changed, 173 insertions(+), 225 deletions(-) diff --git a/cl_screen.c b/cl_screen.c index 57c3e260..e26048ef 100644 --- a/cl_screen.c +++ b/cl_screen.c @@ -422,7 +422,7 @@ void R_TimeReport(char *desc) int length; int t; - if (r_speeds.integer < 2 || !r_timereport_active || r_showtrispass) + if (r_speeds.integer < 2 || !r_timereport_active) return; qglFinish(); @@ -1296,7 +1296,6 @@ void SCR_UpdateLoadingScreen (void) // don't do anything if not initialized yet if (vid_hidden) return; - r_showtrispass = 0; VID_UpdateGamma(false); qglViewport(0, 0, vid.width, vid.height); //qglDisable(GL_SCISSOR_TEST); @@ -1413,8 +1412,6 @@ void CL_UpdateScreen(void) if (r_timereport_active) R_TimeReport("start"); - r_showtrispass = 0; - CHECKGLERROR qglViewport(0, 0, vid.width, vid.height); qglDisable(GL_SCISSOR_TEST); diff --git a/gl_backend.c b/gl_backend.c index ddfe5bbc..16e4377d 100644 --- a/gl_backend.c +++ b/gl_backend.c @@ -566,8 +566,6 @@ void GL_BlendFunc(int blendfunc1, int blendfunc2) { if (gl_state.blendfunc1 != blendfunc1 || gl_state.blendfunc2 != blendfunc2) { - if (r_showtrispass) - return; qglBlendFunc(gl_state.blendfunc1 = blendfunc1, gl_state.blendfunc2 = blendfunc2);CHECKGLERROR if (gl_state.blendfunc2 == GL_ZERO) { @@ -603,8 +601,6 @@ void GL_DepthMask(int state) { if (gl_state.depthmask != state) { - if (r_showtrispass) - return; qglDepthMask(gl_state.depthmask = state);CHECKGLERROR } } @@ -613,8 +609,6 @@ void GL_DepthTest(int state) { if (gl_state.depthtest != state) { - if (r_showtrispass && r_showdisabledepthtest.integer) - return; gl_state.depthtest = state; if (gl_state.depthtest) { @@ -641,8 +635,6 @@ void GL_Color(float cr, float cg, float cb, float ca) { if (gl_state.pointer_color || gl_state.color4f[0] != cr || gl_state.color4f[1] != cg || gl_state.color4f[2] != cb || gl_state.color4f[3] != ca) { - if (r_showtrispass) - return; gl_state.color4f[0] = cr; gl_state.color4f[1] = cg; gl_state.color4f[2] = cb; @@ -653,16 +645,6 @@ void GL_Color(float cr, float cg, float cb, float ca) } } -void GL_ShowTrisColor(float cr, float cg, float cb, float ca) -{ - if (!r_showtrispass) - return; - r_showtrispass = 0; - GL_Color(cr * r_showtris.value, cg * r_showtris.value, cb * r_showtris.value, ca); - r_showtrispass = 1; -} - - void GL_LockArrays(int first, int count) { if (gl_state.lockrange_count != count || gl_state.lockrange_first != first) @@ -707,10 +689,6 @@ void GL_ScissorTest(int state) void GL_Clear(int mask) { - // in showtris rendering, don't clear the color buffer as that would hide - // the accumulated lines - if (r_showtrispass) - mask &= ~GL_COLOR_BUFFER_BIT; qglClear(mask);CHECKGLERROR } @@ -862,11 +840,6 @@ void R_Mesh_Draw(int firstvertex, int numvertices, int numtriangles, const int * return; } //CHECKGLERROR - if (r_showtrispass) - { - R_Mesh_Draw_ShowTris(firstvertex, numvertices, numtriangles, elements); - return; - } renderstats.meshes++; renderstats.meshes_elements += numelements; if (gl_paranoid.integer) @@ -1083,8 +1056,6 @@ void R_Mesh_VertexPointer(const float *vertex3f) void R_Mesh_ColorPointer(const float *color4f) { - if (r_showtrispass) - return; if (gl_state.pointer_color != color4f) { CHECKGLERROR @@ -1110,8 +1081,6 @@ void R_Mesh_ColorPointer(const float *color4f) void R_Mesh_TexCoordPointer(unsigned int unitnum, unsigned int numcomponents, const float *texcoord) { gltextureunit_t *unit = gl_state.units + unitnum; - if (r_showtrispass) - return; // update array settings if (texcoord) { @@ -1149,8 +1118,6 @@ void R_Mesh_TexBindAll(unsigned int unitnum, int tex1d, int tex2d, int tex3d, in gltextureunit_t *unit = gl_state.units + unitnum; if (unitnum >= backendimageunits) return; - if (r_showtrispass) - return; // update 1d texture binding if (unit->t1d != tex1d) { @@ -1242,8 +1209,6 @@ void R_Mesh_TexBind1D(unsigned int unitnum, int texnum) gltextureunit_t *unit = gl_state.units + unitnum; if (unitnum >= backendimageunits) return; - if (r_showtrispass) - return; // update 1d texture binding if (unit->t1d != texnum) { @@ -1311,8 +1276,6 @@ void R_Mesh_TexBind(unsigned int unitnum, int texnum) gltextureunit_t *unit = gl_state.units + unitnum; if (unitnum >= backendimageunits) return; - if (r_showtrispass) - return; // update 1d texture binding if (unit->t1d) { @@ -1380,8 +1343,6 @@ void R_Mesh_TexBind3D(unsigned int unitnum, int texnum) gltextureunit_t *unit = gl_state.units + unitnum; if (unitnum >= backendimageunits) return; - if (r_showtrispass) - return; // update 1d texture binding if (unit->t1d) { @@ -1449,8 +1410,6 @@ void R_Mesh_TexBindCubeMap(unsigned int unitnum, int texnum) gltextureunit_t *unit = gl_state.units + unitnum; if (unitnum >= backendimageunits) return; - if (r_showtrispass) - return; // update 1d texture binding if (unit->t1d) { @@ -1516,8 +1475,6 @@ void R_Mesh_TexBindCubeMap(unsigned int unitnum, int texnum) void R_Mesh_TexMatrix(unsigned int unitnum, const matrix4x4_t *matrix) { gltextureunit_t *unit = gl_state.units + unitnum; - if (r_showtrispass) - return; if (matrix->m[3][3]) { // texmatrix specified, check if it is different @@ -1550,8 +1507,6 @@ void R_Mesh_TexMatrix(unsigned int unitnum, const matrix4x4_t *matrix) void R_Mesh_TexCombine(unsigned int unitnum, int combinergb, int combinealpha, int rgbscale, int alphascale) { gltextureunit_t *unit = gl_state.units + unitnum; - if (r_showtrispass) - return; if (gl_combine.integer) { // GL_ARB_texture_env_combine diff --git a/gl_backend.h b/gl_backend.h index 3bdc2e60..f494b44d 100644 --- a/gl_backend.h +++ b/gl_backend.h @@ -19,7 +19,6 @@ void GL_DepthMask(int state); void GL_DepthTest(int state); void GL_ColorMask(int r, int g, int b, int a); void GL_Color(float cr, float cg, float cb, float ca); -void GL_ShowTrisColor(float cr, float cg, float cb, float ca); void GL_TransformToScreen(const vec4_t in, vec4_t out); void GL_LockArrays(int first, int count); void GL_ActiveTexture(unsigned int num); diff --git a/gl_rmain.c b/gl_rmain.c index 214599df..db574e24 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -48,9 +48,6 @@ qboolean r_rtdlight; qboolean r_rtdlightshadows; -// forces all rendering to draw triangle outlines -int r_showtrispass; - // view origin vec3_t r_vieworigin; vec3_t r_viewforward; @@ -64,7 +61,10 @@ int r_view_width; int r_view_height; int r_view_depth; matrix4x4_t r_view_matrix; - +float r_polygonfactor; +float r_polygonoffset; +float r_shadowpolygonfactor; +float r_shadowpolygonoffset; // // screen size info // @@ -72,7 +72,6 @@ refdef_t r_refdef; cvar_t r_nearclip = {0, "r_nearclip", "1", "distance from camera of nearclip plane" }; cvar_t r_showtris = {0, "r_showtris", "0", "shows triangle outlines, value controls brightness (can be above 1)"}; -cvar_t r_showtris_polygonoffset = {0, "r_showtris_polygonoffset", "-10", "nudges triangle outlines in hardware depth units, used to make outlines appear infront of walls"}; cvar_t r_shownormals = {0, "r_shownormals", "0", "shows per-vertex surface normals and tangent vectors for bumpmapped lighting"}; cvar_t r_showlighting = {0, "r_showlighting", "0", "shows areas lit by lights, useful for finding out why some areas of a map render slowly (bright orange = lots of passes = slow), a value of 2 disables depth testing which can be interesting but not very useful"}; cvar_t r_showshadowvolumes = {0, "r_showshadowvolumes", "0", "shows areas shadowed by lights, useful for finding out why some areas of a map render slowly (bright blue = lots of passes = slow), a value of 2 disables depth testing which can be interesting but not very useful"}; @@ -1169,7 +1168,6 @@ void GL_Main_Init(void) FOG_registercvars(); // FIXME: move this fog stuff to client? Cvar_RegisterVariable(&r_nearclip); Cvar_RegisterVariable(&r_showtris); - Cvar_RegisterVariable(&r_showtris_polygonoffset); Cvar_RegisterVariable(&r_shownormals); Cvar_RegisterVariable(&r_showlighting); Cvar_RegisterVariable(&r_showshadowvolumes); @@ -1825,6 +1823,10 @@ void R_RenderView(void) r_rtdlight = (r_shadow_realtime_world.integer || r_shadow_realtime_dlight.integer) && !gl_flashblend.integer; r_rtdlightshadows = r_rtdlight && (r_rtworld ? r_shadow_realtime_world_dlightshadows.integer : r_shadow_realtime_dlight_shadows.integer) && gl_stencil; r_lightmapintensity = r_rtworld ? r_shadow_realtime_world_lightmaps.value : 1; + r_polygonfactor = 0; + r_polygonoffset = 0; + r_shadowpolygonfactor = r_polygonfactor + r_shadow_shadow_polygonfactor.value; + r_shadowpolygonoffset = r_polygonoffset + r_shadow_shadow_polygonoffset.value; // GL is weird because it's bottom to top, r_view_y is top to bottom qglViewport(r_view_x, vid.height - (r_view_y + r_view_height), r_view_width, r_view_height); @@ -1838,12 +1840,12 @@ void R_RenderView(void) R_TimeReport("setup"); qglDepthFunc(GL_LEQUAL); - qglPolygonOffset(0, 0); + qglPolygonOffset(r_polygonfactor, r_polygonoffset); qglEnable(GL_POLYGON_OFFSET_FILL); R_RenderScene(); - qglPolygonOffset(0, 0); + qglPolygonOffset(r_polygonfactor, r_polygonoffset); qglDisable(GL_POLYGON_OFFSET_FILL); R_BlendView(); @@ -1890,12 +1892,12 @@ void CSQC_R_ClearScreen (void) void CSQC_R_RenderScene (void) { qglDepthFunc(GL_LEQUAL); - qglPolygonOffset(0, 0); + qglPolygonOffset(r_polygonfactor, r_polygonoffset); qglEnable(GL_POLYGON_OFFSET_FILL); R_RenderScene(); - qglPolygonOffset(0, 0); + qglPolygonOffset(r_polygonfactor, r_polygonoffset); qglDisable(GL_POLYGON_OFFSET_FILL); R_BlendView(); @@ -1949,123 +1951,85 @@ void R_RenderScene(void) R_Shadow_UpdateWorldLightSelection(); - for (r_showtrispass = 0;r_showtrispass <= (r_showtris.value > 0);r_showtrispass++) + if (cl.csqc_vidvars.drawworld) { - if (r_showtrispass) - { - rmeshstate_t m; - r_showtrispass = 0; - GL_BlendFunc(GL_ONE, GL_ONE); - GL_DepthTest(!r_showdisabledepthtest.integer); - GL_DepthMask(GL_FALSE); - memset(&m, 0, sizeof(m)); - R_Mesh_State(&m); - //qglEnable(GL_LINE_SMOOTH); - qglEnable(GL_POLYGON_OFFSET_LINE); - qglPolygonOffset(0, r_showtris_polygonoffset.value); - r_showtrispass = 1; - } - - if (cl.csqc_vidvars.drawworld) - { - // don't let sound skip if going slow - if (r_refdef.extraupdate) - S_ExtraUpdate (); - - if (r_showtrispass) - GL_ShowTrisColor(0.025, 0.025, 0, 1); - if (r_refdef.worldmodel && r_refdef.worldmodel->DrawSky) - { - r_refdef.worldmodel->DrawSky(r_refdef.worldentity); - if (r_timereport_active) - R_TimeReport("worldsky"); - } - - if (R_DrawBrushModelsSky() && r_timereport_active) - R_TimeReport("bmodelsky"); - - if (r_showtrispass) - GL_ShowTrisColor(0.05, 0.05, 0.05, 1); - if (r_refdef.worldmodel && r_refdef.worldmodel->Draw) - { - r_refdef.worldmodel->Draw(r_refdef.worldentity); - if (r_timereport_active) - R_TimeReport("world"); - } - } - // don't let sound skip if going slow if (r_refdef.extraupdate) S_ExtraUpdate (); - if (r_showtrispass) - GL_ShowTrisColor(0, 0.015, 0, 1); - - R_DrawModels(); - if (r_timereport_active) - R_TimeReport("models"); + if (r_refdef.worldmodel && r_refdef.worldmodel->DrawSky) + { + r_refdef.worldmodel->DrawSky(r_refdef.worldentity); + if (r_timereport_active) + R_TimeReport("worldsky"); + } - // don't let sound skip if going slow - if (r_refdef.extraupdate) - S_ExtraUpdate (); + if (R_DrawBrushModelsSky() && r_timereport_active) + R_TimeReport("bmodelsky"); - if (r_showtrispass) - GL_ShowTrisColor(0, 0, 0.033, 1); - R_ShadowVolumeLighting(false); - if (r_timereport_active) - R_TimeReport("rtlights"); + if (r_refdef.worldmodel && r_refdef.worldmodel->Draw) + { + r_refdef.worldmodel->Draw(r_refdef.worldentity); + if (r_timereport_active) + R_TimeReport("world"); + } + } - // don't let sound skip if going slow - if (r_refdef.extraupdate) - S_ExtraUpdate (); + // don't let sound skip if going slow + if (r_refdef.extraupdate) + S_ExtraUpdate (); - if (r_showtrispass) - GL_ShowTrisColor(0.1, 0, 0, 1); + R_DrawModels(); + if (r_timereport_active) + R_TimeReport("models"); - if (cl.csqc_vidvars.drawworld) - { - R_DrawLightningBeams(); - if (r_timereport_active) - R_TimeReport("lightning"); + // don't let sound skip if going slow + if (r_refdef.extraupdate) + S_ExtraUpdate (); - R_DrawParticles(); - if (r_timereport_active) - R_TimeReport("particles"); + R_ShadowVolumeLighting(false); + if (r_timereport_active) + R_TimeReport("rtlights"); - R_DrawExplosions(); - if (r_timereport_active) - R_TimeReport("explosions"); - } + // don't let sound skip if going slow + if (r_refdef.extraupdate) + S_ExtraUpdate (); - R_MeshQueue_RenderTransparent(); + if (cl.csqc_vidvars.drawworld) + { + R_DrawLightningBeams(); if (r_timereport_active) - R_TimeReport("drawtrans"); + R_TimeReport("lightning"); - if (cl.csqc_vidvars.drawworld) - { - R_DrawCoronas(); - if (r_timereport_active) - R_TimeReport("coronas"); - } - if(cl.csqc_vidvars.drawcrosshair) - { - R_DrawWorldCrosshair(); - if (r_timereport_active) - R_TimeReport("crosshair"); - } + R_DrawParticles(); + if (r_timereport_active) + R_TimeReport("particles"); - VM_AddPolygonsToMeshQueue(); + R_DrawExplosions(); + if (r_timereport_active) + R_TimeReport("explosions"); + } - R_MeshQueue_Render(); + R_MeshQueue_RenderTransparent(); + if (r_timereport_active) + R_TimeReport("drawtrans"); - if (r_showtrispass) - { - //qglDisable(GL_LINE_SMOOTH); - qglDisable(GL_POLYGON_OFFSET_LINE); - } + if (cl.csqc_vidvars.drawworld) + { + R_DrawCoronas(); + if (r_timereport_active) + R_TimeReport("coronas"); } + if(cl.csqc_vidvars.drawcrosshair) + { + R_DrawWorldCrosshair(); + if (r_timereport_active) + R_TimeReport("crosshair"); + } + + VM_AddPolygonsToMeshQueue(); - r_showtrispass = 0; + R_MeshQueue_Render(); R_MeshQueue_EndScene(); @@ -3117,47 +3081,6 @@ static void R_DrawTextureSurfaceList(const entity_render_t *ent, texture_t *text } } } - if (r_shownormals.integer && !r_showtrispass) - { - int j, k; - float v[3]; - GL_DepthTest(!r_showdisabledepthtest.integer); - GL_DepthMask(texture->currentlayers->depthmask); - GL_BlendFunc(texture->currentlayers->blendfunc1, texture->currentlayers->blendfunc2); - memset(&m, 0, sizeof(m)); - R_Mesh_State(&m); - for (texturesurfaceindex = 0;texturesurfaceindex < texturenumsurfaces;texturesurfaceindex++) - { - surface = texturesurfacelist[texturesurfaceindex]; - RSurf_SetVertexPointer(ent, texture, surface, modelorg, false, true); - GL_Color(1, 0, 0, 1); - qglBegin(GL_LINES); - for (j = 0, k = surface->num_firstvertex;j < surface->num_vertices;j++, k++) - { - VectorCopy(rsurface_vertex3f + k * 3, v); - qglVertex3f(v[0], v[1], v[2]); - VectorMA(v, 8, rsurface_svector3f + k * 3, v); - qglVertex3f(v[0], v[1], v[2]); - } - GL_Color(0, 0, 1, 1); - for (j = 0, k = surface->num_firstvertex;j < surface->num_vertices;j++, k++) - { - VectorCopy(rsurface_vertex3f + k * 3, v); - qglVertex3f(v[0], v[1], v[2]); - VectorMA(v, 8, rsurface_tvector3f + k * 3, v); - qglVertex3f(v[0], v[1], v[2]); - } - GL_Color(0, 1, 0, 1); - for (j = 0, k = surface->num_firstvertex;j < surface->num_vertices;j++, k++) - { - VectorCopy(rsurface_vertex3f + k * 3, v); - qglVertex3f(v[0], v[1], v[2]); - VectorMA(v, 8, rsurface_normal3f + k * 3, v); - qglVertex3f(v[0], v[1], v[2]); - } - qglEnd(); - } - } } if ((texture->textureflags & Q3TEXTUREFLAG_TWOSIDED) || (ent->flags & RENDER_NOCULLFACE)) qglEnable(GL_CULL_FACE); @@ -3308,9 +3231,86 @@ void R_DrawSurfaces(entity_render_t *ent, qboolean skysurfaces) } if (numsurfacelist) R_QueueTextureSurfaceList(ent, texture, numsurfacelist, surfacelist, modelorg); - if (!r_showtrispass) - renderstats.entities_triangles += counttriangles; + renderstats.entities_triangles += counttriangles; if (gl_support_fragment_shader) qglUseProgramObjectARB(0); + + if (r_showtris.integer || r_shownormals.integer) + { + int k, l; + const int *elements; + rmeshstate_t m; + vec3_t v; + GL_DepthTest(true); + GL_DepthMask(true); + if (r_showdisabledepthtest.integer) + qglDepthFunc(GL_ALWAYS); + GL_BlendFunc(GL_ONE, GL_ZERO); + memset(&m, 0, sizeof(m)); + R_Mesh_State(&m); + for (i = 0, j = model->firstmodelsurface, surface = model->data_surfaces + j;i < model->nummodelsurfaces;i++, j++, surface++) + { + if (ent == r_refdef.worldentity && !r_worldsurfacevisible[j]) + continue; + texture = surface->texture->currentframe; + if ((texture->currentmaterialflags & flagsmask) && surface->num_triangles) + { + RSurf_SetVertexPointer(ent, texture, surface, modelorg, false, r_shownormals.integer != 0); + if (r_showtris.integer) + { + if (!texture->currentlayers->depthmask) + GL_Color(r_showtris.value, 0, 0, 1); + else if (ent == r_refdef.worldentity) + GL_Color(r_showtris.value, r_showtris.value, r_showtris.value, 1); + else + GL_Color(0, r_showtris.value, 0, 1); + elements = (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle); + qglBegin(GL_LINES); + for (k = 0;k < surface->num_triangles;k++, elements += 3) + { + qglArrayElement(elements[0]);qglArrayElement(elements[1]); + qglArrayElement(elements[1]);qglArrayElement(elements[2]); + qglArrayElement(elements[2]);qglArrayElement(elements[0]); + } + qglEnd(); + } + if (r_shownormals.integer) + { + GL_Color(r_shownormals.value, 0, 0, 1); + qglBegin(GL_LINES); + for (k = 0, l = surface->num_firstvertex;k < surface->num_vertices;k++, l++) + { + VectorCopy(rsurface_vertex3f + l * 3, v); + qglVertex3f(v[0], v[1], v[2]); + VectorMA(v, 8, rsurface_svector3f + l * 3, v); + qglVertex3f(v[0], v[1], v[2]); + } + qglEnd(); + GL_Color(0, 0, r_shownormals.value, 1); + qglBegin(GL_LINES); + for (k = 0, l = surface->num_firstvertex;k < surface->num_vertices;k++, l++) + { + VectorCopy(rsurface_vertex3f + l * 3, v); + qglVertex3f(v[0], v[1], v[2]); + VectorMA(v, 8, rsurface_tvector3f + l * 3, v); + qglVertex3f(v[0], v[1], v[2]); + } + qglEnd(); + GL_Color(0, r_shownormals.value, 0, 1); + qglBegin(GL_LINES); + for (k = 0, l = surface->num_firstvertex;k < surface->num_vertices;k++, l++) + { + VectorCopy(rsurface_vertex3f + l * 3, v); + qglVertex3f(v[0], v[1], v[2]); + VectorMA(v, 8, rsurface_normal3f + l * 3, v); + qglVertex3f(v[0], v[1], v[2]); + } + qglEnd(); + } + } + } + if (r_showdisabledepthtest.integer) + qglDepthFunc(GL_LEQUAL); + } } diff --git a/gl_rsurf.c b/gl_rsurf.c index 5bcf8fb3..85f28c09 100644 --- a/gl_rsurf.c +++ b/gl_rsurf.c @@ -503,7 +503,7 @@ void R_Q1BSP_Draw(entity_render_t *ent) if (model == NULL) return; R_DrawSurfaces(ent, false); - if (r_showcollisionbrushes.integer && model->brush.num_brushes && !r_showtrispass) + if (r_showcollisionbrushes.integer && model->brush.num_brushes) { int i; msurface_t *surface; @@ -512,14 +512,14 @@ void R_Q1BSP_Draw(entity_render_t *ent) GL_BlendFunc(GL_SRC_ALPHA, GL_ONE); GL_DepthMask(false); GL_DepthTest(!r_showdisabledepthtest.integer); - qglPolygonOffset(r_showcollisionbrushes_polygonfactor.value, r_showcollisionbrushes_polygonoffset.value); + qglPolygonOffset(r_polygonfactor + r_showcollisionbrushes_polygonfactor.value, r_polygonoffset + r_showcollisionbrushes_polygonoffset.value); for (i = 0, brush = model->brush.data_brushes + model->firstmodelbrush;i < model->nummodelbrushes;i++, brush++) if (brush->colbrushf && brush->colbrushf->numtriangles) R_DrawCollisionBrush(brush->colbrushf); for (i = 0, surface = model->data_surfaces + model->firstmodelsurface;i < model->nummodelsurfaces;i++, surface++) if (surface->num_collisiontriangles) R_DrawCollisionSurface(ent, surface); - qglPolygonOffset(0, 0); + qglPolygonOffset(r_polygonfactor, r_polygonoffset); } } diff --git a/glquake.h b/glquake.h index a1199233..811f91ba 100644 --- a/glquake.h +++ b/glquake.h @@ -120,6 +120,9 @@ typedef double GLclampd; #define GL_LINEAR_MIPMAP_NEAREST 0x2701 #define GL_LINEAR_MIPMAP_LINEAR 0x2703 +#define GL_LINE 0x1B01 +#define GL_FILL 0x1B02 + extern int gl_support_anisotropy; extern int gl_max_anisotropy; #define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE @@ -483,6 +486,7 @@ extern void (GLAPIENTRY *qglCopyTexSubImage1D)(GLenum target, GLint level, GLint extern void (GLAPIENTRY *qglCopyTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); extern void (GLAPIENTRY *qglPolygonOffset)(GLfloat factor, GLfloat units); +extern void (GLAPIENTRY *qglPolygonMode)(GLenum face, GLenum mode); //[515]: added on 29.07.2005 extern void (GLAPIENTRY *qglLineWidth)(GLfloat width); diff --git a/r_shadow.c b/r_shadow.c index 566158af..9417854f 100644 --- a/r_shadow.c +++ b/r_shadow.c @@ -876,15 +876,7 @@ void R_Shadow_RenderMode_StencilShadowVolumes(void) GL_BlendFunc(GL_ONE, GL_ZERO); GL_DepthMask(false); GL_DepthTest(true); - if (!r_showtrispass) - qglPolygonOffset(r_shadow_shadow_polygonfactor.value, r_shadow_shadow_polygonoffset.value); - //if (r_shadow_shadow_polygonoffset.value != 0) - //{ - // qglPolygonOffset(r_shadow_shadow_polygonfactor.value, r_shadow_shadow_polygonoffset.value); - // qglEnable(GL_POLYGON_OFFSET_FILL); - //} - //else - // qglDisable(GL_POLYGON_OFFSET_FILL); + qglPolygonOffset(r_shadowpolygonfactor, r_shadowpolygonoffset); qglDepthFunc(GL_LESS); qglCullFace(GL_FRONT); // quake is backwards, this culls back faces qglEnable(GL_STENCIL_TEST); @@ -918,8 +910,7 @@ void R_Shadow_RenderMode_Lighting(qboolean stenciltest, qboolean transparent) GL_BlendFunc(GL_SRC_ALPHA, GL_ONE); GL_DepthMask(false); GL_DepthTest(true); - if (!r_showtrispass) - qglPolygonOffset(0, 0); + qglPolygonOffset(r_polygonfactor, r_polygonoffset); //qglDisable(GL_POLYGON_OFFSET_FILL); GL_Color(1, 1, 1, 1); GL_ColorMask(r_refdef.colormask[0], r_refdef.colormask[1], r_refdef.colormask[2], 1); @@ -962,8 +953,7 @@ void R_Shadow_RenderMode_VisibleShadowVolumes(void) GL_BlendFunc(GL_ONE, GL_ONE); GL_DepthMask(false); GL_DepthTest(!r_showdisabledepthtest.integer); - if (!r_showtrispass) - qglPolygonOffset(0, 0); + qglPolygonOffset(r_polygonfactor, r_polygonoffset); GL_Color(0.0, 0.0125, 0.1, 1); GL_ColorMask(r_refdef.colormask[0], r_refdef.colormask[1], r_refdef.colormask[2], 1); qglDepthFunc(GL_GEQUAL); @@ -979,8 +969,7 @@ void R_Shadow_RenderMode_VisibleLighting(qboolean stenciltest, qboolean transpar GL_BlendFunc(GL_ONE, GL_ONE); GL_DepthMask(false); GL_DepthTest(!r_showdisabledepthtest.integer); - if (!r_showtrispass) - qglPolygonOffset(0, 0); + qglPolygonOffset(r_polygonfactor, r_polygonoffset); GL_Color(0.1, 0.0125, 0, 1); GL_ColorMask(r_refdef.colormask[0], r_refdef.colormask[1], r_refdef.colormask[2], 1); if (transparent) @@ -1003,8 +992,7 @@ void R_Shadow_RenderMode_End(void) GL_BlendFunc(GL_ONE, GL_ZERO); GL_DepthMask(true); GL_DepthTest(true); - if (!r_showtrispass) - qglPolygonOffset(0, 0); + qglPolygonOffset(r_polygonfactor, r_polygonoffset); //qglDisable(GL_POLYGON_OFFSET_FILL); GL_Color(1, 1, 1, 1); GL_ColorMask(r_refdef.colormask[0], r_refdef.colormask[1], r_refdef.colormask[2], 1); diff --git a/render.h b/render.h index faee70b5..cee545ae 100644 --- a/render.h +++ b/render.h @@ -147,7 +147,6 @@ extern cvar_t r_nearclip; // forces all rendering to draw triangle outlines extern cvar_t r_showtris; -extern cvar_t r_showtris_polygonoffset; extern cvar_t r_shownormals; extern cvar_t r_showlighting; extern cvar_t r_showshadowvolumes; @@ -155,7 +154,6 @@ extern cvar_t r_showcollisionbrushes; extern cvar_t r_showcollisionbrushes_polygonfactor; extern cvar_t r_showcollisionbrushes_polygonoffset; extern cvar_t r_showdisabledepthtest; -extern int r_showtrispass; // // view origin @@ -172,6 +170,10 @@ extern int r_view_width; extern int r_view_height; extern int r_view_depth; extern matrix4x4_t r_view_matrix; +extern float r_polygonfactor; +extern float r_polygonoffset; +extern float r_shadowpolygonfactor; +extern float r_shadowpolygonoffset; extern mleaf_t *r_viewleaf, *r_oldviewleaf; diff --git a/todo b/todo index 947a7929..210deeaa 100644 --- a/todo +++ b/todo @@ -3,9 +3,6 @@ -d (Black) bug darkplaces console: $* expansion should not include $0 (Black) -d (Carni) bug darkplaces client: prydon cursor highlighting of EF_SELECTABLE entities flickers with lower server framerate than client framerate (carni) -d (Edward Holness) feature darkplaces console: add condump command to output recent console history (note: wordwrap will remain, trailing spaces will be stripped though), and add it to the readme (Edward Holness) --d (FrikaC) bug darkplaces console: alias test "echo 1";test;echo 2 should print 1 then 2, not 2 then 1 or an error (div0, FrikaC) --d (FrikaC) bug darkplaces server: call checkvelocity (to clear NaNs) every time velocity is set in physics, to fix frikbot (tell FrikaC) --d (FrikaC) bug hmap2: make sure seconds reports in all tools don't print secondssss when they're printing shorter and shorter updates (FrikaC) -d (Gilgamesh) feature darkplaces protocol: add back colormod extension (FrikaC, Uffe, Gilgamesh, Wazat) -d (Gleeb) feature darkplaces server: add sv_playerphysicsqc cvar to allow engine to ignore SV_PlayerPhysics function, this would also have to change the reported extensions (Gleeb) -d (HellToupee) feature darkplaces client: add a dot crosshair texture (HellToupee) @@ -151,6 +148,7 @@ 0 feature darkplaces website: add q1source.zip to downloads page and suggest that mingw/Dev-C++ users may need the dx headers from it (cpuforbrain) 0 feature darkplaces: .vis files - like .lit but replacement vis data, note this also requires .leaf files (knghtbrd) 0 feature dpmaster: don't filter by protocol version if query is for protocol version 0, this way server browsers can see multiple versions of a single game, should probably also add a 'any' gamename that disables gamename filtering (Angst, Elric) +0 feature dpmod: add a g_spawnprotectiontime cvar which would default to 1 (invulnerable for 1 second after spawn) to prevent mining the spawn points 0 feature dpmod: add a summon command using KRIMZON_SV_PARSECLIENTCOMMAND which would summon the specified monster infront of you (Kedhrin) 0 feature dpmod: add knight/hell knight swords as player weapons (TimeServ) 0 feature dpmod: add mode with respawning monsters @@ -469,6 +467,7 @@ d bug darkplaces client: te_customflash isn't working? (Wazat) d bug darkplaces collision: check Urre's sltest.bsp and slopestuck.dem and fix the sticking bug, which only happens with sv_newflymove 1 (Urre) d bug darkplaces commands: say command is not posting to server console (Vermeulen) d bug darkplaces console: $variable expansion is not working on forwarded commands like "say I'm $_cl_name", it does work on local commands like set (esteel, Black) +d bug darkplaces console: alias test "echo 1";test;echo 2 should print 1 then 2, not 2 then 1 or an error (div0, FrikaC) d bug darkplaces console: chat messages are showing up in brown quake characters and having ^7 and such printed literally d bug darkplaces console: console script lines that are too long (1024+ characters) crash (NecroPhil, Black) d bug darkplaces console: inserting characters in the commandline is not adding a nul terminator to the commandline, resulting in lots of trash from older commandlines suddenly showing up (Spike) @@ -541,6 +540,7 @@ d bug darkplaces server: .colormap is not being set on DP_SV_BOTCLIENT entities d bug darkplaces server: SV_SpawnServer should send reconnect command using per-client reliable messages, because sv.reliable_datagram is being cleared d bug darkplaces server: add TE_FLAMEJET builtin and add extension (Supajoe) d bug darkplaces server: add color code to start of chat message to prevent nick colors from messing up the text color +d bug darkplaces server: call checkvelocity (to clear NaNs) every time velocity is set in physics, to fix frikbot (tell FrikaC) d bug darkplaces server: cl_movement 0 clients can pogostick jump and do quake2 style double jumps... why? answer: id1 qc move was clearing self.button2 each time it jumped, which causes it to pogostick when client input rate is lower than server framerate, fixed. (div) d bug darkplaces server: don't clear player entity when loading a savegame d bug darkplaces server: dropclient() is not calling ClientDisconnect on bots during the first level they exist in, it is called on later levels (Urre) @@ -558,6 +558,7 @@ d bug dpmod: fix the 'shell casing spawning at wrong player' bug somehow d bug dpmod: items aren't respawning in coop, they should d bug dpmod: shouldn't get double kill for killing something and its corpse (Sajt) d bug dpmodel: scale parameter isn't affecting animations (Ghostface) +d bug hmap2: make sure seconds reports in all tools don't print secondssss when they're printing shorter and shorter updates (FrikaC) d bug hmap2: strip .map extension from filename if present d bug zmodel: makefile should support mingw d change darkplaces client: add some particles to teleportsplash (Uffe) diff --git a/vid_shared.c b/vid_shared.c index 0a8a2d15..a02639b7 100644 --- a/vid_shared.c +++ b/vid_shared.c @@ -239,6 +239,7 @@ void (GLAPIENTRY *qglCopyTexSubImage3D)(GLenum target, GLint level, GLint xoffse void (GLAPIENTRY *qglScissor)(GLint x, GLint y, GLsizei width, GLsizei height); void (GLAPIENTRY *qglPolygonOffset)(GLfloat factor, GLfloat units); +void (GLAPIENTRY *qglPolygonMode)(GLenum face, GLenum mode); //[515]: added on 29.07.2005 void (GLAPIENTRY *qglLineWidth)(GLfloat width); @@ -466,6 +467,7 @@ static dllfunction_t opengl110funcs[] = {"glCopyTexSubImage2D", (void **) &qglCopyTexSubImage2D}, {"glScissor", (void **) &qglScissor}, {"glPolygonOffset", (void **) &qglPolygonOffset}, + {"glPolygonMode", (void **) &qglPolygonMode}, {NULL, NULL} }; -- 2.39.2