本文整理汇总了C++中qglDisable函数的典型用法代码示例。如果您正苦于以下问题:C++ qglDisable函数的具体用法?C++ qglDisable怎么用?C++ qglDisable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qglDisable函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: edge
//.........这里部分代码省略.........
=================
*/
void RB_ShadowTessEnd( void ) {
int i;
int numTris;
vec3_t lightDir;
// we can only do this if we have enough space in the vertex buffers
if ( tess.numVertexes >= SHADER_MAX_VERTEXES / 2 ) {
return;
}
if ( glConfig.stencilBits < 4 ) {
return;
}
VectorCopy( backEnd.currentEntity->lightDir, lightDir );
// project vertexes away from light direction
for ( i = 0 ; i < tess.numVertexes ; i++ ) {
VectorMA( tess.xyz[i], -512, lightDir, tess.xyz[i+tess.numVertexes] );
}
// decide which triangles face the light
Com_Memset( numEdgeDefs, 0, 4 * tess.numVertexes );
numTris = tess.numIndexes / 3;
for ( i = 0 ; i < numTris ; i++ ) {
int i1, i2, i3;
vec3_t d1, d2, normal;
float *v1, *v2, *v3;
float d;
i1 = tess.indexes[ i*3 + 0 ];
i2 = tess.indexes[ i*3 + 1 ];
i3 = tess.indexes[ i*3 + 2 ];
v1 = tess.xyz[ i1 ];
v2 = tess.xyz[ i2 ];
v3 = tess.xyz[ i3 ];
VectorSubtract( v2, v1, d1 );
VectorSubtract( v3, v1, d2 );
CrossProduct( d1, d2, normal );
d = DotProduct( normal, lightDir );
if ( d > 0 ) {
facing[ i ] = 1;
} else {
facing[ i ] = 0;
}
// create the edges
R_AddEdgeDef( i1, i2, facing[ i ] );
R_AddEdgeDef( i2, i3, facing[ i ] );
R_AddEdgeDef( i3, i1, facing[ i ] );
}
// draw the silhouette edges
GL_Bind( tr.whiteImage );
qglEnable( GL_CULL_FACE );
GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO );
qglColor3f( 0.2f, 0.2f, 0.2f );
// don't write to the color buffer
qglColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );
qglEnable( GL_STENCIL_TEST );
qglStencilFunc( GL_ALWAYS, 1, 255 );
// mirrors have the culling order reversed
if ( backEnd.viewParms.isMirror ) {
qglCullFace( GL_FRONT );
qglStencilOp( GL_KEEP, GL_KEEP, GL_INCR );
R_RenderShadowEdges();
qglCullFace( GL_BACK );
qglStencilOp( GL_KEEP, GL_KEEP, GL_DECR );
R_RenderShadowEdges();
} else {
qglCullFace( GL_BACK );
qglStencilOp( GL_KEEP, GL_KEEP, GL_INCR );
R_RenderShadowEdges();
qglCullFace( GL_FRONT );
qglStencilOp( GL_KEEP, GL_KEEP, GL_DECR );
R_RenderShadowEdges();
}
// reenable writing to the color buffer
qglColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
qglDisable( GL_CULL_FACE );
}
示例2: RB_ShadowFinish
/*
=================
RB_ShadowFinish
Darken everything that is is a shadow volume.
We have to delay this until everything has been shadowed,
because otherwise shadows from different body parts would
overlap and double darken.
=================
*/
void RB_ShadowFinish( void ) {
#if defined(VV_LIGHTING) && defined(_XBOX)
StencilShadower.FinishShadows();
#else
if ( r_shadows->integer != 2 ) {
return;
}
if ( glConfig.stencilBits < 4 ) {
return;
}
#ifdef _DEBUG_STENCIL_SHADOWS
return;
#endif
qglEnable( GL_STENCIL_TEST );
qglStencilFunc( GL_NOTEQUAL, 0, 255 );
qglStencilOp( GL_KEEP, GL_KEEP, GL_KEEP );
bool planeZeroBack = false;
if (qglIsEnabled(GL_CLIP_PLANE0))
{
planeZeroBack = true;
qglDisable (GL_CLIP_PLANE0);
}
GL_Cull(CT_TWO_SIDED);
//qglDisable (GL_CULL_FACE);
GL_Bind( tr.whiteImage );
qglPushMatrix();
qglLoadIdentity ();
// qglColor3f( 0.6f, 0.6f, 0.6f );
// GL_State( GLS_DEPTHMASK_TRUE | GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO );
// qglColor3f( 1, 0, 0 );
// GL_State( GLS_DEPTHMASK_TRUE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO );
qglColor4f( 0.0f, 0.0f, 0.0f, 0.5f );
//GL_State( GLS_DEPTHMASK_TRUE | GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA );
GL_State( GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA );
#ifdef HAVE_GLES
GLfloat vtx[] = {
-100, 100, -10,
100, 100, -10,
100, -100, -10,
-100, -100, -10
};
GLboolean text = qglIsEnabled(GL_TEXTURE_COORD_ARRAY);
GLboolean glcol = qglIsEnabled(GL_COLOR_ARRAY);
if (text)
qglDisableClientState( GL_TEXTURE_COORD_ARRAY );
if (glcol)
qglDisableClientState( GL_COLOR_ARRAY );
qglVertexPointer ( 3, GL_FLOAT, 0, vtx );
qglDrawArrays( GL_TRIANGLE_FAN, 0, 4 );
if (text)
qglEnableClientState( GL_TEXTURE_COORD_ARRAY );
if (glcol)
qglEnableClientState( GL_COLOR_ARRAY );
#else
qglBegin( GL_QUADS );
qglVertex3f( -100, 100, -10 );
qglVertex3f( 100, 100, -10 );
qglVertex3f( 100, -100, -10 );
qglVertex3f( -100, -100, -10 );
qglEnd ();
#endif
qglColor4f(1,1,1,1);
qglDisable( GL_STENCIL_TEST );
if (planeZeroBack)
{
qglEnable (GL_CLIP_PLANE0);
}
qglPopMatrix();
#endif // VV_LIGHTING && _XBOX
}
示例3: RB_EndSurface
//.........这里部分代码省略.........
{
vec4_t viewInfo;
float zmax = backEnd.viewParms.zFar;
float zmin = r_znear->value;
VectorSet4(viewInfo, zmax / zmin, zmax, 0.0, 0.0);
GLSL_SetUniformVec4(&tr.depthBlurShader[0], UNIFORM_VIEWINFO, viewInfo);
}
RB_InstantQuad2(quadVerts, texCoords); //, color, shaderProgram, invTexRes);
FBO_Bind(tr.screenSsaoFbo);
qglViewport(0, 0, tr.screenSsaoFbo->width, tr.screenSsaoFbo->height);
qglScissor(0, 0, tr.screenSsaoFbo->width, tr.screenSsaoFbo->height);
GLSL_BindProgram(&tr.depthBlurShader[1]);
GL_BindToTMU(tr.quarterImage[1], TB_COLORMAP);
GL_BindToTMU(tr.hdrDepthImage, TB_LIGHTMAP);
{
vec4_t viewInfo;
float zmax = backEnd.viewParms.zFar;
float zmin = r_znear->value;
VectorSet4(viewInfo, zmax / zmin, zmax, 0.0, 0.0);
GLSL_SetUniformVec4(&tr.depthBlurShader[1], UNIFORM_VIEWINFO, viewInfo);
}
RB_InstantQuad2(quadVerts, texCoords); //, color, shaderProgram, invTexRes);
}
// reset viewport and scissor
FBO_Bind(oldFbo);
SetViewportAndScissor();
}
if (glRefConfig.framebufferObject && (backEnd.viewParms.flags & VPF_DEPTHCLAMP) && glRefConfig.depthClamp)
{
qglDisable(GL_DEPTH_CLAMP);
}
if (!(backEnd.viewParms.flags & VPF_DEPTHSHADOW))
{
RB_RenderDrawSurfList( cmd->drawSurfs, cmd->numDrawSurfs );
if (r_drawSun->integer)
{
RB_DrawSun(0.1, tr.sunShader);
}
if (r_drawSunRays->integer)
{
FBO_t *oldFbo = glState.currentFBO;
FBO_Bind(tr.sunRaysFbo);
qglClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
qglClear( GL_COLOR_BUFFER_BIT );
if (glRefConfig.occlusionQuery)
{
tr.sunFlareQueryActive[tr.sunFlareQueryIndex] = qtrue;
qglBeginQueryARB(GL_SAMPLES_PASSED_ARB, tr.sunFlareQuery[tr.sunFlareQueryIndex]);
}
RB_DrawSun(0.3, tr.sunFlareShader);
if (glRefConfig.occlusionQuery)
{
qglEndQueryARB(GL_SAMPLES_PASSED_ARB);
}
FBO_Bind(oldFbo);
}
// darken down any stencil shadows
RB_ShadowFinish();
// add light flares on lights that aren't obscured
RB_RenderFlares();
}
if (glRefConfig.framebufferObject && backEnd.viewParms.targetFbo == tr.renderCubeFbo)
{
FBO_Bind(NULL);
GL_SelectTexture(TB_CUBEMAP);
GL_BindToTMU(tr.cubemaps[backEnd.viewParms.targetFboCubemapIndex], TB_CUBEMAP);
qglGenerateMipmapEXT(GL_TEXTURE_CUBE_MAP);
GL_SelectTexture(0);
}
return (const void *)(cmd + 1);
}
示例4: RB_ColorCorrect
void RB_ColorCorrect( void ) {
GLint loc;
GLenum target;
int width, height;
int shift;
float mul;
if ( !r_enablePostProcess->integer || !r_enableColorCorrect->integer || !glsl ) {
return;
}
GL_SelectTexture(0);
qglDisable(GL_TEXTURE_2D);
qglEnable(GL_TEXTURE_RECTANGLE_ARB);
target = GL_TEXTURE_RECTANGLE_ARB;
width = glConfig.vidWidth;
height = glConfig.vidHeight;
qglBindTexture(target, tr.backBufferTexture);
qglCopyTexSubImage2D(target, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight);
qglMatrixMode(GL_PROJECTION);
qglLoadIdentity();
qglMatrixMode(GL_MODELVIEW);
qglLoadIdentity();
RB_SetGL2D();
GL_State( GLS_DEPTHTEST_DISABLE );
qglUseProgramObjectARB(tr.colorCorrectSp);
loc = qglGetUniformLocationARB(tr.colorCorrectSp, "p_gammaRecip");
if (loc < 0) {
Com_Error(ERR_DROP, "%s() couldn't get p_gammaRecip", __FUNCTION__);
}
qglUniform1fARB(loc, (GLfloat)(1.0 / r_gamma->value));
//mul = r_overBrightBitsValue->value;
mul = r_overBrightBits->value;
if (mul < 0.0) {
mul = 0.0;
}
shift = tr.overbrightBits;
loc = qglGetUniformLocationARB(tr.colorCorrectSp, "p_overbright");
if (loc < 0) {
Com_Error(ERR_DROP, "%s() couldn't get p_overbright", __FUNCTION__);
}
qglUniform1fARB(loc, (GLfloat)((float)(1 << shift) * mul));
loc = qglGetUniformLocationARB(tr.colorCorrectSp, "p_contrast");
if (loc < 0) {
Com_Error(ERR_DROP, "%s() couldn't get p_contrast", __FUNCTION__);
}
qglUniform1fARB(loc, (GLfloat)r_contrast->value);
loc = qglGetUniformLocationARB(tr.colorCorrectSp, "backBufferTex");
if (loc < 0) {
Com_Error(ERR_DROP, "%s() couldn't get backBufferTex", __FUNCTION__);
}
qglUniform1iARB(loc, 0);
qglBegin(GL_QUADS);
qglTexCoord2i(0, 0);
qglVertex2i(0, height);
qglTexCoord2i(width, 0);
qglVertex2i(width, height);
qglTexCoord2i(width, height);
qglVertex2i(width, 0);
qglTexCoord2i(0, height);
qglVertex2i(0, 0);
qglEnd();
qglUseProgramObjectARB(0);
qglDisable(GL_TEXTURE_RECTANGLE_ARB);
qglEnable(GL_TEXTURE_2D);
}
示例5: RE_BeginFrame
/*
====================
RE_BeginFrame
If running in stereo, RE_BeginFrame will be called twice
for each RE_EndFrame
====================
*/
void RE_BeginFrame(stereoFrame_t stereoFrame)
{
drawBufferCommand_t *cmd = NULL;
colorMaskCommand_t *colcmd = NULL;
if (!tr.registered)
{
return;
}
glState.finishCalled = qfalse;
tr.frameCount++;
tr.frameSceneNum = 0;
//
// do overdraw measurement
//
if (r_measureOverdraw->integer)
{
if (glConfig.stencilBits < 4)
{
ri.Printf(PRINT_ALL, "Warning: not enough stencil bits to measure overdraw: %d\n", glConfig.stencilBits);
ri.Cvar_Set("r_measureOverdraw", "0");
r_measureOverdraw->modified = qfalse;
}
else if (r_shadows->integer == 2)
{
ri.Printf(PRINT_ALL, "Warning: stencil shadows and overdraw measurement are mutually exclusive\n");
ri.Cvar_Set("r_measureOverdraw", "0");
r_measureOverdraw->modified = qfalse;
}
else
{
R_IssuePendingRenderCommands();
qglEnable(GL_STENCIL_TEST);
qglStencilMask(~0U);
qglClearStencil(0U);
qglStencilFunc(GL_ALWAYS, 0U, ~0U);
qglStencilOp(GL_KEEP, GL_INCR, GL_INCR);
}
r_measureOverdraw->modified = qfalse;
}
else
{
// this is only reached if it was on and is now off
if (r_measureOverdraw->modified)
{
R_IssuePendingRenderCommands();
qglDisable(GL_STENCIL_TEST);
}
r_measureOverdraw->modified = qfalse;
}
//
// texturemode stuff
//
if (r_textureMode->modified)
{
R_IssuePendingRenderCommands();
GL_TextureMode(r_textureMode->string);
r_textureMode->modified = qfalse;
}
//
// NVidia stuff
//
// fog control
if (glConfig.NVFogAvailable && r_nv_fogdist_mode->modified)
{
r_nv_fogdist_mode->modified = qfalse;
if (!Q_stricmp(r_nv_fogdist_mode->string, "GL_EYE_PLANE_ABSOLUTE_NV"))
{
glConfig.NVFogMode = (int)GL_EYE_PLANE_ABSOLUTE_NV;
}
else if (!Q_stricmp(r_nv_fogdist_mode->string, "GL_EYE_PLANE"))
{
glConfig.NVFogMode = (int)GL_EYE_PLANE;
}
else if (!Q_stricmp(r_nv_fogdist_mode->string, "GL_EYE_RADIAL_NV"))
{
glConfig.NVFogMode = (int)GL_EYE_RADIAL_NV;
}
else
{
// in case this was really 'else', store a valid value for next time
glConfig.NVFogMode = (int)GL_EYE_RADIAL_NV;
ri.Cvar_Set("r_nv_fogdist_mode", "GL_EYE_RADIAL_NV");
}
}
//
//.........这里部分代码省略.........
示例6: GL_DrawAliasShadow
void GL_DrawAliasShadow (entity_t *e, dmdl_t *paliashdr, int posenum)
{
dtrivertx_t *verts;
int *order;
vec3_t point;
float height, lheight;
int count;
daliasframe_t *frame;
lheight = currententity->origin[2] - lightspot[2];
frame = (daliasframe_t *)((byte *)paliashdr + paliashdr->ofs_frames
+ currententity->frame * paliashdr->framesize);
verts = frame->verts;
// height = 0;
order = (int *)((byte *)paliashdr + paliashdr->ofs_glcmds);
height = -lheight + 0.1f; // was 1.0f, lowered shadows to ground more - MrG
// Knightmare- don't draw shadow above entity
if ((currententity->origin[2]+height) > currententity->origin[2])
return;
// Knightmare- don't draw shadows above view origin
if (r_newrefdef.vieworg[2] < (currententity->origin[2] + height))
return;
qglPushMatrix ();
R_RotateForEntity (e, false);
qglDisable (GL_TEXTURE_2D);
qglEnable (GL_BLEND);
qglColor4f (0, 0, 0, gl_shadowalpha->value); // was 0.5
// Knightmare- Stencil shadows by MrG
if (gl_config.have_stencil)
{
qglEnable(GL_STENCIL_TEST);
qglStencilFunc(GL_EQUAL, 1, 2);
qglStencilOp(GL_KEEP,GL_KEEP,GL_INCR);
}
// End Stencil shadows - MrG
while (1)
{
// get the vertex count and primitive type
count = *order++;
if (!count)
break; // done
if (count < 0)
{
count = -count;
qglBegin (GL_TRIANGLE_FAN);
}
else
qglBegin (GL_TRIANGLE_STRIP);
do
{
// normals and vertexes come from the frame list
/*
point[0] = verts[order[2]].v[0] * frame->scale[0] + frame->translate[0];
point[1] = verts[order[2]].v[1] * frame->scale[1] + frame->translate[1];
point[2] = verts[order[2]].v[2] * frame->scale[2] + frame->translate[2];
*/
memcpy( point, s_lerped[order[2]], sizeof( point ) );
point[0] -= shadevector[0]*(point[2]+lheight);
point[1] -= shadevector[1]*(point[2]+lheight);
point[2] = height;
// height -= 0.001;
qglVertex3fv (point);
order += 3;
// verts++;
} while (--count);
qglEnd ();
}
// Knightmare- disable Stencil shadows
if (gl_config.have_stencil)
qglDisable(GL_STENCIL_TEST);
qglColor4f (1,1,1,1);
qglEnable (GL_TEXTURE_2D);
qglDisable (GL_BLEND);
qglPopMatrix ();
}
示例7: GL_DrawAliasFrameLerp
/*
=============
GL_DrawAliasFrameLerp
interpolates between two frames and origins
FIXME: batch lerp all vertexes
=============
*/
void GL_DrawAliasFrameLerp (dmdl_t *paliashdr, float backlerp)
{
float l;
daliasframe_t *frame, *oldframe;
dtrivertx_t *v, *ov, *verts;
int *order;
int count;
float frontlerp;
float alpha;
vec3_t move, delta, vectors[3];
vec3_t frontv, backv;
int i;
int index_xyz;
float *lerp;
frame = (daliasframe_t *)((byte *)paliashdr + paliashdr->ofs_frames
+ currententity->frame * paliashdr->framesize);
verts = v = frame->verts;
oldframe = (daliasframe_t *)((byte *)paliashdr + paliashdr->ofs_frames
+ currententity->oldframe * paliashdr->framesize);
ov = oldframe->verts;
order = (int *)((byte *)paliashdr + paliashdr->ofs_glcmds);
// glTranslatef (frame->translate[0], frame->translate[1], frame->translate[2]);
// glScalef (frame->scale[0], frame->scale[1], frame->scale[2]);
if (currententity->flags & RF_TRANSLUCENT)
alpha = currententity->alpha;
else
alpha = 1.0;
// PMM - added double shell
if ( currententity->flags & ( RF_SHELL_RED | RF_SHELL_GREEN | RF_SHELL_BLUE | RF_SHELL_DOUBLE | RF_SHELL_HALF_DAM) )
qglDisable( GL_TEXTURE_2D );
frontlerp = 1.0 - backlerp;
// move should be the delta back to the previous frame * backlerp
VectorSubtract (currententity->oldorigin, currententity->origin, delta);
AngleVectors (currententity->angles, vectors[0], vectors[1], vectors[2]);
move[0] = DotProduct (delta, vectors[0]); // forward
move[1] = -DotProduct (delta, vectors[1]); // left
move[2] = DotProduct (delta, vectors[2]); // up
VectorAdd (move, oldframe->translate, move);
for (i=0 ; i<3 ; i++)
{
move[i] = backlerp*move[i] + frontlerp*frame->translate[i];
}
for (i=0 ; i<3 ; i++)
{
frontv[i] = frontlerp*frame->scale[i];
backv[i] = backlerp*oldframe->scale[i];
}
lerp = s_lerped[0];
GL_LerpVerts( paliashdr->num_xyz, v, ov, verts, lerp, move, frontv, backv );
if ( gl_vertex_arrays->value )
{
float colorArray[MAX_VERTS*4];
qglEnableClientState( GL_VERTEX_ARRAY );
qglVertexPointer( 3, GL_FLOAT, 16, s_lerped ); // padded for SIMD
// if ( currententity->flags & ( RF_SHELL_RED | RF_SHELL_GREEN | RF_SHELL_BLUE ) )
// PMM - added double damage shell
if ( currententity->flags & ( RF_SHELL_RED | RF_SHELL_GREEN | RF_SHELL_BLUE | RF_SHELL_DOUBLE | RF_SHELL_HALF_DAM) )
{
qglColor4f( shadelight[0], shadelight[1], shadelight[2], alpha );
}
else
{
qglEnableClientState( GL_COLOR_ARRAY );
qglColorPointer( 3, GL_FLOAT, 0, colorArray );
//
// pre light everything
//
for ( i = 0; i < paliashdr->num_xyz; i++ )
{
float l = shadedots[verts[i].lightnormalindex];
colorArray[i*3+0] = l * shadelight[0];
colorArray[i*3+1] = l * shadelight[1];
colorArray[i*3+2] = l * shadelight[2];
//.........这里部分代码省略.........
示例8: RB_StageIteratorLightmappedMultitexture
void RB_StageIteratorLightmappedMultitexture( void ) {
shaderCommands_t *input;
input = &tess;
//
// log this call
//
if ( r_logFile->integer ) {
// don't just call LogComment, or we will get
// a call to va() every frame!
GLimp_LogComment( va("--- RB_StageIteratorLightmappedMultitexture( %s ) ---\n", tess.shader->name) );
}
//
// set face culling appropriately
//
GL_Cull( input->shader->cullType );
//
// set color, pointers, and lock
//
GL_State( GLS_DEFAULT );
qglVertexPointer( 3, GL_FLOAT, 16, input->xyz );
#ifdef REPLACE_MODE
qglDisableClientState( GL_COLOR_ARRAY );
qglColor3f( 1, 1, 1 );
qglShadeModel( GL_FLAT );
#else
qglEnableClientState( GL_COLOR_ARRAY );
qglColorPointer( 4, GL_UNSIGNED_BYTE, 0, tess.constantColor255 );
#endif
//
// select base stage
//
GL_SelectTexture( 0 );
qglEnableClientState( GL_TEXTURE_COORD_ARRAY );
R_BindAnimatedImage( &tess.xstages[0]->bundle[0] );
qglTexCoordPointer( 2, GL_FLOAT, 16, tess.texCoords[0][0] );
//
// configure second stage
//
GL_SelectTexture( 1 );
qglEnable( GL_TEXTURE_2D );
if ( r_lightmap->integer ) {
GL_TexEnv( GL_REPLACE );
} else {
GL_TexEnv( GL_MODULATE );
}
R_BindAnimatedImage( &tess.xstages[0]->bundle[1] );
qglEnableClientState( GL_TEXTURE_COORD_ARRAY );
qglTexCoordPointer( 2, GL_FLOAT, 16, tess.texCoords[0][1] );
//
// lock arrays
//
if ( qglLockArraysEXT ) {
qglLockArraysEXT(0, input->numVertexes);
GLimp_LogComment( "glLockArraysEXT\n" );
}
R_DrawElements( input->numIndexes, input->indexes );
//
// disable texturing on TEXTURE1, then select TEXTURE0
//
qglDisable( GL_TEXTURE_2D );
qglDisableClientState( GL_TEXTURE_COORD_ARRAY );
GL_SelectTexture( 0 );
#ifdef REPLACE_MODE
GL_TexEnv( GL_MODULATE );
qglShadeModel( GL_SMOOTH );
#endif
//
// now do any dynamic lighting needed
//
if ( tess.dlightBits && tess.shader->sort <= SS_OPAQUE ) {
ProjectDlightTexture();
}
//
// now do fog
//
if ( tess.fogNum && tess.shader->fogPass ) {
RB_FogPass();
}
//
// unlock arrays
//
if ( qglUnlockArraysEXT ) {
qglUnlockArraysEXT();
GLimp_LogComment( "glUnlockArraysEXT\n" );
}
//.........这里部分代码省略.........
示例9: R_DrawCel
//R_DRAWCEL
static void R_DrawCel( int numIndexes, const glIndex_t *indexes ) {
int primitives;
if(
//. ignore the 2d projection. do i smell the HUD?
(backEnd.projection2D == qtrue) ||
//. ignore general entitites that are sprites. SEE NOTE #3.
(backEnd.currentEntity->e.reType == RT_SPRITE) ||
//. ignore these liquids. why? ever see liquid with tris on the surface? exactly. SEE NOTE #4.
(tess.shader->contentFlags & (CONTENTS_WATER | CONTENTS_LAVA | CONTENTS_SLIME | CONTENTS_FOG)) ||
//. ignore things that are two sided, meaning mostly things that have transparency. SEE NOTE #1.
(tess.shader->cullType == CT_TWO_SIDED)
) {
return;
}
primitives = r_primitives->integer;
// default is to use triangles if compiled vertex arrays are present
if ( primitives == 0 ) {
if ( qglLockArraysEXT ) {
primitives = 2;
} else {
primitives = 1;
}
}
//. correction for mirrors. SEE NOTE #2.
if(backEnd.viewParms.isMirror == qtrue) { qglCullFace (GL_FRONT); }
else { qglCullFace (GL_BACK); }
qglEnable (GL_BLEND);
qglBlendFunc (GL_SRC_ALPHA ,GL_ONE_MINUS_SRC_ALPHA);
qglColor3f (0.0f,0.0f,0.0f);
qglLineWidth( (float) r_celoutline->integer );
if(primitives == 2) {
qglDrawElements( GL_TRIANGLES, numIndexes, GL_INDEX_TYPE, indexes );
} else if(primitives == 1) {
R_DrawStripElements( numIndexes, indexes, qglArrayElement );
} else if(primitives == 3) {
R_DrawStripElements( numIndexes, indexes, R_ArrayElementDiscrete );
}
//. correction for mirrors. SEE NOTE #2.
if(backEnd.viewParms.isMirror == qtrue) { qglCullFace (GL_BACK); }
else { qglCullFace (GL_FRONT); }
qglDisable (GL_BLEND);
return;
/* Notes
1. this is going to be a pain in the arse. it fixes things like light `beams` from being cel'd but it
also will ignore any other shader set with no culling. this usually is everything that is translucent.
but this is a good hack to clean up the screen untill something more selective comes along. or who knows
group desision might actually be that this is liked. if so i take back calling it a `hack`, lol.
= bob.
2. mirrors display correctly because the normals of the displayed are inverted of normal space. so to
continue to have them display correctly, we must invert them inversely from a normal inversion.
= bob.
3. this turns off a lot of space hogging sprite cel outlines. picture if you will five people in a small
room all shooting rockets. each smoke puff gets a big black square around it, each explosion gets a big
black square around it, and now nobody can see eachother because everyones screen is solid black.
= bob.
4. ignoring liquids means you will not get black tris lines all over the top of your liquid. i put this in
after seeing the lava on q3dm7 and water on q3ctf2 that had black lines all over the top, making the
liquids look solid instead of... liquid.
= bob.
*/
}
示例10: RB_StageIteratorGeneric
/*
** RB_StageIteratorGeneric
*/
void RB_StageIteratorGeneric( void )
{
shaderCommands_t *input;
input = &tess;
RB_DeformTessGeometry();
//
// log this call
//
if ( r_logFile->integer )
{
// don't just call LogComment, or we will get
// a call to va() every frame!
GLimp_LogComment( va("--- RB_StageIteratorGeneric( %s ) ---\n", tess.shader->name) );
}
//
// set face culling appropriately
//
GL_Cull( input->shader->cullType );
// set polygon offset if necessary
if ( input->shader->polygonOffset )
{
qglEnable( GL_POLYGON_OFFSET_FILL );
qglPolygonOffset( r_offsetFactor->value, r_offsetUnits->value );
}
//. show me cel outlines.
//. there has to be a better place to put this.
if(r_celoutline->integer > 0) {
DrawCel(&tess);
}
//
// if there is only a single pass then we can enable color
// and texture arrays before we compile, otherwise we need
// to avoid compiling those arrays since they will change
// during multipass rendering
//
if ( tess.numPasses > 1 || input->shader->multitextureEnv )
{
setArraysOnce = qfalse;
qglDisableClientState (GL_COLOR_ARRAY);
qglDisableClientState (GL_TEXTURE_COORD_ARRAY);
}
else
{
setArraysOnce = qtrue;
qglEnableClientState( GL_COLOR_ARRAY);
qglColorPointer( 4, GL_UNSIGNED_BYTE, 0, tess.svars.colors );
qglEnableClientState( GL_TEXTURE_COORD_ARRAY);
qglTexCoordPointer( 2, GL_FLOAT, 0, tess.svars.texcoords[0] );
}
//
// lock XYZ
//
qglVertexPointer (3, GL_FLOAT, 16, input->xyz); // padded for SIMD
if (qglLockArraysEXT)
{
qglLockArraysEXT(0, input->numVertexes);
GLimp_LogComment( "glLockArraysEXT\n" );
}
//
// enable color and texcoord arrays after the lock if necessary
//
if ( !setArraysOnce )
{
qglEnableClientState( GL_TEXTURE_COORD_ARRAY );
qglEnableClientState( GL_COLOR_ARRAY );
}
//
// call shader function
//
RB_IterateStagesGeneric( input );
//
// now do any dynamic lighting needed
//
if ( tess.dlightBits && tess.shader->sort <= SS_OPAQUE
&& !(tess.shader->surfaceFlags & (SURF_NODLIGHT | SURF_SKY) ) ) {
ProjectDlightTexture();
}
//
// now do fog
//
if ( tess.fogNum && tess.shader->fogPass ) {
RB_FogPass();
}
//.........这里部分代码省略.........
示例11: RE_BeginFrame
/*
====================
RE_BeginFrame
If running in stereo, RE_BeginFrame will be called twice
for each RE_EndFrame
====================
*/
void RE_BeginFrame( stereoFrame_t stereoFrame ) {
drawBufferCommand_t *cmd = NULL;
colorMaskCommand_t *colcmd = NULL;
if ( !tr.registered ) {
return;
}
glState.finishCalled = qfalse;
tr.frameCount++;
tr.frameSceneNum = 0;
//
// do overdraw measurement
//
if ( r_measureOverdraw->integer )
{
if ( glConfig.stencilBits < 4 )
{
ri.Printf( PRINT_ALL, "Warning: not enough stencil bits to measure overdraw: %d\n", glConfig.stencilBits );
ri.Cvar_Set( "r_measureOverdraw", "0" );
r_measureOverdraw->modified = qfalse;
}
else if ( r_shadows->integer == 2 )
{
ri.Printf( PRINT_ALL, "Warning: stencil shadows and overdraw measurement are mutually exclusive\n" );
ri.Cvar_Set( "r_measureOverdraw", "0" );
r_measureOverdraw->modified = qfalse;
}
else
{
R_SyncRenderThread();
qglEnable( GL_STENCIL_TEST );
qglStencilMask( ~0U );
qglClearStencil( 0U );
qglStencilFunc( GL_ALWAYS, 0U, ~0U );
qglStencilOp( GL_KEEP, GL_INCR, GL_INCR );
}
r_measureOverdraw->modified = qfalse;
}
else
{
// this is only reached if it was on and is now off
if ( r_measureOverdraw->modified ) {
R_SyncRenderThread();
qglDisable( GL_STENCIL_TEST );
}
r_measureOverdraw->modified = qfalse;
}
//
// texturemode stuff
//
if ( r_textureMode->modified ) {
R_SyncRenderThread();
GL_TextureMode( r_textureMode->string );
r_textureMode->modified = qfalse;
}
//
// gamma stuff
//
if ( r_gamma->modified ) {
r_gamma->modified = qfalse;
R_SyncRenderThread();
R_SetColorMappings();
}
// check for errors
if ( !r_ignoreGLErrors->integer )
{
int err;
R_SyncRenderThread();
if ((err = qglGetError()) != GL_NO_ERROR)
ri.Error(ERR_FATAL, "RE_BeginFrame() - glGetError() failed (0x%x)!", err);
}
if (glConfig.stereoEnabled) {
if( !(cmd = R_GetCommandBuffer(sizeof(*cmd))) )
return;
cmd->commandId = RC_DRAW_BUFFER;
if ( stereoFrame == STEREO_LEFT ) {
cmd->buffer = (int)GL_BACK_LEFT;
} else if ( stereoFrame == STEREO_RIGHT ) {
cmd->buffer = (int)GL_BACK_RIGHT;
} else {
ri.Error( ERR_FATAL, "RE_BeginFrame: Stereo is enabled, but stereoFrame was %i", stereoFrame );
}
//.........这里部分代码省略.........
示例12: Z_Draw
/*
==============
Z_Draw
==============
*/
void Z_Draw (void)
{
brush_t *brush;
float w, h;
double start, end;
qtexture_t *q;
float top, bottom;
vec3_t org_top, org_bottom, dir_up, dir_down;
int xCam = z.width/3;
if (!active_brushes.next)
return; // not valid yet
if (z.timing)
start = Sys_DoubleTime ();
//
// clear
//
qglViewport(0, 0, z.width, z.height);
qglClearColor (
g_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK][0],
g_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK][1],
g_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK][2],
0);
/* GL Bug */
/* When not using hw acceleration, gl will fault if we clear the depth
buffer bit on the first pass. The hack fix is to set the GL_DEPTH_BUFFER_BIT
only after Z_Draw() has been called once. Yeah, right. */
qglClear(glbitClear);
glbitClear |= GL_DEPTH_BUFFER_BIT;
qglMatrixMode(GL_PROJECTION);
qglLoadIdentity ();
w = z.width/2 / z.scale;
h = z.height/2 / z.scale;
qglOrtho (-w, w, z.origin[2]-h, z.origin[2]+h, -8, 8);
qglDisable(GL_TEXTURE_2D);
qglDisable(GL_TEXTURE_1D);
qglDisable(GL_DEPTH_TEST);
qglDisable(GL_BLEND);
//
// now draw the grid
//
Z_DrawGrid ();
//
// draw stuff
//
qglDisable(GL_CULL_FACE);
qglShadeModel (GL_FLAT);
qglPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
qglDisable(GL_TEXTURE_2D);
qglDisable(GL_BLEND);
qglDisable(GL_DEPTH_TEST);
// draw filled interiors and edges
dir_up[0] = 0 ; dir_up[1] = 0; dir_up[2] = 1;
dir_down[0] = 0 ; dir_down[1] = 0; dir_down[2] = -1;
VectorCopy (z.origin, org_top);
org_top[2] = 4096;
VectorCopy (z.origin, org_bottom);
org_bottom[2] = -4096;
for (brush = active_brushes.next ; brush != &active_brushes ; brush=brush->next)
{
if (brush->mins[0] >= z.origin[0]
|| brush->maxs[0] <= z.origin[0]
|| brush->mins[1] >= z.origin[1]
|| brush->maxs[1] <= z.origin[1])
continue;
if (!Brush_Ray (org_top, dir_down, brush, &top))
continue;
top = org_top[2] - top;
if (!Brush_Ray (org_bottom, dir_up, brush, &bottom))
continue;
bottom = org_bottom[2] + bottom;
q = Texture_ForName (brush->brush_faces->texdef.name);
qglColor3f (q->color[0], q->color[1], q->color[2]);
qglBegin (GL_QUADS);
qglVertex2f (-xCam, bottom);
qglVertex2f (xCam, bottom);
//.........这里部分代码省略.........
示例13: QueueDraw
void QueueDraw(){
guint32 i, k;
face_t *face;
winding_t *w;
int j, nDrawMode = g_pParentWnd->GetCamera().draw_mode;
if ( notex_faces->len ) {
qglDisable( GL_TEXTURE_2D );
for ( i = 0; i < notex_faces->len; i++ )
{
face = (face_t*)notex_faces->pdata[i];
w = face->face_winding;
qglBegin( GL_POLYGON );
/*
if (b->patchBrush)
//++timo FIXME: find a use case for this??
qglColor4f (face->d_color[0], face->d_color[1], face->d_color[2], 0.13);
else
*/
qglColor4f( face->d_color[0], face->d_color[1], face->d_color[2], face->pShader->getTrans() );
if ( g_PrefsDlg.m_bGLLighting ) {
qglNormal3fv( face->plane.normal );
}
for ( j = 0; j < w->numpoints; j++ )
{
if ( nDrawMode == cd_texture || nDrawMode == cd_light ) {
qglTexCoord2fv( &w->points[j][3] );
}
qglVertex3fv( w->points[j] );
}
qglEnd();
}
}
if ( !len ) {
return;
}
if ( nDrawMode == cd_texture || nDrawMode == cd_light ) {
qglEnable( GL_TEXTURE_2D );
}
for ( k = 0; k < len; k++ )
{
qglBindTexture( GL_TEXTURE_2D, sort[k].texture->texture_number );
for ( i = 0; i < sort[k].faces->len; i++ )
{
face = (face_t*)sort[k].faces->pdata[i];
w = face->face_winding;
qglBegin( GL_POLYGON );
/*
if (b->patchBrush)
//++timo FIXME: find a use case for this??
qglColor4f (face->d_color[0], face->d_color[1], face->d_color[2], 0.13);
else
*/
qglColor4f( face->d_color[0], face->d_color[1], face->d_color[2], face->pShader->getTrans() );
if ( g_PrefsDlg.m_bGLLighting ) {
qglNormal3fv( face->plane.normal );
}
for ( j = 0; j < w->numpoints; j++ )
{
if ( nDrawMode == cd_texture || nDrawMode == cd_light ) {
qglTexCoord2fv( &w->points[j][3] );
}
qglVertex3fv( w->points[j] );
}
qglEnd();
}
}
qglBindTexture( GL_TEXTURE_2D, 0 );
}
示例14: FBO_BlitFromTexture
void FBO_BlitFromTexture(struct image_s *src, vec4i_t inSrcBox, vec2_t inSrcTexScale, FBO_t *dst, vec4i_t inDstBox, struct shaderProgram_s *shaderProgram, vec4_t inColor, int blend)
{
vec4i_t dstBox, srcBox;
vec2_t srcTexScale;
vec4_t color;
vec4_t quadVerts[4];
vec2_t texCoords[4];
vec2_t invTexRes;
FBO_t *oldFbo = glState.currentFBO;
matrix_t projection;
int width, height;
if (!src)
{
return;
}
if (inSrcBox)
{
VectorSet4(srcBox, inSrcBox[0], inSrcBox[1], inSrcBox[0] + inSrcBox[2], inSrcBox[1] + inSrcBox[3]);
}
else
{
VectorSet4(srcBox, 0, 0, src->width, src->height);
}
// framebuffers are 0 bottom, Y up.
if (inDstBox)
{
if (dst)
{
dstBox[0] = inDstBox[0];
dstBox[1] = dst->height - inDstBox[1] - inDstBox[3];
dstBox[2] = inDstBox[0] + inDstBox[2];
dstBox[3] = dst->height - inDstBox[1];
}
else
{
dstBox[0] = inDstBox[0];
dstBox[1] = glConfig.vidHeight - inDstBox[1] - inDstBox[3];
dstBox[2] = inDstBox[0] + inDstBox[2];
dstBox[3] = glConfig.vidHeight - inDstBox[1];
}
}
else if (dst)
{
VectorSet4(dstBox, 0, dst->height, dst->width, 0);
}
else
{
VectorSet4(dstBox, 0, glConfig.vidHeight, glConfig.vidWidth, 0);
}
if (inSrcTexScale)
{
VectorCopy2(inSrcTexScale, srcTexScale);
}
else
{
srcTexScale[0] = srcTexScale[1] = 1.0f;
}
if (inColor)
{
VectorCopy4(inColor, color);
}
else
{
color[0] = color[1] = color[2] = color[3] = 1.0f;
}
if (!shaderProgram)
{
shaderProgram = &tr.textureColorShader;
}
FBO_Bind(dst);
if (glState.currentFBO)
{
width = glState.currentFBO->width;
height = glState.currentFBO->height;
}
else
{
width = glConfig.vidWidth;
height = glConfig.vidHeight;
}
qglViewport(0, 0, width, height);
qglScissor(0, 0, width, height);
Matrix16Ortho(0, width, height, 0, 0, 1, projection);
qglDisable(GL_CULL_FACE);
GL_BindToTMU(src, TB_COLORMAP);
VectorSet4(quadVerts[0], dstBox[0], dstBox[1], 0, 1);
VectorSet4(quadVerts[1], dstBox[2], dstBox[1], 0, 1);
//.........这里部分代码省略.........
示例15: GL_Setup2D
/*
==================
GL_Setup2D
TODO: time is messed up
==================
*/
void GL_Setup2D (int time){
mat4_t projectionMatrix = {2.0f / backEnd.cropWidth, 0.0f, 0.0f, 0.0f, 0.0f, -2.0f / backEnd.cropHeight, 0.0f, 0.0f, 0.0f, 0.0f, -2.0f, 0.0f, -1.0f, 1.0f, -1.0f, 1.0f};
QGL_LogPrintf("---------- RB_Setup2D ----------\n");
backEnd.projection2D = true;
backEnd.time = time;
backEnd.floatTime = MS2SEC(Sys_Milliseconds());
backEnd.viewport.x = 0;
backEnd.viewport.y = 0;
backEnd.viewport.width = backEnd.cropWidth;
backEnd.viewport.height = backEnd.cropHeight;
backEnd.scissor.x = 0;
backEnd.scissor.y = 0;
backEnd.scissor.width = backEnd.cropWidth;
backEnd.scissor.height = backEnd.cropHeight;
backEnd.coordScale[0] = 1.0f / backEnd.viewport.width;
backEnd.coordScale[1] = 1.0f / backEnd.viewport.height;
backEnd.coordBias[0] = -backEnd.viewport.x * backEnd.coordScale[0];
backEnd.coordBias[1] = -backEnd.viewport.y * backEnd.coordScale[1];
backEnd.depthFilling = false;
backEnd.debugRendering = false;
backEnd.currentColorCaptured = SORT_BAD;
backEnd.currentDepthCaptured = false;
// Set up the viewport
GL_Viewport(backEnd.viewport);
// Set up the scissor
GL_Scissor(backEnd.viewport);
// Set up the depth bounds
if (glConfig.depthBoundsTestAvailable)
GL_DepthBounds(0.0f, 1.0f);
// Set the projection matrix
GL_LoadMatrix(GL_PROJECTION, projectionMatrix);
// Set the modelview matrix
GL_LoadIdentity(GL_MODELVIEW);
// Set the GL state
GL_PolygonMode(GL_FILL);
GL_Disable(GL_CULL_FACE);
GL_Disable(GL_POLYGON_OFFSET_FILL);
GL_Disable(GL_BLEND);
GL_Disable(GL_ALPHA_TEST);
GL_Disable(GL_DEPTH_TEST);
GL_Disable(GL_STENCIL_TEST);
GL_DepthRange(0.0f, 1.0f);
GL_ColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
GL_DepthMask(GL_FALSE);
GL_StencilMask(255);
// Disable the clip plane
qglDisable(GL_CLIP_PLANE0);
// Disable multisampling if available
if (glConfig.multiSamples > 1)
qglDisable(GL_MULTISAMPLE);
// Check for errors
if (!r_ignoreGLErrors->integerValue)
GL_CheckForErrors();
QGL_LogPrintf("--------------------\n");
}