#include "tr_local.h"
Include dependency graph for tr_backend.c:

Go to the source code of this file.
Defines | |
| #define | MAC_EVENT_PUMP_MSEC 5 |
Functions | |
| void | GL_Bind (image_t *image) |
| void | GL_BindMultitexture (image_t *image0, GLuint env0, image_t *image1, GLuint env1) |
| void | GL_Cull (int cullType) |
| void | GL_SelectTexture (int unit) |
| void | GL_State (unsigned long stateBits) |
| void | GL_TexEnv (int env) |
| void | RB_BeginDrawingView (void) |
| const void * | RB_DrawBuffer (const void *data) |
| const void * | RB_DrawSurfs (const void *data) |
| void | RB_ExecuteRenderCommands (const void *data) |
| void | RB_Hyperspace (void) |
| void | RB_RenderDrawSurfList (drawSurf_t *drawSurfs, int numDrawSurfs) |
| void | RB_RenderThread (void) |
| const void * | RB_SetColor (const void *data) |
| void | RB_SetGL2D (void) |
| void | RB_ShowImages (void) |
| const void * | RB_StretchPic (const void *data) |
| const void * | RB_SwapBuffers (const void *data) |
| void | RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty) |
| void | RE_UploadCinematic (int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty) |
| void | SetViewportAndScissor (void) |
Variables | |
| backEndState_t | backEnd |
| backEndData_t * | backEndData [SMP_FRAMES] |
| float | s_flipMatrix [16] |
|
|
Definition at line 512 of file tr_backend.c. |
|
|
||||||||||||||||||||
|
Definition at line 96 of file tr_backend.c. References glstate_t::currenttextures, trGlobals_t::dlightImage, trGlobals_t::frameCount, image_s::frameUsed, GL_SelectTexture(), glState, image_t, cvar_s::integer, qglBindTexture, r_nobind, image_s::texnum, and tr. 00096 {
00097 int texnum0, texnum1;
00098
00099 texnum0 = image0->texnum;
00100 texnum1 = image1->texnum;
00101
00102 if ( r_nobind->integer && tr.dlightImage ) { // performance evaluation option
00103 texnum0 = texnum1 = tr.dlightImage->texnum;
00104 }
00105
00106 if ( glState.currenttextures[1] != texnum1 ) {
00107 GL_SelectTexture( 1 );
00108 image1->frameUsed = tr.frameCount;
00109 glState.currenttextures[1] = texnum1;
00110 qglBindTexture( GL_TEXTURE_2D, texnum1 );
00111 }
00112 if ( glState.currenttextures[0] != texnum0 ) {
00113 GL_SelectTexture( 0 );
00114 image0->frameUsed = tr.frameCount;
00115 glState.currenttextures[0] = texnum0;
00116 qglBindTexture( GL_TEXTURE_2D, texnum0 );
00117 }
00118 }
|
Here is the call graph for this function:

|
|
Definition at line 124 of file tr_backend.c. References backEnd, glstate_t::faceCulling, glState, viewParms_t::isMirror, qglCullFace, qglDisable, qglEnable, and backEndState_t::viewParms. Referenced by R_DebugGraphics(), RB_StageIteratorGeneric(), RB_StageIteratorLightmappedMultitexture(), and RB_StageIteratorVertexLitTexture(). 00124 {
00125 if ( glState.faceCulling == cullType ) {
00126 return;
00127 }
00128
00129 glState.faceCulling = cullType;
00130
00131 if ( cullType == CT_TWO_SIDED )
00132 {
00133 qglDisable( GL_CULL_FACE );
00134 }
00135 else
00136 {
00137 qglEnable( GL_CULL_FACE );
00138
00139 if ( cullType == CT_BACK_SIDED )
00140 {
00141 if ( backEnd.viewParms.isMirror )
00142 {
00143 qglCullFace( GL_FRONT );
00144 }
00145 else
00146 {
00147 qglCullFace( GL_BACK );
00148 }
00149 }
00150 else
00151 {
00152 if ( backEnd.viewParms.isMirror )
00153 {
00154 qglCullFace( GL_BACK );
00155 }
00156 else
00157 {
00158 qglCullFace( GL_FRONT );
00159 }
00160 }
00161 }
00162 }
|
|
|
Definition at line 65 of file tr_backend.c. References glstate_t::currenttmu, ERR_DROP, GL_TEXTURE0_ARB, GL_TEXTURE1_ARB, GLimp_LogComment(), glState, qglActiveTextureARB, qglClientActiveTextureARB, and ri. Referenced by DrawMultitextured(), GL_BindMultitexture(), GL_SetDefaultState(), R_CreateImage(), R_DeleteTextures(), and RB_StageIteratorLightmappedMultitexture(). 00066 {
00067 if ( glState.currenttmu == unit )
00068 {
00069 return;
00070 }
00071
00072 if ( unit == 0 )
00073 {
00074 qglActiveTextureARB( GL_TEXTURE0_ARB );
00075 GLimp_LogComment( "glActiveTextureARB( GL_TEXTURE0_ARB )\n" );
00076 qglClientActiveTextureARB( GL_TEXTURE0_ARB );
00077 GLimp_LogComment( "glClientActiveTextureARB( GL_TEXTURE0_ARB )\n" );
00078 }
00079 else if ( unit == 1 )
00080 {
00081 qglActiveTextureARB( GL_TEXTURE1_ARB );
00082 GLimp_LogComment( "glActiveTextureARB( GL_TEXTURE1_ARB )\n" );
00083 qglClientActiveTextureARB( GL_TEXTURE1_ARB );
00084 GLimp_LogComment( "glClientActiveTextureARB( GL_TEXTURE1_ARB )\n" );
00085 } else {
00086 ri.Error( ERR_DROP, "GL_SelectTexture: unit = %i", unit );
00087 }
00088
00089 glState.currenttmu = unit;
00090 }
|
Here is the call graph for this function:

|
|
Definition at line 203 of file tr_backend.c. References assert, ERR_DROP, f, GLenum(), GLS_ATEST_GE_80, GLS_ATEST_GT_0, GLS_ATEST_LT_80, GLS_DSTBLEND_DST_ALPHA, GLS_DSTBLEND_ONE, GLS_DSTBLEND_ONE_MINUS_DST_ALPHA, GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA, GLS_DSTBLEND_ONE_MINUS_SRC_COLOR, GLS_DSTBLEND_SRC_ALPHA, GLS_DSTBLEND_SRC_COLOR, GLS_DSTBLEND_ZERO, GLS_SRCBLEND_ALPHA_SATURATE, GLS_SRCBLEND_BITS, GLS_SRCBLEND_DST_ALPHA, GLS_SRCBLEND_DST_COLOR, GLS_SRCBLEND_ONE, GLS_SRCBLEND_ONE_MINUS_DST_ALPHA, GLS_SRCBLEND_ONE_MINUS_DST_COLOR, GLS_SRCBLEND_ONE_MINUS_SRC_ALPHA, GLS_SRCBLEND_SRC_ALPHA, GLS_SRCBLEND_ZERO, glState, glstate_t::glStateBits, qglAlphaFunc, qglBlendFunc, qglDepthFunc, qglDepthMask, qglDisable, qglEnable, qglPolygonMode, and ri. Referenced by DrawMultitextured(), DrawNormals(), DrawTris(), ProjectDlightTexture(), R_DebugPolygon(), RB_BeginDrawingView(), RB_FogPass(), RB_IterateStagesGeneric(), RB_SetGL2D(), RB_ShadowFinish(), RB_ShadowTessEnd(), RB_StageIteratorLightmappedMultitexture(), RB_StageIteratorSky(), RB_StageIteratorVertexLitTexture(), and RB_SurfaceBeam(). 00204 {
00205 unsigned long diff = stateBits ^ glState.glStateBits;
00206
00207 if ( !diff )
00208 {
00209 return;
00210 }
00211
00212 //
00213 // check depthFunc bits
00214 //
00215 if ( diff & GLS_DEPTHFUNC_EQUAL )
00216 {
00217 if ( stateBits & GLS_DEPTHFUNC_EQUAL )
00218 {
00219 qglDepthFunc( GL_EQUAL );
00220 }
00221 else
00222 {
00223 qglDepthFunc( GL_LEQUAL );
00224 }
00225 }
00226
00227 //
00228 // check blend bits
00229 //
00230 if ( diff & ( GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS ) )
00231 {
00232 GLenum srcFactor, dstFactor;
00233
00234 if ( stateBits & ( GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS ) )
00235 {
00236 switch ( stateBits & GLS_SRCBLEND_BITS )
00237 {
00238 case GLS_SRCBLEND_ZERO:
00239 srcFactor = GL_ZERO;
00240 break;
00241 case GLS_SRCBLEND_ONE:
00242 srcFactor = GL_ONE;
00243 break;
00244 case GLS_SRCBLEND_DST_COLOR:
00245 srcFactor = GL_DST_COLOR;
00246 break;
00247 case GLS_SRCBLEND_ONE_MINUS_DST_COLOR:
00248 srcFactor = GL_ONE_MINUS_DST_COLOR;
00249 break;
00250 case GLS_SRCBLEND_SRC_ALPHA:
00251 srcFactor = GL_SRC_ALPHA;
00252 break;
00253 case GLS_SRCBLEND_ONE_MINUS_SRC_ALPHA:
00254 srcFactor = GL_ONE_MINUS_SRC_ALPHA;
00255 break;
00256 case GLS_SRCBLEND_DST_ALPHA:
00257 srcFactor = GL_DST_ALPHA;
00258 break;
00259 case GLS_SRCBLEND_ONE_MINUS_DST_ALPHA:
00260 srcFactor = GL_ONE_MINUS_DST_ALPHA;
00261 break;
00262 case GLS_SRCBLEND_ALPHA_SATURATE:
00263 srcFactor = GL_SRC_ALPHA_SATURATE;
00264 break;
00265 default:
00266 srcFactor = GL_ONE; // to get warning to shut up
00267 ri.Error( ERR_DROP, "GL_State: invalid src blend state bits\n" );
00268 break;
00269 }
00270
00271 switch ( stateBits & GLS_DSTBLEND_BITS )
00272 {
00273 case GLS_DSTBLEND_ZERO:
00274 dstFactor = GL_ZERO;
00275 break;
00276 case GLS_DSTBLEND_ONE:
00277 dstFactor = GL_ONE;
00278 break;
00279 case GLS_DSTBLEND_SRC_COLOR:
00280 dstFactor = GL_SRC_COLOR;
00281 break;
00282 case GLS_DSTBLEND_ONE_MINUS_SRC_COLOR:
00283 dstFactor = GL_ONE_MINUS_SRC_COLOR;
00284 break;
00285 case GLS_DSTBLEND_SRC_ALPHA:
00286 dstFactor = GL_SRC_ALPHA;
00287 break;
00288 case GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA:
00289 dstFactor = GL_ONE_MINUS_SRC_ALPHA;
00290 break;
00291 case GLS_DSTBLEND_DST_ALPHA:
00292 dstFactor = GL_DST_ALPHA;
00293 break;
00294 case GLS_DSTBLEND_ONE_MINUS_DST_ALPHA:
00295 dstFactor = GL_ONE_MINUS_DST_ALPHA;
00296 break;
00297 default:
00298 dstFactor = GL_ONE; // to get warning to shut up
00299 ri.Error( ERR_DROP, "GL_State: invalid dst blend state bits\n" );
00300 break;
00301 }
00302
00303 qglEnable( GL_BLEND );
00304 qglBlendFunc( srcFactor, dstFactor );
00305 }
00306 else
00307 {
00308 qglDisable( GL_BLEND );
00309 }
00310 }
00311
00312 //
00313 // check depthmask
00314 //
00315 if ( diff & GLS_DEPTHMASK_TRUE )
00316 {
00317 if ( stateBits & GLS_DEPTHMASK_TRUE )
00318 {
00319 qglDepthMask( GL_TRUE );
00320 }
00321 else
00322 {
00323 qglDepthMask( GL_FALSE );
00324 }
00325 }
00326
00327 //
00328 // fill/line mode
00329 //
00330 if ( diff & GLS_POLYMODE_LINE )
00331 {
00332 if ( stateBits & GLS_POLYMODE_LINE )
00333 {
00334 qglPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
00335 }
00336 else
00337 {
00338 qglPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
00339 }
00340 }
00341
00342 //
00343 // depthtest
00344 //
00345 if ( diff & GLS_DEPTHTEST_DISABLE )
00346 {
00347 if ( stateBits & GLS_DEPTHTEST_DISABLE )
00348 {
00349 qglDisable( GL_DEPTH_TEST );
00350 }
00351 else
00352 {
00353 qglEnable( GL_DEPTH_TEST );
00354 }
00355 }
00356
00357 //
00358 // alpha test
00359 //
00360 if ( diff & GLS_ATEST_BITS )
00361 {
00362 switch ( stateBits & GLS_ATEST_BITS )
00363 {
00364 case 0:
00365 qglDisable( GL_ALPHA_TEST );
00366 break;
00367 case GLS_ATEST_GT_0:
00368 qglEnable( GL_ALPHA_TEST );
00369 qglAlphaFunc( GL_GREATER, 0.0f );
00370 break;
00371 case GLS_ATEST_LT_80:
00372 qglEnable( GL_ALPHA_TEST );
00373 qglAlphaFunc( GL_LESS, 0.5f );
00374 break;
00375 case GLS_ATEST_GE_80:
00376 qglEnable( GL_ALPHA_TEST );
00377 qglAlphaFunc( GL_GEQUAL, 0.5f );
00378 break;
00379 default:
00380 assert( 0 );
00381 break;
00382 }
00383 }
00384
00385 glState.glStateBits = stateBits;
00386 }
|
Here is the call graph for this function:

|
|
Definition at line 167 of file tr_backend.c. References glstate_t::currenttmu, ERR_DROP, glState, qglTexEnvf, ri, and glstate_t::texEnv. Referenced by DrawMultitextured(), GL_SetDefaultState(), and RB_StageIteratorLightmappedMultitexture(). 00168 {
00169 if ( env == glState.texEnv[glState.currenttmu] )
00170 {
00171 return;
00172 }
00173
00174 glState.texEnv[glState.currenttmu] = env;
00175
00176
00177 switch ( env )
00178 {
00179 case GL_MODULATE:
00180 qglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
00181 break;
00182 case GL_REPLACE:
00183 qglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
00184 break;
00185 case GL_DECAL:
00186 qglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL );
00187 break;
00188 case GL_ADD:
00189 qglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD );
00190 break;
00191 default:
00192 ri.Error( ERR_DROP, "GL_TexEnv: invalid env '%d' passed\n", env );
00193 break;
00194 }
00195 }
|
|
|
Definition at line 432 of file tr_backend.c. References orientationr_t::axis, backEnd, cplane_s::dist, DotProduct, f, glstate_t::faceCulling, glstate_t::finishCalled, GL_State(), GLS_DEFAULT, glState, cvar_s::integer, backEndState_t::isHyperspace, viewParms_t::isPortal, cplane_s::normal, viewParms_t::or, orientationr_t::origin, viewParms_t::portalPlane, backEndState_t::projection2D, qglClear, qglClearColor, qglClipPlane, qglDisable, qglEnable, qglFinish, qglLoadMatrixf, r_fastsky, r_finish, r_measureOverdraw, r_shadows, RB_Hyperspace(), trRefdef_t::rdflags, backEndState_t::refdef, s_flipMatrix, SetViewportAndScissor(), backEndState_t::skyRenderedThisView, and backEndState_t::viewParms. Referenced by RB_RenderDrawSurfList(). 00432 {
00433 int clearBits = 0;
00434
00435 // sync with gl if needed
00436 if ( r_finish->integer == 1 && !glState.finishCalled ) {
00437 qglFinish ();
00438 glState.finishCalled = qtrue;
00439 }
00440 if ( r_finish->integer == 0 ) {
00441 glState.finishCalled = qtrue;
00442 }
00443
00444 // we will need to change the projection matrix before drawing
00445 // 2D images again
00446 backEnd.projection2D = qfalse;
00447
00448 //
00449 // set the modelview matrix for the viewer
00450 //
00451 SetViewportAndScissor();
00452
00453 // ensures that depth writes are enabled for the depth clear
00454 GL_State( GLS_DEFAULT );
00455 // clear relevant buffers
00456 clearBits = GL_DEPTH_BUFFER_BIT;
00457
00458 if ( r_measureOverdraw->integer || r_shadows->integer == 2 )
00459 {
00460 clearBits |= GL_STENCIL_BUFFER_BIT;
00461 }
00462 if ( r_fastsky->integer && !( backEnd.refdef.rdflags & RDF_NOWORLDMODEL ) )
00463 {
00464 clearBits |= GL_COLOR_BUFFER_BIT; // FIXME: only if sky shaders have been used
00465 #ifdef _DEBUG
00466 qglClearColor( 0.8f, 0.7f, 0.4f, 1.0f ); // FIXME: get color of sky
00467 #else
00468 qglClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); // FIXME: get color of sky
00469 #endif
00470 }
00471 qglClear( clearBits );
00472
00473 if ( ( backEnd.refdef.rdflags & RDF_HYPERSPACE ) )
00474 {
00475 RB_Hyperspace();
00476 return;
00477 }
00478 else
00479 {
00480 backEnd.isHyperspace = qfalse;
00481 }
00482
00483 glState.faceCulling = -1; // force face culling to set next time
00484
00485 // we will only draw a sun if there was sky rendered in this view
00486 backEnd.skyRenderedThisView = qfalse;
00487
00488 // clip to the plane of the portal
00489 if ( backEnd.viewParms.isPortal ) {
00490 float plane[4];
00491 double plane2[4];
00492
00493 plane[0] = backEnd.viewParms.portalPlane.normal[0];
00494 plane[1] = backEnd.viewParms.portalPlane.normal[1];
00495 plane[2] = backEnd.viewParms.portalPlane.normal[2];
00496 plane[3] = backEnd.viewParms.portalPlane.dist;
00497
00498 plane2[0] = DotProduct (backEnd.viewParms.or.axis[0], plane);
00499 plane2[1] = DotProduct (backEnd.viewParms.or.axis[1], plane);
00500 plane2[2] = DotProduct (backEnd.viewParms.or.axis[2], plane);
00501 plane2[3] = DotProduct (plane, backEnd.viewParms.or.origin) - plane[3];
00502
00503 qglLoadMatrixf( s_flipMatrix );
00504 qglClipPlane (GL_CLIP_PLANE0, plane2);
00505 qglEnable (GL_CLIP_PLANE0);
00506 } else {
00507 qglDisable (GL_CLIP_PLANE0);
00508 }
00509 }
|
Here is the call graph for this function:

|
|
Definition at line 937 of file tr_backend.c. References drawBufferCommand_t::buffer, cvar_s::integer, qglClear, qglClearColor, qglDrawBuffer, and r_clear. Referenced by RB_ExecuteRenderCommands(). 00937 {
00938 const drawBufferCommand_t *cmd;
00939
00940 cmd = (const drawBufferCommand_t *)data;
00941
00942 qglDrawBuffer( cmd->buffer );
00943
00944 // clear screen for debugging
00945 if ( r_clear->integer ) {
00946 qglClearColor( 1, 0, 0.5, 1 );
00947 qglClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
00948 }
00949
00950 return (const void *)(cmd + 1);
00951 }
|
|
|
Definition at line 912 of file tr_backend.c. References backEnd, drawSurfsCommand_t::drawSurfs, drawSurfsCommand_t::numDrawSurfs, shaderCommands_s::numIndexes, RB_EndSurface(), RB_RenderDrawSurfList(), drawSurfsCommand_t::refdef, backEndState_t::refdef, tess, drawSurfsCommand_t::viewParms, and backEndState_t::viewParms. Referenced by RB_ExecuteRenderCommands(). 00912 {
00913 const drawSurfsCommand_t *cmd;
00914
00915 // finish any 2D drawing if needed
00916 if ( tess.numIndexes ) {
00917 RB_EndSurface();
00918 }
00919
00920 cmd = (const drawSurfsCommand_t *)data;
00921
00922 backEnd.refdef = cmd->refdef;
00923 backEnd.viewParms = cmd->viewParms;
00924
00925 RB_RenderDrawSurfList( cmd->drawSurfs, cmd->numDrawSurfs );
00926
00927 return (const void *)(cmd + 1);
00928 }
|
Here is the call graph for this function:

|
|
Definition at line 1075 of file tr_backend.c. References backEnd, backEndData, renderCommandList_t::cmds, backEndData_t::commands, data, cvar_s::integer, refimport_t::Milliseconds, backEndCounters_t::msec, backEndState_t::pc, r_smp, RB_DrawBuffer(), RB_DrawSurfs(), RB_SetColor(), RB_StretchPic(), RB_SwapBuffers(), RB_TakeScreenshotCmd(), RC_DRAW_BUFFER, RC_DRAW_SURFS, RC_END_OF_LIST, RC_SCREENSHOT, RC_SET_COLOR, RC_STRETCH_PIC, RC_SWAP_BUFFERS, ri, and backEndState_t::smpFrame. Referenced by R_IssueRenderCommands(), and RB_RenderThread(). 01075 {
01076 int t1, t2;
01077
01078 t1 = ri.Milliseconds ();
01079
01080 if ( !r_smp->integer || data == backEndData[0]->commands.cmds ) {
01081 backEnd.smpFrame = 0;
01082 } else {
01083 backEnd.smpFrame = 1;
01084 }
01085
01086 while ( 1 ) {
01087 switch ( *(const int *)data ) {
01088 case RC_SET_COLOR:
01089 data = RB_SetColor( data );
01090 break;
01091 case RC_STRETCH_PIC:
01092 data = RB_StretchPic( data );
01093 break;
01094 case RC_DRAW_SURFS:
01095 data = RB_DrawSurfs( data );
01096 break;
01097 case RC_DRAW_BUFFER:
01098 data = RB_DrawBuffer( data );
01099 break;
01100 case RC_SWAP_BUFFERS:
01101 data = RB_SwapBuffers( data );
01102 break;
01103 case RC_SCREENSHOT:
01104 data = RB_TakeScreenshotCmd( data );
01105 break;
01106
01107 case RC_END_OF_LIST:
01108 default:
01109 // stop rendering on this thread
01110 t2 = ri.Milliseconds ();
01111 backEnd.pc.msec = t2 - t1;
01112 return;
01113 }
01114 }
01115
01116 }
|
Here is the call graph for this function:

|
|
Definition at line 397 of file tr_backend.c. References backEnd, c, backEndState_t::isHyperspace, qglClear, qglClearColor, backEndState_t::refdef, and trRefdef_t::time. Referenced by RB_BeginDrawingView(). 00397 {
00398 float c;
00399
00400 if ( !backEnd.isHyperspace ) {
00401 // do initialization shit
00402 }
00403
00404 c = ( backEnd.refdef.time & 255 ) / 255.0f;
00405 qglClearColor( c, c, c, 1 );
00406 qglClear( GL_COLOR_BUFFER_BIT );
00407
00408 backEnd.isHyperspace = qtrue;
00409 }
|
|
||||||||||||
|
Definition at line 519 of file tr_backend.c. References backEnd, backEndCounters_t::c_surfaces, backEndState_t::currentEntity, trRefdef_t::dlights, drawSurf_t, trRefEntity_t::e, trRefdef_t::entities, shader_s::entityMergable, trRefdef_t::floatTime, i, refimport_t::Milliseconds, orientationr_t::modelMatrix, trRefEntity_t::needDlights, trRefdef_t::num_dlights, backEndState_t::or, backEndState_t::pc, qboolean, qglDepthRange, qglLoadMatrixf, R_DecomposeSort(), R_RotateForEntity(), R_TransformDlights(), RB_BeginDrawingView(), RB_BeginSurface(), RB_DrawSun(), RB_EndSurface(), RB_RenderFlares(), RB_ShadowFinish(), rb_surfaceTable, backEndState_t::refdef, refEntity_t::renderfx, ri, shaderCommands_s::shader, shader_t, shaderCommands_s::shaderTime, refEntity_t::shaderTime, drawSurf_s::sort, drawSurf_s::surface, t, tess, shader_s::timeOffset, tr, backEndState_t::viewParms, viewParms_t::world, and trGlobals_t::worldEntity. Referenced by RB_DrawSurfs(). 00519 {
00520 shader_t *shader, *oldShader;
00521 int fogNum, oldFogNum;
00522 int entityNum, oldEntityNum;
00523 int dlighted, oldDlighted;
00524 qboolean depthRange, oldDepthRange;
00525 int i;
00526 drawSurf_t *drawSurf;
00527 int oldSort;
00528 float originalTime;
00529 #ifdef __MACOS__
00530 int macEventTime;
00531
00532 Sys_PumpEvents(); // crutch up the mac's limited buffer queue size
00533
00534 // we don't want to pump the event loop too often and waste time, so
00535 // we are going to check every shader change
00536 macEventTime = ri.Milliseconds() + MAC_EVENT_PUMP_MSEC;
00537 #endif
00538
00539 // save original time for entity shader offsets
00540 originalTime = backEnd.refdef.floatTime;
00541
00542 // clear the z buffer, set the modelview, etc
00543 RB_BeginDrawingView ();
00544
00545 // draw everything
00546 oldEntityNum = -1;
00547 backEnd.currentEntity = &tr.worldEntity;
00548 oldShader = NULL;
00549 oldFogNum = -1;
00550 oldDepthRange = qfalse;
00551 oldDlighted = qfalse;
00552 oldSort = -1;
00553 depthRange = qfalse;
00554
00555 backEnd.pc.c_surfaces += numDrawSurfs;
00556
00557 for (i = 0, drawSurf = drawSurfs ; i < numDrawSurfs ; i++, drawSurf++) {
00558 if ( drawSurf->sort == oldSort ) {
00559 // fast path, same as previous sort
00560 rb_surfaceTable[ *drawSurf->surface ]( drawSurf->surface );
00561 continue;
00562 }
00563 oldSort = drawSurf->sort;
00564 R_DecomposeSort( drawSurf->sort, &entityNum, &shader, &fogNum, &dlighted );
00565
00566 //
00567 // change the tess parameters if needed
00568 // a "entityMergable" shader is a shader that can have surfaces from seperate
00569 // entities merged into a single batch, like smoke and blood puff sprites
00570 if (shader != oldShader || fogNum != oldFogNum || dlighted != oldDlighted
00571 || ( entityNum != oldEntityNum && !shader->entityMergable ) ) {
00572 if (oldShader != NULL) {
00573 #ifdef __MACOS__ // crutch up the mac's limited buffer queue size
00574 int t;
00575
00576 t = ri.Milliseconds();
00577 if ( t > macEventTime ) {
00578 macEventTime = t + MAC_EVENT_PUMP_MSEC;
00579 Sys_PumpEvents();
00580 }
00581 #endif
00582 RB_EndSurface();
00583 }
00584 RB_BeginSurface( shader, fogNum );
00585 oldShader = shader;
00586 oldFogNum = fogNum;
00587 oldDlighted = dlighted;
00588 }
00589
00590 //
00591 // change the modelview matrix if needed
00592 //
00593 if ( entityNum != oldEntityNum ) {
00594 depthRange = qfalse;
00595
00596 if ( entityNum != ENTITYNUM_WORLD ) {
00597 backEnd.currentEntity = &backEnd.refdef.entities[entityNum];
00598 backEnd.refdef.floatTime = originalTime - backEnd.currentEntity->e.shaderTime;
00599 // we have to reset the shaderTime as well otherwise image animations start
00600 // from the wrong frame
00601 tess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset;
00602
00603 // set up the transformation matrix
00604 R_RotateForEntity( backEnd.currentEntity, &backEnd.viewParms, &backEnd.or );
00605
00606 // set up the dynamic lighting if needed
00607 if ( backEnd.currentEntity->needDlights ) {
00608 R_TransformDlights( backEnd.refdef.num_dlights, backEnd.refdef.dlights, &backEnd.or );
00609 }
00610
00611 if ( backEnd.currentEntity->e.renderfx & RF_DEPTHHACK ) {
00612 // hack the depth range to prevent view model from poking into walls
00613 depthRange = qtrue;
00614 }
00615 } else {
00616 backEnd.currentEntity = &tr.worldEntity;
00617 backEnd.refdef.floatTime = originalTime;
00618 backEnd.or = backEnd.viewParms.world;
00619 // we have to reset the shaderTime as well otherwise image animations on
00620 // the world (like water) continue with the wrong frame
00621 tess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset;
00622 R_TransformDlights( backEnd.refdef.num_dlights, backEnd.refdef.dlights, &backEnd.or );
00623 }
00624
00625 qglLoadMatrixf( backEnd.or.modelMatrix );
00626
00627 //
00628 // change depthrange if needed
00629 //
00630 if ( oldDepthRange != depthRange ) {
00631 if ( depthRange ) {
00632 qglDepthRange (0, 0.3);
00633 } else {
00634 qglDepthRange (0, 1);
00635 }
00636 oldDepthRange = depthRange;
00637 }
00638
00639 oldEntityNum = entityNum;
00640 }
00641
00642 // add the triangles for this surface
00643 rb_surfaceTable[ *drawSurf->surface ]( drawSurf->surface );
00644 }
00645
00646 backEnd.refdef.floatTime = originalTime;
00647
00648 // draw the contents of the last shader batch
00649 if (oldShader != NULL) {
00650 RB_EndSurface();
00651 }
00652
00653 // go back to the world modelview matrix
00654 qglLoadMatrixf( backEnd.viewParms.world.modelMatrix );
00655 if ( depthRange ) {
00656 qglDepthRange (0, 1);
00657 }
00658
00659 #if 0
00660 RB_DrawSun();
00661 #endif
00662 // darken down any stencil shadows
00663 RB_ShadowFinish();
00664
00665 // add light flares on lights that aren't obscured
00666 RB_RenderFlares();
00667
00668 #ifdef __MACOS__
00669 Sys_PumpEvents(); // crutch up the mac's limited buffer queue size
00670 #endif
00671 }
|
Here is the call graph for this function:

|
|
Definition at line 1124 of file tr_backend.c. References data, GLimp_RendererSleep(), RB_ExecuteRenderCommands(), and renderThreadActive. Referenced by R_InitCommandBuffers(). 01124 {
01125 const void *data;
01126
01127 // wait for either a rendering command or a quit command
01128 while ( 1 ) {
01129 // sleep until we have work to do
01130 data = GLimp_RendererSleep();
01131
01132 if ( !data ) {
01133 return; // all done, renderer is shutting down
01134 }
01135
01136 renderThreadActive = qtrue;
01137
01138 RB_ExecuteRenderCommands( data );
01139
01140 renderThreadActive = qfalse;
01141 }
01142 }
|
Here is the call graph for this function:

|
|
Definition at line 817 of file tr_backend.c. References backEnd, setColorCommand_t::color, and backEndState_t::color2D. Referenced by RB_ExecuteRenderCommands(). 00817 {
00818 const setColorCommand_t *cmd;
00819
00820 cmd = (const setColorCommand_t *)data;
00821
00822 backEnd.color2D[0] = cmd->color[0] * 255;
00823 backEnd.color2D[1] = cmd->color[1] * 255;
00824 backEnd.color2D[2] = cmd->color[2] * 255;
00825 backEnd.color2D[3] = cmd->color[3] * 255;
00826
00827 return (const void *)(cmd + 1);
00828 }
|
|
Here is the call graph for this function:

|
|
Definition at line 963 of file tr_backend.c. References backEnd, GL_Bind(), glConfig, h(), i, image_t, trGlobals_t::images, cvar_s::integer, refimport_t::Milliseconds, trGlobals_t::numImages, PRINT_ALL, backEndState_t::projection2D, qglBegin, qglClear, qglEnd, qglFinish, qglTexCoord2f, qglVertex2f, r_showImages, RB_SetGL2D(), ri, tr, image_s::uploadHeight, image_s::uploadWidth, glconfig_t::vidHeight, glconfig_t::vidWidth, w, x, and y. Referenced by RB_SwapBuffers(), and RE_EndRegistration(). 00963 {
00964 int i;
00965 image_t *image;
00966 float x, y, w, h;
00967 int start, end;
00968
00969 if ( !backEnd.projection2D ) {
00970 RB_SetGL2D();
00971 }
00972
00973 qglClear( GL_COLOR_BUFFER_BIT );
00974
00975 qglFinish();
00976
00977 start = ri.Milliseconds();
00978
00979 for ( i=0 ; i<tr.numImages ; i++ ) {
00980 image = tr.images[i];
00981
00982 w = glConfig.vidWidth / 20;
00983 h = glConfig.vidHeight / 15;
00984 x = i % 20 * w;
00985 y = i / 20 * h;
00986
00987 // show in proportional size in mode 2
00988 if ( r_showImages->integer == 2 ) {
00989 w *= image->uploadWidth / 512.0f;
00990 h *= image->uploadHeight / 512.0f;
00991 }
00992
00993 GL_Bind( image );
00994 qglBegin (GL_QUADS);
00995 qglTexCoord2f( 0, 0 );
00996 qglVertex2f( x, y );
00997 qglTexCoord2f( 1, 0 );
00998 qglVertex2f( x + w, y );
00999 qglTexCoord2f( 1, 1 );
01000 qglVertex2f( x + w, y + h );
01001 qglTexCoord2f( 0, 1 );
01002 qglVertex2f( x, y + h );
01003 qglEnd();
01004 }
01005
01006 qglFinish();
01007
01008 end = ri.Milliseconds();
01009 ri.Printf( PRINT_ALL, "%i msec to draw all images\n", end - start );
01010
01011 }
|
Here is the call graph for this function:

|