本文整理汇总了C++中qglStencilFunc函数的典型用法代码示例。如果您正苦于以下问题:C++ qglStencilFunc函数的具体用法?C++ qglStencilFunc怎么用?C++ qglStencilFunc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qglStencilFunc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RB_StencilShadowPass
/*
=====================
RB_StencilShadowPass
Stencil test should already be enabled, and the stencil buffer should have
been set to 128 on any surfaces that might receive shadows
=====================
*/
void RB_StencilShadowPass(const drawSurf_t *drawSurfs)
{
if (!r_shadows.GetBool()) {
return;
}
if (!drawSurfs) {
return;
}
RB_LogComment("---------- RB_StencilShadowPass ----------\n");
globalImages->BindNull();
qglDisableClientState(GL_TEXTURE_COORD_ARRAY);
// for visualizing the shadows
if (r_showShadows.GetInteger()) {
if (r_showShadows.GetInteger() == 2) {
// draw filled in
GL_State(GLS_DEPTHMASK | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_LESS);
} else {
// draw as lines, filling the depth buffer
GL_State(GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO | GLS_POLYMODE_LINE | GLS_DEPTHFUNC_ALWAYS);
}
} else {
// don't write to the color buffer, just the stencil buffer
GL_State(GLS_DEPTHMASK | GLS_COLORMASK | GLS_ALPHAMASK | GLS_DEPTHFUNC_LESS);
}
if (r_shadowPolygonFactor.GetFloat() || r_shadowPolygonOffset.GetFloat()) {
qglPolygonOffset(r_shadowPolygonFactor.GetFloat(), -r_shadowPolygonOffset.GetFloat());
qglEnable(GL_POLYGON_OFFSET_FILL);
}
qglStencilFunc(GL_ALWAYS, 1, 255);
if (glConfig.depthBoundsTestAvailable && r_useDepthBoundsTest.GetBool()) {
qglEnable(GL_DEPTH_BOUNDS_TEST_EXT);
}
RB_RenderDrawSurfChainWithFunction(drawSurfs, RB_T_Shadow);
GL_Cull(CT_FRONT_SIDED);
if (r_shadowPolygonFactor.GetFloat() || r_shadowPolygonOffset.GetFloat()) {
qglDisable(GL_POLYGON_OFFSET_FILL);
}
if (glConfig.depthBoundsTestAvailable && r_useDepthBoundsTest.GetBool()) {
qglDisable(GL_DEPTH_BOUNDS_TEST_EXT);
}
qglEnableClientState(GL_TEXTURE_COORD_ARRAY);
qglStencilFunc(GL_GEQUAL, 128, 255);
qglStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
}
示例2: RB_RenderViewLight
/*
==================
RB_RenderViewLight
==================
*/
static void RB_RenderViewLight(viewLight_t *vLight)
{
backEnd.vLight = vLight;
// do fogging later
if (vLight->lightShader->IsFogLight()) {
return;
}
if (vLight->lightShader->IsBlendLight()) {
return;
}
RB_LogComment("---------- RB_RenderViewLight 0x%p ----------\n", vLight);
// clear the stencil buffer if needed
if (vLight->globalShadows || vLight->localShadows) {
backEnd.currentScissor = vLight->scissorRect;
if (r_useScissor.GetBool()) {
qglScissor(backEnd.viewDef->viewport.x1 + backEnd.currentScissor.x1,
backEnd.viewDef->viewport.y1 + backEnd.currentScissor.y1,
backEnd.currentScissor.x2 + 1 - backEnd.currentScissor.x1,
backEnd.currentScissor.y2 + 1 - backEnd.currentScissor.y1);
}
qglClear(GL_STENCIL_BUFFER_BIT);
} else {
// no shadows, so no need to read or write the stencil buffer
// we might in theory want to use GL_ALWAYS instead of disabling
// completely, to satisfy the invarience rules
qglStencilFunc(GL_ALWAYS, 128, 255);
}
backEnd.depthFunc = GLS_DEPTHFUNC_EQUAL;
RB_StencilShadowPass(vLight->globalShadows);
RB_CreateDrawInteractions(vLight->localInteractions);
RB_StencilShadowPass(vLight->localShadows);
RB_CreateDrawInteractions(vLight->globalInteractions);
if (r_skipTranslucent.GetBool()) {
return;
}
// disable stencil testing for translucent interactions, because
// the shadow isn't calculated at their point, and the shadow
// behind them may be depth fighting with a back side, so there
// isn't any reasonable thing to do
qglStencilFunc(GL_ALWAYS, 128, 255);
backEnd.depthFunc = GLS_DEPTHFUNC_LESS;
RB_CreateDrawInteractions(vLight->translucentInteractions);
}
示例3: 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 ( r_shadows->integer != 2 ) {
return;
}
if ( glConfig.stencilBits < 4 ) {
return;
}
qglEnable( GL_STENCIL_TEST );
qglStencilFunc( GL_NOTEQUAL, 0, 255 );
qglDisable( GL_CLIP_PLANE0 );
qglDisable( GL_CULL_FACE );
GL_Bind( tr.whiteImage );
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 );
qglBegin( GL_QUADS );
qglVertex3f( -100, 100, -10 );
qglVertex3f( 100, 100, -10 );
qglVertex3f( 100, -100, -10 );
qglVertex3f( -100, -100, -10 );
qglEnd();
qglColor4f( 1,1,1,1 );
qglDisable( GL_STENCIL_TEST );
}
示例4: 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 );
qglBegin( GL_QUADS );
qglVertex3f( -100, 100, -10 );
qglVertex3f( 100, 100, -10 );
qglVertex3f( 100, -100, -10 );
qglVertex3f( -100, -100, -10 );
qglEnd ();
qglColor4f(1,1,1,1);
qglDisable( GL_STENCIL_TEST );
if (planeZeroBack)
{
qglEnable (GL_CLIP_PLANE0);
}
qglPopMatrix();
#endif // VV_LIGHTING && _XBOX
}
示例5: RB_StencilSurf
// stencil_surf0: clear stencil; draw, incrementing stencil where stencil == 0
// stencil_surf1: draw, incrementing stencil where stencil == 1
// ...
// stencil_surfN: draw, incrementing stencil where stencil == N
// draw_surfN: disable stencil write, color where stencil == N+1
// ...
// draw_surf1: color where stencil == 2
// draw_surf0: color where stencil == 1, disable stencil test
void const* RB_StencilSurf(void const* data)
{
stencilSurfCommand_t const* const cmd = (stencilSurfCommand_t const* const)data;
// Finish any 2D drawing if needed
if(tess.numIndexes)
RB_EndSurface();
backEnd.refdef = cmd->refdef;
backEnd.viewParms = cmd->viewParms;
if(r_subviewStencil->integer)
{
// First stencil surface for this view
if(0 == backEnd.stencil_level)
{
assert(qfalse == backEnd.stencil_draw);
qglClear(GL_STENCIL_BUFFER_BIT);
qglEnable(GL_STENCIL_TEST);
backEnd.stencil_test = qtrue;
// sfail/dpfail: KEEP, dppass: INCR
qglStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
backEnd.stencil_draw = qtrue;
}
qglStencilFunc(GL_EQUAL, backEnd.stencil_level, ~0U);
backEnd.stencil_level++;
RB_RenderDrawSurfList(cmd->drawSurf, 1);
backEnd.pc.c_stencilSurfaces++;
}
return cmd + 1;
}
示例6: GLRB_ShadowSilhouette
void GLRB_ShadowSilhouette( const float* edges, int edgeCount )
{
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
GL_Cull( CT_BACK_SIDED ); // @pjb: resolves to GL_FRONT if to mirror flag is set
qglStencilOp( GL_KEEP, GL_KEEP, GL_INCR );
RenderShadowEdges( edges, edgeCount );
GL_Cull( CT_FRONT_SIDED ); // @pjb: resolves to GL_BACK due to mirror flag is set
qglStencilOp( GL_KEEP, GL_KEEP, GL_DECR );
RenderShadowEdges( edges, edgeCount );
// reenable writing to the color buffer
qglColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
}
示例7: 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 (r_shadows->integer != 2)
{
return;
}
if (glConfig.stencilBits < 4)
{
return;
}
qglEnable(GL_STENCIL_TEST);
qglStencilFunc(GL_NOTEQUAL, 0, 255);
qglDisable(GL_CLIP_PLANE0);
qglDisable(GL_CULL_FACE);
GL_Bind(tr.whiteImage);
qglLoadIdentity();
qglColor3f(0.6f, 0.6f, 0.6f);
GL_State(GLS_DEPTHMASK_TRUE | GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO);
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);
}
GLfloat vtx[] =
{
-100, 100, -10,
100, 100, -10,
100, -100, -10,
-100, -100, -10
};
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);
}
qglColor4f(1, 1, 1, 1);
qglDisable(GL_STENCIL_TEST);
}
示例8: RB_STD_FogAllLights
/*
==================
RB_STD_FogAllLights
==================
*/
void RB_STD_FogAllLights( void ) {
viewLight_t *vLight;
if ( r_skipFogLights.GetBool() || r_showOverDraw.GetInteger() != 0
|| backEnd.viewDef->isXraySubview /* dont fog in xray mode*/
) {
return;
}
qglDisable( GL_STENCIL_TEST );
for ( vLight = backEnd.viewDef->viewLights ; vLight ; vLight = vLight->next ) {
backEnd.vLight = vLight;
if ( !vLight->lightShader->IsFogLight() && !vLight->lightShader->IsBlendLight() ) {
continue;
}
#if 0 // _D3XP disabled that
if ( r_ignore.GetInteger() ) {
// we use the stencil buffer to guarantee that no pixels will be
// double fogged, which happens in some areas that are thousands of
// units from the origin
backEnd.currentScissor = vLight->scissorRect;
if ( r_useScissor.GetBool() ) {
qglScissor( backEnd.viewDef->viewport.x1 + backEnd.currentScissor.x1,
backEnd.viewDef->viewport.y1 + backEnd.currentScissor.y1,
backEnd.currentScissor.x2 + 1 - backEnd.currentScissor.x1,
backEnd.currentScissor.y2 + 1 - backEnd.currentScissor.y1 );
}
qglClear( GL_STENCIL_BUFFER_BIT );
qglEnable( GL_STENCIL_TEST );
// only pass on the cleared stencil values
qglStencilFunc( GL_EQUAL, 128, 255 );
// when we pass the stencil test and depth test and are going to draw,
// increment the stencil buffer so we don't ever draw on that pixel again
qglStencilOp( GL_KEEP, GL_KEEP, GL_INCR );
}
#endif
if ( vLight->lightShader->IsFogLight() ) {
RB_FogPass( vLight->globalInteractions, vLight->localInteractions );
} else if ( vLight->lightShader->IsBlendLight() ) {
RB_BlendLight( vLight->globalInteractions, vLight->localInteractions );
}
qglDisable( GL_STENCIL_TEST );
}
qglEnable( GL_STENCIL_TEST );
}
示例9: GL_StencilFunc
/*
==================
GL_StencilFunc
==================
*/
void GL_StencilFunc (uint func, int ref, uint mask){
if (glState.stencilFunc[0] == func && glState.stencilFunc[1] == func && glState.stencilFuncRef[0] == ref && glState.stencilFuncRef[1] == ref && glState.stencilFuncMask[0] == mask && glState.stencilFuncMask[1] == mask)
return;
glState.stencilFunc[0] = func;
glState.stencilFunc[1] = func;
glState.stencilFuncRef[0] = ref;
glState.stencilFuncRef[1] = ref;
glState.stencilFuncMask[0] = mask;
glState.stencilFuncMask[1] = mask;
qglStencilFunc(func, ref, mask);
}
示例10: GLRB_SetOverdrawMeasureEnabled
void GLRB_SetOverdrawMeasureEnabled( qboolean enabled )
{
if ( !enabled )
{
qglDisable( GL_STENCIL_TEST );
}
else
{
qglEnable( GL_STENCIL_TEST );
qglStencilMask( ~0U );
qglClearStencil( 0U );
qglStencilFunc( GL_ALWAYS, 0U, ~0U );
qglStencilOp( GL_KEEP, GL_INCR, GL_INCR );
}
}
示例11: RB_MaskTessEnd
void RB_MaskTessEnd( void ) {
shaderCommands_t *input;
input = &tess;
//qglClear( GL_COLOR_BUFFER_BIT );
qglColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE);
qglDepthMask(GL_FALSE);
qglEnable(GL_STENCIL_TEST);
qglClearStencil(0);
qglClear(GL_STENCIL_BUFFER_BIT);
qglStencilFunc(GL_ALWAYS,1,1);
qglStencilOp(GL_KEEP,GL_KEEP,GL_REPLACE);
tess.currentStageIteratorFunc();
qglDepthMask(GL_TRUE);
qglColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE);
qglStencilFunc(GL_EQUAL,1,1);
qglStencilOp(GL_KEEP,GL_KEEP,GL_KEEP);
}
示例12: RB_STD_DrawView
/*
=============
RB_STD_DrawView
=============
*/
void RB_STD_DrawView( void ) {
drawSurf_t **drawSurfs;
int numDrawSurfs;
backEnd.depthFunc = GLS_DEPTHFUNC_EQUAL;
drawSurfs = (drawSurf_t **)&backEnd.viewDef->drawSurfs[0];
numDrawSurfs = backEnd.viewDef->numDrawSurfs;
// clear the z buffer, set the projection matrix, etc
RB_BeginDrawingView();
// decide how much overbrighting we are going to do
RB_DetermineLightScale();
// fill the depth buffer and clear color buffer to black except on
// subviews
RB_STD_FillDepthBuffer( drawSurfs, numDrawSurfs );
// main light renderer
switch( tr.backEndRenderer ) {
case BE_ARB2:
RB_ARB2_DrawInteractions();
break;
}
// disable stencil shadow test
qglStencilFunc( GL_ALWAYS, 128, 255 );
// uplight the entire screen to crutch up not having better blending range
RB_STD_LightScale();
// now draw any non-light dependent shading passes
int processed = RB_STD_DrawShaderPasses( drawSurfs, numDrawSurfs );
// fob and blend lights
RB_STD_FogAllLights();
// now draw any post-processing effects using _currentRender
if ( processed < numDrawSurfs ) {
RB_STD_DrawShaderPasses( drawSurfs+processed, numDrawSurfs-processed );
}
RB_RenderDebugTools( drawSurfs, numDrawSurfs );
}
示例13: RB_STD_FillDepthBuffer
/*
=====================
RB_STD_FillDepthBuffer
If we are rendering a subview with a near clip plane, use a second texture
to force the alpha test to fail when behind that clip plane
=====================
*/
void RB_STD_FillDepthBuffer(drawSurf_t **drawSurfs, int numDrawSurfs)
{
// if we are just doing 2D rendering, no need to fill the depth buffer
if (!backEnd.viewDef->viewEntitys) {
return;
}
RB_LogComment("---------- RB_STD_FillDepthBuffer ----------\n");
// enable the second texture for mirror plane clipping if needed
if (backEnd.viewDef->numClipPlanes) {
GL_SelectTexture(1);
globalImages->alphaNotchImage->Bind();
qglDisableClientState(GL_TEXTURE_COORD_ARRAY);
qglEnable(GL_TEXTURE_GEN_S);
qglTexCoord2f(1, 0.5);
}
// the first texture will be used for alpha tested surfaces
GL_SelectTexture(0);
qglEnableClientState(GL_TEXTURE_COORD_ARRAY);
// decal surfaces may enable polygon offset
qglPolygonOffset(r_offsetFactor.GetFloat(), r_offsetUnits.GetFloat());
GL_State(GLS_DEPTHFUNC_LESS);
// Enable stencil test if we are going to be using it for shadows.
// If we didn't do this, it would be legal behavior to get z fighting
// from the ambient pass and the light passes.
qglEnable(GL_STENCIL_TEST);
qglStencilFunc(GL_ALWAYS, 1, 255);
RB_RenderDrawSurfListWithFunction(drawSurfs, numDrawSurfs, RB_T_FillDepthBuffer);
if (backEnd.viewDef->numClipPlanes) {
GL_SelectTexture(1);
globalImages->BindNull();
qglDisable(GL_TEXTURE_GEN_S);
GL_SelectTexture(0);
}
}
示例14: 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;
if(r_subviewStencil->integer)
{
assert(backEnd.stencil_level == cmd->viewParms.subview_level);
if(qtrue == backEnd.stencil_draw)
{
qglStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
backEnd.stencil_draw = qfalse;
}
if(backEnd.stencil_level)
{
// pass if: backEnd.stencil_level <= stencil
qglStencilFunc(GL_LEQUAL, backEnd.stencil_level, ~0U);
backEnd.stencil_level--;
}
}
RB_RenderDrawSurfList( cmd->drawSurfs, cmd->numDrawSurfs );
if(r_subviewStencil->integer)
{
if(backEnd.stencil_test && 0 == backEnd.stencil_level)
{
qglDisable(GL_STENCIL_TEST);
backEnd.stencil_test = qfalse;
}
}
return (const void *)(cmd + 1);
}
示例15: RB_SetGLDefaults
/*
* RB_SetGLDefaults
*/
static void RB_SetGLDefaults( void )
{
if( glConfig.stencilBits )
{
qglStencilMask( ( GLuint ) ~0 );
qglStencilFunc( GL_EQUAL, 128, 0xFF );
qglStencilOp( GL_KEEP, GL_KEEP, GL_INCR );
}
qglDisable( GL_CULL_FACE );
qglFrontFace( GL_CCW );
qglDisable( GL_BLEND );
qglDepthFunc( GL_LEQUAL );
qglDepthMask( GL_FALSE );
qglDisable( GL_POLYGON_OFFSET_FILL );
qglPolygonOffset( -1.0f, 0.0f ); // units will be handled by RB_DepthOffset
qglColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
qglEnable( GL_DEPTH_TEST );
#ifndef GL_ES_VERSION_2_0
qglPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
#endif
qglFrontFace( GL_CCW );
}