@@ -1949,7 +1949,7 @@ void viewproject(int targtype = VP_CAMERA)
19491949 }
19501950}
19511951
1952- void drawnoviewtype (int targtype)
1952+ void drawviewtype (int targtype)
19531953{
19541954 if (targtype == VP_LEFT || targtype == VP_RIGHT)
19551955 {
@@ -1966,174 +1966,153 @@ void drawnoviewtype(int targtype)
19661966 }
19671967 }
19681968
1969- xtravertsva = xtraverts = glde = gbatches = 0 ;
1969+ if (!hasnoview ())
1970+ {
1971+ updatedynlights ();
19701972
1971- int w = screenw, h = screenh ;
1972- if (forceaspect) w = int ( ceil (h*forceaspect) );
1973- gettextres (w, h );
1973+ setfog (fogmat, fogblend, abovemat) ;
1974+ viewproject (targtype );
1975+ setcamprojmatrix ( );
19741976
1975- hudmatrix. ortho ( 0 , w, h, 0 , - 1 , 1 );
1976- resethudmatrix ( );
1977+ glEnable (GL_CULL_FACE );
1978+ glEnable (GL_DEPTH_TEST );
19771979
1978- glClearColor (0 .f , 0 .f , 0 .f , 1 );
1979- if (clearview (viewtype, targtype)) glClear (GL_COLOR_BUFFER_BIT);
1980+ xtravertsva = xtraverts = glde = gbatches = 0 ;
19801981
1981- hudshader-> set ();
1982+ visiblecubes ();
19821983
1983- hud::update (screenw, screenh);
1984- hud::drawhud (true );
1985- hud::drawlast ();
1984+ glClearColor (0 , 0 , 0 , 0 );
1985+ glClear (GL_DEPTH_BUFFER_BIT | (wireframe && editmode && clearview (viewtype, targtype) ? GL_COLOR_BUFFER_BIT : 0 ));
19861986
1987- if (targtype == VP_LEFT || targtype == VP_RIGHT)
1988- {
1989- if (viewtype >= VW_STEREO)
1990- {
1991- setcolormask ();
1992- glColorMask (COLORMASK, GL_TRUE);
1993- }
1994- }
1995- }
1987+ if (wireframe && editmode) glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
19961988
1997- void drawviewtype (int targtype)
1998- {
1999- updatedynlights ();
1989+ if (limitsky ()) drawskybox (farplane, true );
20001990
2001- setfog (fogmat, fogblend, abovemat);
2002- viewproject (targtype);
2003- setcamprojmatrix ();
2004- if (targtype == VP_LEFT || targtype == VP_RIGHT)
2005- {
2006- if (viewtype >= VW_STEREO)
2007- {
2008- switch (viewtype)
2009- {
2010- case VW_STEREO_BLEND: setcolormask (targtype == VP_LEFT, false , targtype == VP_RIGHT); break ;
2011- case VW_STEREO_AVG: setcolormask (targtype == VP_LEFT, true , targtype == VP_RIGHT); break ;
2012- case VW_STEREO_BLEND_REDCYAN:
2013- case VW_STEREO_REDCYAN: setcolormask (targtype == VP_LEFT, targtype == VP_RIGHT, targtype == VP_RIGHT); break ;
2014- }
2015- glColorMask (COLORMASK, GL_TRUE);
2016- }
2017- }
1991+ rendergeom (causticspass);
1992+ if (!wireframe && editmode && (outline || (fullbright && blankgeom))) renderoutline ();
20181993
2019- glEnable (GL_CULL_FACE);
2020- glEnable (GL_DEPTH_TEST);
2021-
2022- xtravertsva = xtraverts = glde = gbatches = 0 ;
1994+ queryreflections ();
1995+ generategrass ();
20231996
2024- visiblecubes ();
2025-
2026- glClearColor (0 , 0 , 0 , 0 );
2027- glClear (GL_DEPTH_BUFFER_BIT | (wireframe && editmode && clearview (viewtype, targtype) ? GL_COLOR_BUFFER_BIT : 0 ));
1997+ if (!limitsky ()) drawskybox (farplane, false );
20281998
2029- if (wireframe && editmode) glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
1999+ renderdecals (true );
2000+ renderavatar (true );
20302001
2031- if (limitsky ()) drawskybox (farplane, true );
2002+ rendermapmodels ();
2003+ rendergame ();
20322004
2033- rendergeom (causticspass);
2034- if (!wireframe && editmode && (outline || (fullbright && blankgeom))) renderoutline ();
2005+ if (wireframe && editmode) glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
20352006
2036- queryreflections ();
2037- generategrass ();
2007+ drawglaretex ();
2008+ drawdepthfxtex ();
2009+ drawreflections ();
20382010
2039- if (! limitsky ()) drawskybox (farplane, false );
2011+ if (wireframe && editmode) glPolygonMode (GL_FRONT_AND_BACK, GL_LINE );
20402012
2041- renderdecals ( true );
2042- renderavatar ( true );
2013+ renderwater ( );
2014+ rendergrass ( );
20432015
2044- rendermapmodels ();
2045- rendergame ();
2016+ rendermaterials ();
2017+ renderalphageom ();
20462018
2047- if (wireframe && editmode) glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
2019+ if (wireframe && editmode) glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
20482020
2049- drawglaretex ();
2050- drawdepthfxtex ();
2051- drawreflections ();
2021+ renderparticles (true );
20522022
2053- if (wireframe && editmode) glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
2023+ if (wireframe && editmode) glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
20542024
2055- renderwater ();
2056- rendergrass ();
2025+ renderavatar (false , true );
20572026
2058- rendermaterials ();
2059- renderalphageom ();
2027+ if (wireframe && editmode) glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
20602028
2061- if (wireframe && editmode) glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
2029+ glDisable (GL_CULL_FACE);
2030+ glDisable (GL_DEPTH_TEST);
20622031
2063- renderparticles (true );
2032+ if (!viewtype)
2033+ {
2034+ addmotionblur ();
2035+ addglare ();
2036+ }
2037+ if (isliquid (fogmat&MATF_VOLUME)) drawfogoverlay (fogmat, fogblend, abovemat);
2038+ if (!viewtype) renderpostfx ();
20642039
2065- if (wireframe && editmode) glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
2040+ if (editmode && !pixeling)
2041+ {
2042+ glEnable (GL_DEPTH_TEST);
2043+ glDepthMask (GL_FALSE);
20662044
2067- renderavatar (false , true );
2045+ renderblendbrush ();
2046+ rendereditcursor ();
20682047
2069- if (wireframe && editmode) glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
2048+ glDepthMask (GL_TRUE);
2049+ glDisable (GL_DEPTH_TEST);
2050+ }
20702051
2071- glDisable (GL_CULL_FACE);
2072- glDisable (GL_DEPTH_TEST);
2052+ int w = screenw, h = screenh;
2053+ if (forceaspect) w = int (ceil (h*forceaspect));
2054+ gettextres (w, h);
20732055
2074- if (!viewtype)
2075- {
2076- addmotionblur ();
2077- addglare ();
2078- }
2079- if (isliquid (fogmat&MATF_VOLUME)) drawfogoverlay (fogmat, fogblend, abovemat);
2080- if (!viewtype) renderpostfx ();
2056+ hudmatrix.ortho (0 , w, h, 0 , -1 , 1 );
2057+ resethudmatrix ();
20812058
2082- if (editmode && !pixeling)
2083- {
2084- glEnable (GL_DEPTH_TEST);
2085- glDepthMask (GL_FALSE);
2059+ gle::colorf (1 , 1 , 1 );
20862060
2087- renderblendbrush ();
2088- rendereditcursor ();
2061+ if (!pixeling || !editmode)
2062+ {
2063+ extern int debugsm;
2064+ if (debugsm)
2065+ {
2066+ extern void viewshadowmap ();
2067+ viewshadowmap ();
2068+ }
20892069
2090- glDepthMask (GL_TRUE);
2091- glDisable (GL_DEPTH_TEST);
2092- }
2070+ extern int debugglare;
2071+ if (debugglare)
2072+ {
2073+ extern void viewglaretex ();
2074+ viewglaretex ();
2075+ }
20932076
2094- int w = screenw, h = screenh;
2095- if (forceaspect) w = int (ceil (h*forceaspect));
2096- gettextres (w, h);
2077+ extern int debugdepthfx;
2078+ if (debugdepthfx)
2079+ {
2080+ extern void viewdepthfxtex ();
2081+ viewdepthfxtex ();
2082+ }
20972083
2098- hudmatrix. ortho ( 0 , w, h, 0 , - 1 , 1 );
2099- resethudmatrix ();
2084+ extern void debugparticles ( );
2085+ debugparticles ();
21002086
2101- gle::colorf (1 , 1 , 1 );
2087+ hudshader->set ();
2088+ hud::drawhud ();
2089+ rendertexturepanel (w, h);
2090+ hud::drawlast ();
2091+ }
21022092
2103- if (!pixeling || !editmode)
2093+ renderedgame = false ;
2094+ }
2095+ else
21042096 {
2105- extern int debugsm;
2106- if (debugsm)
2107- {
2108- extern void viewshadowmap ();
2109- viewshadowmap ();
2110- }
2097+ xtravertsva = xtraverts = glde = gbatches = 0 ;
21112098
2112- extern int debugglare;
2113- if (debugglare)
2114- {
2115- extern void viewglaretex ();
2116- viewglaretex ();
2117- }
2099+ int w = screenw, h = screenh;
2100+ if (forceaspect) w = int (ceil (h*forceaspect));
2101+ gettextres (w, h);
21182102
2119- extern int debugdepthfx;
2120- if (debugdepthfx)
2121- {
2122- extern void viewdepthfxtex ();
2123- viewdepthfxtex ();
2124- }
2103+ hudmatrix.ortho (0 , w, h, 0 , -1 , 1 );
2104+ resethudmatrix ();
21252105
2126- extern void debugparticles ( );
2127- debugparticles ( );
2106+ glClearColor ( 0 . f , 0 . f , 0 . f , 1 );
2107+ if ( clearview (viewtype, targtype)) glClear (GL_COLOR_BUFFER_BIT );
21282108
21292109 hudshader->set ();
2130- hud::drawhud ();
2131- rendertexturepanel (w, h);
2110+
2111+ hud::update (screenw, screenh);
2112+ hud::drawhud (true );
21322113 hud::drawlast ();
21332114 }
21342115
2135- renderedgame = false ;
2136-
21372116 if (targtype == VP_LEFT || targtype == VP_RIGHT)
21382117 {
21392118 if (viewtype >= VW_STEREO)
@@ -2178,22 +2157,21 @@ void gl_drawframe()
21782157 game::project (w, h);
21792158 }
21802159
2181- void (*drawviewtype_fn)(int ) = hasnoview () ? drawnoviewtype : drawviewtype;
21822160 int oldcurtime = curtime;
21832161
21842162 switch (viewtype)
21852163 {
21862164 case VW_NORMAL:
2187- drawviewtype_fn (VP_CAMERA);
2165+ drawviewtype (VP_CAMERA);
21882166 break ;
21892167
21902168 case VW_LEFTRIGHT:
21912169 case VW_CROSSEYED:
2192- drawviewtype_fn (VP_LEFT);
2170+ drawviewtype (VP_LEFT);
21932171 views[VP_LEFT].copy ();
21942172 curtime = 0 ;
21952173
2196- drawviewtype_fn (VP_RIGHT);
2174+ drawviewtype (VP_RIGHT);
21972175 views[VP_RIGHT].copy ();
21982176 curtime = oldcurtime;
21992177
@@ -2214,14 +2192,14 @@ void gl_drawframe()
22142192
22152193 case VW_STEREO_BLEND:
22162194 case VW_STEREO_BLEND_REDCYAN:
2217- drawviewtype_fn (VP_LEFT);
2195+ drawviewtype (VP_LEFT);
22182196 curtime = 0 ;
22192197
2220- drawviewtype_fn (VP_RIGHT);
2198+ drawviewtype (VP_RIGHT);
22212199 views[VP_RIGHT].copy ();
22222200 curtime = 0 ;
22232201
2224- drawviewtype_fn (VP_CAMERA);
2202+ drawviewtype (VP_CAMERA);
22252203 curtime = oldcurtime;
22262204
22272205 glDisable (GL_BLEND);
@@ -2237,13 +2215,13 @@ void gl_drawframe()
22372215
22382216 case VW_STEREO_AVG:
22392217 case VW_STEREO_REDCYAN:
2240- drawviewtype_fn (VP_LEFT);
2218+ drawviewtype (VP_LEFT);
22412219 if (viewtype == VW_STEREO_AVG)
22422220 {
22432221 views[VP_LEFT].copy ();
22442222 }
22452223 curtime = 0 ;
2246- drawviewtype_fn (VP_RIGHT);
2224+ drawviewtype (VP_RIGHT);
22472225 curtime = oldcurtime;
22482226
22492227 glDisable (GL_BLEND);
0 commit comments