本文整理汇总了C++中RB_EndSurface函数的典型用法代码示例。如果您正苦于以下问题:C++ RB_EndSurface函数的具体用法?C++ RB_EndSurface怎么用?C++ RB_EndSurface使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RB_EndSurface函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RB_EndSurface
/*
=============
RB_SwapBuffers
=============
*/
const void *RB_SwapBuffers( const void *data ) {
const swapBuffersCommand_t *cmd;
// finish any 2D drawing if needed
if ( tess.numIndexes ) {
RB_EndSurface();
}
// texture swapping test
if ( r_showImages->integer ) {
RB_ShowImages();
}
cmd = (const swapBuffersCommand_t *)data;
// we measure overdraw by reading back the stencil buffer and
// counting up the number of increments that have happened
if ( r_measureOverdraw->integer ) {
int i;
long sum = 0;
unsigned char *stencilReadback;
stencilReadback = ri.Hunk_AllocateTempMemory( glConfig.vidWidth * glConfig.vidHeight );
qglReadPixels( 0, 0, glConfig.vidWidth, glConfig.vidHeight, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, stencilReadback );
for ( i = 0; i < glConfig.vidWidth * glConfig.vidHeight; i++ ) {
sum += stencilReadback[i];
}
backEnd.pc.c_overDraw += sum;
ri.Hunk_FreeTempMemory( stencilReadback );
}
if (glRefConfig.framebufferObject)
{
if (!backEnd.framePostProcessed)
{
if (tr.msaaResolveFbo && r_hdr->integer)
{
// Resolving an RGB16F MSAA FBO to the screen messes with the brightness, so resolve to an RGB16F FBO first
FBO_FastBlit(tr.renderFbo, NULL, tr.msaaResolveFbo, NULL, GL_COLOR_BUFFER_BIT, GL_NEAREST);
FBO_FastBlit(tr.msaaResolveFbo, NULL, NULL, NULL, GL_COLOR_BUFFER_BIT, GL_NEAREST);
}
else if (tr.renderFbo)
{
FBO_FastBlit(tr.renderFbo, NULL, NULL, NULL, GL_COLOR_BUFFER_BIT, GL_NEAREST);
}
}
}
if ( !glState.finishCalled ) {
qglFinish();
}
GLimp_LogComment( "***************** RB_SwapBuffers *****************\n\n\n" );
GLimp_EndFrame();
backEnd.framePostProcessed = qfalse;
backEnd.projection2D = qfalse;
return (const void *)(cmd + 1);
}
示例2: RB_SwapBuffers
/*
=============
RB_SwapBuffers
=============
*/
static int RB_SwapBuffers( const void *data ) {
// finish any 2D drawing if needed
if ( tess.numIndexes ) {
RB_EndSurface();
}
// texture swapping test
if ( r_showImages->integer ) {
RB_ShowImages();
}
backEnd.projection2D = qfalse;
tr.capturingDofOrStereo = qfalse;
tr.latestDofOrStereoFrame = qfalse;
/* Take and merge DOF frames */
if ( r_stereoSeparation->value <= 0.0f && !tr.finishStereo) {
if ( R_MME_MultiPassNext() ) {
return 1;
}
} else if ( r_stereoSeparation->value > 0.0f) {
if ( R_MME_MultiPassNextStereo() ) {
return 1;
}
}
// we measure overdraw by reading back the stencil buffer and
// counting up the number of increments that have happened
if ( r_measureOverdraw->integer ) {
int i;
long sum = 0;
unsigned char *stencilReadback;
stencilReadback = ri.Hunk_AllocateTempMemory( glConfig.vidWidth * glConfig.vidHeight );
qglReadPixels( 0, 0, glConfig.vidWidth, glConfig.vidHeight, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, stencilReadback );
for ( i = 0; i < glConfig.vidWidth * glConfig.vidHeight; i++ ) {
sum += stencilReadback[i];
}
backEnd.pc.c_overDraw += sum;
ri.Hunk_FreeTempMemory( stencilReadback );
}
if ( !glState.finishCalled ) {
qglFinish();
}
/* Allow MME to take a screenshot */
if ( r_stereoSeparation->value < 0.0f && tr.finishStereo) {
tr.capturingDofOrStereo = qtrue;
tr.latestDofOrStereoFrame = qtrue;
Cvar_SetValue("r_stereoSeparation", -r_stereoSeparation->value);
return 1;
} else if ( r_stereoSeparation->value <= 0.0f) {
if ( R_MME_TakeShot( ) && r_stereoSeparation->value != 0.0f) {
tr.capturingDofOrStereo = qtrue;
tr.latestDofOrStereoFrame = qfalse;
Cvar_SetValue("r_stereoSeparation", -r_stereoSeparation->value);
tr.finishStereo = qtrue;
return 1;
}
} else if ( r_stereoSeparation->value > 0.0f) {
if ( tr.finishStereo) {
R_MME_TakeShotStereo( );
R_MME_DoNotTake( );
Cvar_SetValue("r_stereoSeparation", -r_stereoSeparation->value);
tr.finishStereo = qfalse;
}
}
R_FrameBuffer_EndFrame();
GLimp_LogComment( "***************** RB_SwapBuffers *****************\n\n\n" );
GLimp_EndFrame();
return 0;
}
示例3: RB_DrawSun
/*
** RB_DrawSun
*/
void RB_DrawSun( void ) {
float size;
float dist;
vec3_t origin, vec1, vec2;
vec3_t temp;
if ( !backEnd.skyRenderedThisView ) {
return;
}
if ( !r_drawSun->integer ) {
return;
}
qglLoadMatrixf( backEnd.viewParms.world.modelMatrix );
qglTranslatef (backEnd.viewParms.ori.origin[0], backEnd.viewParms.ori.origin[1], backEnd.viewParms.ori.origin[2]);
dist = backEnd.viewParms.zFar / 1.75; // div sqrt(3)
size = dist * 0.4;
VectorScale( tr.sunDirection, dist, origin );
PerpendicularVector( vec1, tr.sunDirection );
CrossProduct( tr.sunDirection, vec1, vec2 );
VectorScale( vec1, size, vec1 );
VectorScale( vec2, size, vec2 );
// farthest depth range
qglDepthRange( 1.0, 1.0 );
// FIXME: use quad stamp
RB_BeginSurface( tr.sunShader, tess.fogNum );
VectorCopy( origin, temp );
VectorSubtract( temp, vec1, temp );
VectorSubtract( temp, vec2, temp );
VectorCopy( temp, tess.xyz[tess.numVertexes] );
tess.texCoords[tess.numVertexes][0][0] = 0;
tess.texCoords[tess.numVertexes][0][1] = 0;
tess.vertexColors[tess.numVertexes][0] = 255;
tess.vertexColors[tess.numVertexes][1] = 255;
tess.vertexColors[tess.numVertexes][2] = 255;
tess.numVertexes++;
VectorCopy( origin, temp );
VectorAdd( temp, vec1, temp );
VectorSubtract( temp, vec2, temp );
VectorCopy( temp, tess.xyz[tess.numVertexes] );
tess.texCoords[tess.numVertexes][0][0] = 0;
tess.texCoords[tess.numVertexes][0][1] = 1;
tess.vertexColors[tess.numVertexes][0] = 255;
tess.vertexColors[tess.numVertexes][1] = 255;
tess.vertexColors[tess.numVertexes][2] = 255;
tess.numVertexes++;
VectorCopy( origin, temp );
VectorAdd( temp, vec1, temp );
VectorAdd( temp, vec2, temp );
VectorCopy( temp, tess.xyz[tess.numVertexes] );
tess.texCoords[tess.numVertexes][0][0] = 1;
tess.texCoords[tess.numVertexes][0][1] = 1;
tess.vertexColors[tess.numVertexes][0] = 255;
tess.vertexColors[tess.numVertexes][1] = 255;
tess.vertexColors[tess.numVertexes][2] = 255;
tess.numVertexes++;
VectorCopy( origin, temp );
VectorSubtract( temp, vec1, temp );
VectorAdd( temp, vec2, temp );
VectorCopy( temp, tess.xyz[tess.numVertexes] );
tess.texCoords[tess.numVertexes][0][0] = 1;
tess.texCoords[tess.numVertexes][0][1] = 0;
tess.vertexColors[tess.numVertexes][0] = 255;
tess.vertexColors[tess.numVertexes][1] = 255;
tess.vertexColors[tess.numVertexes][2] = 255;
tess.numVertexes++;
tess.indexes[tess.numIndexes++] = 0;
tess.indexes[tess.numIndexes++] = 1;
tess.indexes[tess.numIndexes++] = 2;
tess.indexes[tess.numIndexes++] = 0;
tess.indexes[tess.numIndexes++] = 2;
tess.indexes[tess.numIndexes++] = 3;
RB_EndSurface();
// back to normal depth range
qglDepthRange( 0.0, 1.0 );
}
示例4: RB_EndSurface
/*
=============
RB_StretchPic
=============
*/
const void *RB_StretchPic ( const void *data ) {
const stretchPicCommand_t *cmd;
shader_t *shader;
int numVerts, numIndexes;
cmd = (const stretchPicCommand_t *)data;
shader = cmd->shader;
if ( shader != tess.shader ) {
if ( tess.numIndexes ) {
RB_EndSurface(); //this might change culling and other states
}
backEnd.currentEntity = &backEnd.entity2D;
RB_BeginSurface( shader, 0 );
}
if ( !backEnd.projection2D ) {
RB_SetGL2D(); //set culling and other states
}
RB_CHECKOVERFLOW( 4, 6 );
numVerts = tess.numVertexes;
numIndexes = tess.numIndexes;
tess.numVertexes += 4;
tess.numIndexes += 6;
tess.indexes[ numIndexes ] = numVerts + 3;
tess.indexes[ numIndexes + 1 ] = numVerts + 0;
tess.indexes[ numIndexes + 2 ] = numVerts + 2;
tess.indexes[ numIndexes + 3 ] = numVerts + 2;
tess.indexes[ numIndexes + 4 ] = numVerts + 0;
tess.indexes[ numIndexes + 5 ] = numVerts + 1;
*(int *)tess.vertexColors[ numVerts ] =
*(int *)tess.vertexColors[ numVerts + 1 ] =
*(int *)tess.vertexColors[ numVerts + 2 ] =
*(int *)tess.vertexColors[ numVerts + 3 ] = *(int *)backEnd.color2D;
tess.xyz[ numVerts ][0] = cmd->x;
tess.xyz[ numVerts ][1] = cmd->y;
tess.xyz[ numVerts ][2] = 0;
tess.texCoords[ numVerts ][0][0] = cmd->s1;
tess.texCoords[ numVerts ][0][1] = cmd->t1;
tess.xyz[ numVerts + 1 ][0] = cmd->x + cmd->w;
tess.xyz[ numVerts + 1 ][1] = cmd->y;
tess.xyz[ numVerts + 1 ][2] = 0;
tess.texCoords[ numVerts + 1 ][0][0] = cmd->s2;
tess.texCoords[ numVerts + 1 ][0][1] = cmd->t1;
tess.xyz[ numVerts + 2 ][0] = cmd->x + cmd->w;
tess.xyz[ numVerts + 2 ][1] = cmd->y + cmd->h;
tess.xyz[ numVerts + 2 ][2] = 0;
tess.texCoords[ numVerts + 2 ][0][0] = cmd->s2;
tess.texCoords[ numVerts + 2 ][0][1] = cmd->t2;
tess.xyz[ numVerts + 3 ][0] = cmd->x;
tess.xyz[ numVerts + 3 ][1] = cmd->y + cmd->h;
tess.xyz[ numVerts + 3 ][2] = 0;
tess.texCoords[ numVerts + 3 ][0][0] = cmd->s1;
tess.texCoords[ numVerts + 3 ][0][1] = cmd->t2;
return (const void *)(cmd + 1);
}
示例5: RB_EndSurface
/*
=============
RB_PostProcess
=============
*/
const void *RB_PostProcess(const void *data)
{
const postProcessCommand_t *cmd = data;
FBO_t *srcFbo;
ivec4_t srcBox, dstBox;
qboolean autoExposure;
// finish any 2D drawing if needed
if(tess.numIndexes)
RB_EndSurface();
if (!glRefConfig.framebufferObject || !r_postProcess->integer)
{
// do nothing
return (const void *)(cmd + 1);
}
if (cmd)
{
backEnd.refdef = cmd->refdef;
backEnd.viewParms = cmd->viewParms;
}
srcFbo = tr.renderFbo;
if (tr.msaaResolveFbo)
{
// Resolve the MSAA before anything else
// Can't resolve just part of the MSAA FBO, so multiple views will suffer a performance hit here
FBO_FastBlit(tr.renderFbo, NULL, tr.msaaResolveFbo, NULL, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST);
srcFbo = tr.msaaResolveFbo;
}
dstBox[0] = backEnd.viewParms.viewportX;
dstBox[1] = backEnd.viewParms.viewportY;
dstBox[2] = backEnd.viewParms.viewportWidth;
dstBox[3] = backEnd.viewParms.viewportHeight;
if (r_ssao->integer)
{
srcBox[0] = backEnd.viewParms.viewportX * tr.screenSsaoImage->width / (float)glConfig.vidWidth;
srcBox[1] = backEnd.viewParms.viewportY * tr.screenSsaoImage->height / (float)glConfig.vidHeight;
srcBox[2] = backEnd.viewParms.viewportWidth * tr.screenSsaoImage->width / (float)glConfig.vidWidth;
srcBox[3] = backEnd.viewParms.viewportHeight * tr.screenSsaoImage->height / (float)glConfig.vidHeight;
FBO_Blit(tr.screenSsaoFbo, srcBox, NULL, srcFbo, dstBox, NULL, NULL, GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO);
}
srcBox[0] = backEnd.viewParms.viewportX;
srcBox[1] = backEnd.viewParms.viewportY;
srcBox[2] = backEnd.viewParms.viewportWidth;
srcBox[3] = backEnd.viewParms.viewportHeight;
if (srcFbo)
{
if (r_hdr->integer && (r_toneMap->integer || r_forceToneMap->integer))
{
autoExposure = r_autoExposure->integer || r_forceAutoExposure->integer;
RB_ToneMap(srcFbo, srcBox, NULL, dstBox, autoExposure);
}
else if (r_cameraExposure->value == 0.0f)
{
FBO_FastBlit(srcFbo, srcBox, NULL, dstBox, GL_COLOR_BUFFER_BIT, GL_NEAREST);
}
else
{
vec4_t color;
color[0] =
color[1] =
color[2] = pow(2, r_cameraExposure->value); //exp2(r_cameraExposure->value);
color[3] = 1.0f;
FBO_Blit(srcFbo, srcBox, NULL, NULL, dstBox, NULL, color, 0);
}
}
if (r_drawSunRays->integer)
RB_SunRays(NULL, srcBox, NULL, dstBox);
if (1)
RB_BokehBlur(NULL, srcBox, NULL, dstBox, backEnd.refdef.blurFactor);
else
RB_GaussianBlur(backEnd.refdef.blurFactor);
#if 0
if (0)
{
vec4_t quadVerts[4];
vec2_t texCoords[4];
ivec4_t iQtrBox;
vec4_t box;
vec4_t viewInfo;
static float scale = 5.0f;
//.........这里部分代码省略.........
示例6: RE_StretchRaw
/*
=============
RE_StretchRaw
FIXME: not exactly backend
Stretches a raw 32 bit power of 2 bitmap image over the given screen rectangle.
Used for cinematics.
=============
*/
void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty) {
int i, j;
int start, end;
vec4_t quadVerts[4];
vec2_t texCoords[4];
if ( !tr.registered ) {
return;
}
R_IssuePendingRenderCommands();
if ( tess.numIndexes ) {
RB_EndSurface();
}
// we definately want to sync every frame for the cinematics
qglFinish();
start = 0;
if ( r_speeds->integer ) {
start = ri.Milliseconds();
}
// make sure rows and cols are powers of 2
for ( i = 0 ; ( 1 << i ) < cols ; i++ ) {
}
for ( j = 0 ; ( 1 << j ) < rows ; j++ ) {
}
if ( ( 1 << i ) != cols || ( 1 << j ) != rows) {
ri.Error (ERR_DROP, "Draw_StretchRaw: size not a power of 2: %i by %i", cols, rows);
}
RE_UploadCinematic (w, h, cols, rows, data, client, dirty);
GL_BindToTMU(tr.scratchImage[client], TB_COLORMAP);
if ( r_speeds->integer ) {
end = ri.Milliseconds();
ri.Printf( PRINT_ALL, "qglTexSubImage2D %i, %i: %i msec\n", cols, rows, end - start );
}
// FIXME: HUGE hack
if (glRefConfig.framebufferObject)
{
FBO_Bind(backEnd.framePostProcessed ? NULL : tr.renderFbo);
}
RB_SetGL2D();
VectorSet4(quadVerts[0], x, y, 0.0f, 1.0f);
VectorSet4(quadVerts[1], x + w, y, 0.0f, 1.0f);
VectorSet4(quadVerts[2], x + w, y + h, 0.0f, 1.0f);
VectorSet4(quadVerts[3], x, y + h, 0.0f, 1.0f);
VectorSet2(texCoords[0], 0.5f / cols, 0.5f / rows);
VectorSet2(texCoords[1], (cols - 0.5f) / cols, 0.5f / rows);
VectorSet2(texCoords[2], (cols - 0.5f) / cols, (rows - 0.5f) / rows);
VectorSet2(texCoords[3], 0.5f / cols, (rows - 0.5f) / rows);
GLSL_BindProgram(&tr.textureColorShader);
GLSL_SetUniformMat4(&tr.textureColorShader, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
GLSL_SetUniformVec4(&tr.textureColorShader, UNIFORM_COLOR, colorWhite);
RB_InstantQuad2(quadVerts, texCoords);
}
示例7: RB_SetGL2D
/*
=============
RB_RotatedPic
=============
*/
const void *RB_RotatedPic(const void *data)
{
const stretchPicCommand_t *cmd = ( const stretchPicCommand_t * ) data;
shader_t *shader;
int numVerts, numIndexes;
float angle;
float pi2 = M_PI * 2;
if (!backEnd.projection2D)
{
RB_SetGL2D();
}
shader = cmd->shader;
if (shader != tess.shader)
{
if (tess.numIndexes)
{
RB_EndSurface();
}
backEnd.currentEntity = &backEnd.entity2D;
RB_BeginSurface(shader, 0);
}
RB_CHECKOVERFLOW(4, 6);
numVerts = tess.numVertexes;
numIndexes = tess.numIndexes;
tess.numVertexes += 4;
tess.numIndexes += 6;
tess.indexes[numIndexes] = numVerts + 3;
tess.indexes[numIndexes + 1] = numVerts + 0;
tess.indexes[numIndexes + 2] = numVerts + 2;
tess.indexes[numIndexes + 3] = numVerts + 2;
tess.indexes[numIndexes + 4] = numVerts + 0;
tess.indexes[numIndexes + 5] = numVerts + 1;
*( int * ) tess.vertexColors[numVerts].v =
*( int * ) tess.vertexColors[numVerts + 1].v =
*( int * ) tess.vertexColors[numVerts + 2].v =
*( int * ) tess.vertexColors[numVerts + 3].v = *( int * ) backEnd.color2D;
angle = cmd->angle * pi2;
tess.xyz[numVerts].v[0] = cmd->x + (cos(angle) * cmd->w);
tess.xyz[numVerts].v[1] = cmd->y + (sin(angle) * cmd->h);
tess.xyz[numVerts].v[2] = 0;
tess.texCoords0[numVerts].v[0] = cmd->s1;
tess.texCoords0[numVerts].v[1] = cmd->t1;
angle = cmd->angle * pi2 + 0.25 * pi2;
tess.xyz[numVerts + 1].v[0] = cmd->x + (cos(angle) * cmd->w);
tess.xyz[numVerts + 1].v[1] = cmd->y + (sin(angle) * cmd->h);
tess.xyz[numVerts + 1].v[2] = 0;
tess.texCoords0[numVerts + 1].v[0] = cmd->s2;
tess.texCoords0[numVerts + 1].v[1] = cmd->t1;
angle = cmd->angle * pi2 + 0.50 * pi2;
tess.xyz[numVerts + 2].v[0] = cmd->x + (cos(angle) * cmd->w);
tess.xyz[numVerts + 2].v[1] = cmd->y + (sin(angle) * cmd->h);
tess.xyz[numVerts + 2].v[2] = 0;
tess.texCoords0[numVerts + 2].v[0] = cmd->s2;
tess.texCoords0[numVerts + 2].v[1] = cmd->t2;
angle = cmd->angle * pi2 + 0.75 * pi2;
tess.xyz[numVerts + 3].v[0] = cmd->x + (cos(angle) * cmd->w);
tess.xyz[numVerts + 3].v[1] = cmd->y + (sin(angle) * cmd->h);
tess.xyz[numVerts + 3].v[2] = 0;
tess.texCoords0[numVerts + 3].v[0] = cmd->s1;
tess.texCoords0[numVerts + 3].v[1] = cmd->t2;
return ( const void * ) (cmd + 1);
}
示例8: RB_RenderDrawSurfList
/*
==================
RB_RenderDrawSurfList
==================
*/
void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
shader_t *shader, *oldShader;
int fogNum, oldFogNum;
int entityNum, oldEntityNum;
int dlighted, oldDlighted;
qboolean depthRange, oldDepthRange, isCrosshair, wasCrosshair;
int i;
drawSurf_t *drawSurf;
int oldSort;
float originalTime;
// save original time for entity shader offsets
originalTime = backEnd.refdef.floatTime;
// clear the z buffer, set the modelview, etc
RB_BeginDrawingView ();
// draw everything
oldEntityNum = -1;
backEnd.currentEntity = &tr.worldEntity;
oldShader = NULL;
oldFogNum = -1;
oldDepthRange = qfalse;
wasCrosshair = qfalse;
oldDlighted = qfalse;
oldSort = -1;
depthRange = qfalse;
backEnd.pc.c_surfaces += numDrawSurfs;
for (i = 0, drawSurf = drawSurfs ; i < numDrawSurfs ; i++, drawSurf++) {
if ( drawSurf->sort == oldSort ) {
// fast path, same as previous sort
rb_surfaceTable[ *drawSurf->surface ]( drawSurf->surface );
continue;
}
oldSort = drawSurf->sort;
R_DecomposeSort( drawSurf->sort, &entityNum, &shader, &fogNum, &dlighted );
//
// change the tess parameters if needed
// a "entityMergable" shader is a shader that can have surfaces from seperate
// entities merged into a single batch, like smoke and blood puff sprites
if ( shader != NULL && ( shader != oldShader || fogNum != oldFogNum || dlighted != oldDlighted
|| ( entityNum != oldEntityNum && !shader->entityMergable ) ) ) {
if (oldShader != NULL) {
RB_EndSurface();
}
RB_BeginSurface( shader, fogNum );
oldShader = shader;
oldFogNum = fogNum;
oldDlighted = dlighted;
}
//
// change the modelview matrix if needed
//
if ( entityNum != oldEntityNum ) {
depthRange = isCrosshair = qfalse;
if ( entityNum != REFENTITYNUM_WORLD ) {
backEnd.currentEntity = &backEnd.refdef.entities[entityNum];
backEnd.refdef.floatTime = originalTime - backEnd.currentEntity->e.shaderTime;
// we have to reset the shaderTime as well otherwise image animations start
// from the wrong frame
tess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset;
// set up the transformation matrix
R_RotateForEntity( backEnd.currentEntity, &backEnd.viewParms, &backEnd.or );
// set up the dynamic lighting if needed
if ( backEnd.currentEntity->needDlights ) {
R_TransformDlights( backEnd.refdef.num_dlights, backEnd.refdef.dlights, &backEnd.or );
}
if(backEnd.currentEntity->e.renderfx & RF_DEPTHHACK)
{
// hack the depth range to prevent view model from poking into walls
depthRange = qtrue;
if(backEnd.currentEntity->e.renderfx & RF_CROSSHAIR)
isCrosshair = qtrue;
}
} else {
backEnd.currentEntity = &tr.worldEntity;
backEnd.refdef.floatTime = originalTime;
backEnd.or = backEnd.viewParms.world;
// we have to reset the shaderTime as well otherwise image animations on
// the world (like water) continue with the wrong frame
tess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset;
R_TransformDlights( backEnd.refdef.num_dlights, backEnd.refdef.dlights, &backEnd.or );
}
qglLoadMatrixf( backEnd.or.modelMatrix );
//.........这里部分代码省略.........
示例9: RB_RenderDrawSurfList
//.........这里部分代码省略.........
//remember the other values necessary for rendering this surf
pRender->drawSurf = drawSurf;
pRender->dlighted = dlighted;
pRender->fogNum = fogNum;
pRender->shader = shader;
//assure the info is back to the last set state
shader = oldShader;
entityNum = oldEntityNum;
fogNum = oldFogNum;
dlighted = oldDlighted;
oldSort = (unsigned int)-1; //invalidate this thing, cause we may want to postrender more surfs of the same sort
//continue without bothering to begin a draw surf
continue;
}
}
if (shader != oldShader || fogNum != oldFogNum || dlighted != oldDlighted
|| ( entityNum != oldEntityNum && !shader->entityMergable ) )
{
if (oldShader != NULL) {
#ifdef __MACOS__ // crutch up the mac's limited buffer queue size
int t;
t = Sys_Milliseconds();
if ( t > macEventTime ) {
macEventTime = t + MAC_EVENT_PUMP_MSEC;
Sys_PumpEvents();
}
#endif
RB_EndSurface();
if (!didShadowPass && shader && shader->sort > SS_BANNER)
{
RB_ShadowFinish();
didShadowPass = true;
}
}
RB_BeginSurface( shader, fogNum );
oldShader = shader;
oldFogNum = fogNum;
oldDlighted = dlighted;
}
//
// change the modelview matrix if needed
//
if ( entityNum != oldEntityNum ) {
depthRange = qfalse;
if ( entityNum != TR_WORLDENT ) {
backEnd.currentEntity = &backEnd.refdef.entities[entityNum];
backEnd.refdef.floatTime = originalTime - backEnd.currentEntity->e.shaderTime;
// set up the transformation matrix
R_RotateForEntity( backEnd.currentEntity, &backEnd.viewParms, &backEnd.ori );
// set up the dynamic lighting if needed
if ( backEnd.currentEntity->needDlights ) {
#ifdef VV_LIGHTING
VVLightMan.R_TransformDlights( &backEnd.ori );
#else
R_TransformDlights( backEnd.refdef.num_dlights, backEnd.refdef.dlights, &backEnd.ori );
示例10: RB_EndSurface
/*
=============
RB_SwapBuffers
=============
*/
const void *RB_SwapBuffers( const void *data ) {
const swapBuffersCommand_t *cmd;
// finish any 2D drawing if needed
if ( tess.numIndexes ) {
RB_EndSurface();
}
// texture swapping test
if ( r_showImages->integer ) {
RB_ShowImages();
}
cmd = (const swapBuffersCommand_t *)data;
// we measure overdraw by reading back the stencil buffer and
// counting up the number of increments that have happened
// there is an extension to read from stencil buffer on GLES, but it's not available on every device, and I'm too lazy
#ifndef GL_VERSION_ES_CM_1_0
if ( r_measureOverdraw->integer ) {
int i;
long sum = 0;
unsigned char *stencilReadback;
stencilReadback = ri.Hunk_AllocateTempMemory( glConfig.vidWidth * glConfig.vidHeight );
qglReadPixels( 0, 0, glConfig.vidWidth, glConfig.vidHeight, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, stencilReadback );
for ( i = 0; i < glConfig.vidWidth * glConfig.vidHeight; i++ ) {
sum += stencilReadback[i];
}
backEnd.pc.c_overDraw += sum;
ri.Hunk_FreeTempMemory( stencilReadback );
}
#endif
if ( !glState.finishCalled ) {
qglFinish();
}
GLimp_LogComment( "***************** RB_SwapBuffers *****************\n\n\n" );
GLimp_EndFrame();
/*
if (r_cardboardStereo->integer && Key_GetCatcher( ) & (KEYCATCH_UI | KEYCATCH_CONSOLE)) {
qglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
qglClearColor(0.0f, 0.0f, 0.0f, 1.0f);
qglClear(GL_COLOR_BUFFER_BIT);
}
*/
#ifdef __ANDROID__
// On-screen keyboard messes up GL state a bit
glState.currenttextures[0] = 0;
glState.currenttmu = 0;
glState.texEnv[glState.currenttmu] = GL_MODULATE;
glState.glStateBits &= ~(GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS);
glState.glStateBits |= (GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA);
#endif
backEnd.projection2D = qfalse;
backEnd.doneBloom = qfalse;
backEnd.donepostproc = qfalse;
backEnd.doneSurfaces = qfalse;
return (const void *)(cmd + 1);
}
示例11: RB_EndSurface
/*
=============
RB_DrawSurfs
=============
*/
const void *RB_DrawSurfs( const void *data ) {
const drawSurfsCommand_t *cmd;
// finish any 2D drawing if needed
if ( tess.numIndexes ) {
RB_EndSurface();
}
cmd = (const drawSurfsCommand_t *)data;
backEnd.refdef = cmd->refdef;
backEnd.viewParms = cmd->viewParms;
RB_RenderDrawSurfList( cmd->drawSurfs, cmd->numDrawSurfs );
// Dynamic Glow/Flares:
/*
The basic idea is to render the glowing parts of the scene to an offscreen buffer, then take
that buffer and blur it. After it is sufficiently blurred, re-apply that image back to
the normal screen using a additive blending. To blur the scene I use a vertex program to supply
four texture coordinate offsets that allow 'peeking' into adjacent pixels. In the register
combiner (pixel shader), I combine the adjacent pixels using a weighting factor. - Aurelio
*/
// Render dynamic glowing/flaring objects.
#ifndef _XBOX // GLOWXXX
if ( !(backEnd.refdef.rdflags & RDF_NOWORLDMODEL) && g_bDynamicGlowSupported && r_DynamicGlow->integer )
{
// Copy the normal scene to texture.
qglDisable( GL_TEXTURE_2D );
qglEnable( GL_TEXTURE_RECTANGLE_EXT );
qglBindTexture( GL_TEXTURE_RECTANGLE_EXT, tr.sceneImage );
qglCopyTexSubImage2D( GL_TEXTURE_RECTANGLE_EXT, 0, 0, 0, backEnd.viewParms.viewportX, backEnd.viewParms.viewportY, backEnd.viewParms.viewportWidth, backEnd.viewParms.viewportHeight);
qglDisable( GL_TEXTURE_RECTANGLE_EXT );
qglEnable( GL_TEXTURE_2D );
// Just clear colors, but leave the depth buffer intact so we can 'share' it.
qglClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
qglClear( GL_COLOR_BUFFER_BIT );
// Render the glowing objects.
g_bRenderGlowingObjects = true;
RB_RenderDrawSurfList( cmd->drawSurfs, cmd->numDrawSurfs );
g_bRenderGlowingObjects = false;
qglFinish();
// Copy the glow scene to texture.
qglDisable( GL_TEXTURE_2D );
qglEnable( GL_TEXTURE_RECTANGLE_EXT );
qglBindTexture( GL_TEXTURE_RECTANGLE_EXT, tr.screenGlow );
qglCopyTexSubImage2D( GL_TEXTURE_RECTANGLE_EXT, 0, 0, 0, backEnd.viewParms.viewportX, backEnd.viewParms.viewportY, backEnd.viewParms.viewportWidth, backEnd.viewParms.viewportHeight );
qglDisable( GL_TEXTURE_RECTANGLE_EXT );
qglEnable( GL_TEXTURE_2D );
// Resize the viewport to the blur texture size.
const int oldViewWidth = backEnd.viewParms.viewportWidth;
const int oldViewHeight = backEnd.viewParms.viewportHeight;
backEnd.viewParms.viewportWidth = r_DynamicGlowWidth->integer;
backEnd.viewParms.viewportHeight = r_DynamicGlowHeight->integer;
SetViewportAndScissor();
// Blur the scene.
RB_BlurGlowTexture();
// Copy the finished glow scene back to texture.
qglDisable( GL_TEXTURE_2D );
qglEnable( GL_TEXTURE_RECTANGLE_EXT );
qglBindTexture( GL_TEXTURE_RECTANGLE_EXT, tr.blurImage );
qglCopyTexSubImage2D( GL_TEXTURE_RECTANGLE_EXT, 0, 0, 0, 0, 0, backEnd.viewParms.viewportWidth, backEnd.viewParms.viewportHeight );
qglDisable( GL_TEXTURE_RECTANGLE_EXT );
qglEnable( GL_TEXTURE_2D );
// Set the viewport back to normal.
backEnd.viewParms.viewportWidth = oldViewWidth;
backEnd.viewParms.viewportHeight = oldViewHeight;
SetViewportAndScissor();
qglClear( GL_COLOR_BUFFER_BIT );
// Draw the glow additively over the screen.
RB_DrawGlowOverlay();
}
#endif // _XBOX
return (const void *)(cmd + 1);
}
示例12: RB_EndSurface
/*
=============
RB_PostProcess
=============
*/
const void *RB_PostProcess(const void *data)
{
const postProcessCommand_t *cmd = data;
FBO_t *srcFbo;
qboolean autoExposure;
// finish any 2D drawing if needed
if(tess.numIndexes)
RB_EndSurface();
if (!glRefConfig.framebufferObject || !r_postProcess->integer)
{
// do nothing
return (const void *)(cmd + 1);
}
srcFbo = tr.renderFbo;
if (tr.msaaResolveFbo)
{
// Resolve the MSAA before anything else
FBO_FastBlit(tr.renderFbo, NULL, tr.msaaResolveFbo, NULL, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST);
srcFbo = tr.msaaResolveFbo;
}
if (r_ssao->integer)
{
FBO_BlitFromTexture(tr.screenSsaoImage, NULL, NULL, srcFbo, NULL, NULL, NULL, GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO);
}
if (srcFbo)
{
if (r_hdr->integer && (r_toneMap->integer || r_forceToneMap->integer))
{
autoExposure = r_autoExposure->integer || r_forceAutoExposure->integer;
RB_ToneMap(srcFbo, autoExposure);
}
else if (r_cameraExposure->value == 0.0f)
{
FBO_FastBlit(srcFbo, NULL, tr.screenScratchFbo, NULL, GL_COLOR_BUFFER_BIT, GL_NEAREST);
}
else
{
vec4_t color;
color[0] =
color[1] =
color[2] = pow(2, r_cameraExposure->value); //exp2(r_cameraExposure->value);
color[3] = 1.0f;
FBO_Blit(srcFbo, NULL, NULL, tr.screenScratchFbo, NULL, NULL, color, 0);
}
}
if (r_drawSunRays->integer)
RB_SunRays();
if (1)
RB_BokehBlur(backEnd.refdef.blurFactor);
else
RB_GaussianBlur(backEnd.refdef.blurFactor);
if (0)
{
vec4i_t dstBox;
VectorSet4(dstBox, 0, 0, 128, 128);
FBO_BlitFromTexture(tr.sunShadowDepthImage[0], NULL, NULL, tr.screenScratchFbo, dstBox, NULL, NULL, 0);
VectorSet4(dstBox, 128, 0, 128, 128);
FBO_BlitFromTexture(tr.sunShadowDepthImage[1], NULL, NULL, tr.screenScratchFbo, dstBox, NULL, NULL, 0);
VectorSet4(dstBox, 256, 0, 128, 128);
FBO_BlitFromTexture(tr.sunShadowDepthImage[2], NULL, NULL, tr.screenScratchFbo, dstBox, NULL, NULL, 0);
}
if (0)
{
vec4i_t dstBox;
VectorSet4(dstBox, 256, glConfig.vidHeight - 256, 256, 256);
FBO_BlitFromTexture(tr.renderDepthImage, NULL, NULL, tr.screenScratchFbo, dstBox, NULL, NULL, 0);
VectorSet4(dstBox, 512, glConfig.vidHeight - 256, 256, 256);
FBO_BlitFromTexture(tr.screenShadowImage, NULL, NULL, tr.screenScratchFbo, dstBox, NULL, NULL, 0);
}
if (0)
{
vec4i_t dstBox;
VectorSet4(dstBox, 256, glConfig.vidHeight - 256, 256, 256);
FBO_BlitFromTexture(tr.sunRaysImage, NULL, NULL, tr.screenScratchFbo, dstBox, NULL, NULL, 0);
}
backEnd.framePostProcessed = qtrue;
return (const void *)(cmd + 1);
}
示例13: RB_RenderDrawSurfList
/*
==================
RB_RenderDrawSurfList
==================
*/
void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
shader_t *shader;
int fogNum;
qboolean depthRange, oldDepthRange;
int i;
drawSurf_t *drawSurf;
int oldSort;
const surfaceType_t *surface;
// clear the z buffer, set the modelview, etc
RB_BeginDrawingView ();
// Prepare initial values that will trigger the needed settings
backEnd.currentModel = (sceneModel_t*)-1;
oldDepthRange = qfalse;
oldSort = -1;
depthRange = qfalse;
// Clear for endsurface first run
tess.numIndexes = 0;
backEnd.pc.c_surfaces += numDrawSurfs;
if (!(backEnd.refdef->rdflags & RDF_NOWORLDMODEL)) {
backEnd.sceneZfar = backEnd.viewParms.zFar;
}
for (i = 0, drawSurf = drawSurfs ; i < numDrawSurfs ; i++, drawSurf++) {
/* Rendering a model? */
if ( drawSurf->sort & QSORT_HAVEMODEL_MASK ) {
const drawModel_t *drawModel;
unsigned int index;
RB_EndSurface();
oldSort = drawSurf->sort;
drawModel = (drawModel_t*) drawSurf->data;
backEnd.currentModel = drawModel->model;
index = R_SortToIndex( oldSort );
surface = drawModel->surface[index];
// set up the transformation matrix
R_RotateForEntity( backEnd.currentModel, &backEnd.viewParms, &backEnd.or );
R_TransformDlights( backEnd.refdef->numDlights, backEnd.refdef->dlights, &backEnd.or );
//Load the temporary matrix to show the model
qglLoadMatrixf( backEnd.or.modelMatrix );
depthRange = 0;
//figure this stuff out now and store it
if ( backEnd.currentModel->renderfx & RF_NODEPTH ) {
depthRange = 2;
} else if ( backEnd.currentModel->renderfx & RF_DEPTHHACK ) {
depthRange = 1;
}
if ( oldDepthRange != depthRange ) {
oldDepthRange = depthRange;
switch ( depthRange ) {
default:
case 0:
qglDepthRange (0, 1);
break;
case 1:
qglDepthRange (0, .3);
break;
case 2:
qglDepthRange (0, 0);
break;
}
}
shader = R_SortToShader( oldSort );
fogNum = R_SortToFog( oldSort );
RB_BeginSurface( shader, fogNum );
if ( mme_saveStencil->integer == 1) {
if ( backEnd.currentModel->renderfx & RF_STENCIL) {
if (!backEnd.doingStencil) {
qglStencilOp( GL_KEEP, GL_KEEP, GL_REPLACE );
backEnd.doingStencil = qtrue;
}
} else {
if (backEnd.doingStencil) {
qglStencilOp( GL_KEEP, GL_KEEP, GL_ZERO );
backEnd.doingStencil = qfalse;
}
}
}
rb_surfaceTable[ *surface ]( surface );
continue;
}
if ( drawSurf->sort == oldSort ) {
// fast path, same as previous sort
rb_surfaceTable[ *((byte *)drawSurf->data) ]( drawSurf->data );
continue;
}
RB_EndSurface();
oldSort = drawSurf->sort;
shader = R_SortToShader( oldSort );
fogNum = R_SortToFog( oldSort );
//.........这里部分代码省略.........
示例14: RB_RenderFlare
//.........这里部分代码省略.........
// calculate the flare size..
size = backEnd.viewParms.viewportWidth * ( r_flareSize->value/640.0f + 8 / distance );
/*
* This is an alternative to intensity scaling. It changes the size of the flare on screen instead
* with growing distance. See in the description at the top why this is not the way to go.
// size will change ~ 1/r.
size = backEnd.viewParms.viewportWidth * (r_flareSize->value / (distance * -2.0f));
*/
/*
* As flare sizes stay nearly constant with increasing distance we must decrease the intensity
* to achieve a reasonable visual result. The intensity is ~ (size^2 / distance^2) which can be
* got by considering the ratio of
* (flaresurface on screen) : (Surface of sphere defined by flare origin and distance from flare)
* An important requirement is:
* intensity <= 1 for all distances.
*
* The formula used here to compute the intensity is as follows:
* intensity = flareCoeff * size^2 / (distance + size*sqrt(flareCoeff))^2
* As you can see, the intensity will have a max. of 1 when the distance is 0.
* The coefficient flareCoeff will determine the falloff speed with increasing distance.
*/
factor = distance + size * sqrt(flareCoeff);
intensity = flareCoeff * size * size / (factor * factor);
VectorScale(f->color, f->drawIntensity * intensity, color);
// Calculations for fogging
if(tr.world && f->fogNum < tr.world->numfogs)
{
tess.numVertexes = 1;
VectorCopy(f->origin, tess.xyz[0]);
tess.fogNum = f->fogNum;
RB_CalcModulateColorsByFog(fogFactors);
// We don't need to render the flare if colors are 0 anyways.
if(!(fogFactors[0] || fogFactors[1] || fogFactors[2]))
return;
}
iColor[0] = color[0] * fogFactors[0];
iColor[1] = color[1] * fogFactors[1];
iColor[2] = color[2] * fogFactors[2];
RB_BeginSurface( tr.flareShader, f->fogNum );
// FIXME: use quadstamp?
tess.xyz[tess.numVertexes][0] = f->windowX - size;
tess.xyz[tess.numVertexes][1] = f->windowY - size;
tess.texCoords[tess.numVertexes][0][0] = 0;
tess.texCoords[tess.numVertexes][0][1] = 0;
tess.vertexColors[tess.numVertexes][0] = iColor[0];
tess.vertexColors[tess.numVertexes][1] = iColor[1];
tess.vertexColors[tess.numVertexes][2] = iColor[2];
tess.vertexColors[tess.numVertexes][3] = 255;
tess.numVertexes++;
tess.xyz[tess.numVertexes][0] = f->windowX - size;
tess.xyz[tess.numVertexes][1] = f->windowY + size;
tess.texCoords[tess.numVertexes][0][0] = 0;
tess.texCoords[tess.numVertexes][0][1] = 1;
tess.vertexColors[tess.numVertexes][0] = iColor[0];
tess.vertexColors[tess.numVertexes][1] = iColor[1];
tess.vertexColors[tess.numVertexes][2] = iColor[2];
tess.vertexColors[tess.numVertexes][3] = 255;
tess.numVertexes++;
tess.xyz[tess.numVertexes][0] = f->windowX + size;
tess.xyz[tess.numVertexes][1] = f->windowY + size;
tess.texCoords[tess.numVertexes][0][0] = 1;
tess.texCoords[tess.numVertexes][0][1] = 1;
tess.vertexColors[tess.numVertexes][0] = iColor[0];
tess.vertexColors[tess.numVertexes][1] = iColor[1];
tess.vertexColors[tess.numVertexes][2] = iColor[2];
tess.vertexColors[tess.numVertexes][3] = 255;
tess.numVertexes++;
tess.xyz[tess.numVertexes][0] = f->windowX + size;
tess.xyz[tess.numVertexes][1] = f->windowY - size;
tess.texCoords[tess.numVertexes][0][0] = 1;
tess.texCoords[tess.numVertexes][0][1] = 0;
tess.vertexColors[tess.numVertexes][0] = iColor[0];
tess.vertexColors[tess.numVertexes][1] = iColor[1];
tess.vertexColors[tess.numVertexes][2] = iColor[2];
tess.vertexColors[tess.numVertexes][3] = 255;
tess.numVertexes++;
tess.indexes[tess.numIndexes++] = 0;
tess.indexes[tess.numIndexes++] = 1;
tess.indexes[tess.numIndexes++] = 2;
tess.indexes[tess.numIndexes++] = 0;
tess.indexes[tess.numIndexes++] = 2;
tess.indexes[tess.numIndexes++] = 3;
RB_EndSurface();
}
示例15: RB_EndSurface
/*
==================
RB_TakeVideoFrameCmd
==================
*/
const void *RB_TakeVideoFrameCmd( const void *data )
{
const videoFrameCommand_t *cmd;
byte *cBuf;
size_t memcount, linelen;
int padwidth, avipadwidth, padlen, avipadlen;
GLint packAlign;
// finish any 2D drawing if needed
if(tess.numIndexes)
RB_EndSurface();
cmd = (const videoFrameCommand_t *)data;
qglGetIntegerv(GL_PACK_ALIGNMENT, &packAlign);
linelen = cmd->width * 3;
// Alignment stuff for glReadPixels
padwidth = PAD(linelen, packAlign);
padlen = padwidth - linelen;
// AVI line padding
avipadwidth = PAD(linelen, AVI_LINE_PADDING);
avipadlen = avipadwidth - linelen;
cBuf = PADP(cmd->captureBuffer, packAlign);
qglReadPixels(0, 0, cmd->width, cmd->height, GL_RGB,
GL_UNSIGNED_BYTE, cBuf);
memcount = padwidth * cmd->height;
// gamma correct
if(glConfig.deviceSupportsGamma)
R_GammaCorrect(cBuf, memcount);
if(cmd->motionJpeg)
{
memcount = RE_SaveJPGToBuffer(cmd->encodeBuffer, linelen * cmd->height,
r_aviMotionJpegQuality->integer,
cmd->width, cmd->height, cBuf, padlen);
ri.CL_WriteAVIVideoFrame(cmd->encodeBuffer, memcount);
}
else
{
byte *lineend, *memend;
byte *srcptr, *destptr;
srcptr = cBuf;
destptr = cmd->encodeBuffer;
memend = srcptr + memcount;
// swap R and B and remove line paddings
while(srcptr < memend)
{
lineend = srcptr + linelen;
while(srcptr < lineend)
{
*destptr++ = srcptr[2];
*destptr++ = srcptr[1];
*destptr++ = srcptr[0];
srcptr += 3;
}
Com_Memset(destptr, '\0', avipadlen);
destptr += avipadlen;
srcptr += padlen;
}
ri.CL_WriteAVIVideoFrame(cmd->encodeBuffer, avipadwidth * cmd->height);
}
return (const void *)(cmd + 1);
}