本文整理汇总了C++中qglStencilFunc函数的典型用法代码示例。如果您正苦于以下问题:C++ qglStencilFunc函数的具体用法?C++ qglStencilFunc怎么用?C++ qglStencilFunc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qglStencilFunc函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:AreaScout,项目名称:dante-doom3-odroid,代码行数:65,代码来源:draw_common.cpp
示例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);
}
开发者ID:AreaScout,项目名称:dante-doom3-odroid,代码行数:58,代码来源:draw_arb.cpp
示例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 );
}
开发者ID:JackalFrost,项目名称:RTCW-WSGF,代码行数:43,代码来源:tr_shadows.c
示例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
}
开发者ID:3ddy,项目名称:Jedi-Outcast,代码行数:70,代码来源:tr_shadows.cpp
示例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;
}
开发者ID:asvo,项目名称:quake3.gpl.old,代码行数:42,代码来源:tr_backend.c
示例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 );
}
开发者ID:Avatarchik,项目名称:Quake-III-Arena-D3D11,代码行数:27,代码来源:gl_shadows.c
示例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);
}
开发者ID:Mailaender,项目名称:etlegacy,代码行数:64,代码来源:tr_shadows.c
示例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 );
}
开发者ID:BielBdeLuna,项目名称:dhewm3,代码行数:58,代码来源:draw_common.cpp
示例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);
}
开发者ID:Mirrorman95,项目名称:quake-2-evolved,代码行数:19,代码来源:r_glState.c
示例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 );
}
}
开发者ID:Avatarchik,项目名称:Quake-III-Arena-D3D11,代码行数:15,代码来源:gl_driver.c
示例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);
}
开发者ID:redrumrobot,项目名称:quakeconstruct,代码行数:24,代码来源:tr_shade.c
示例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 );
}
开发者ID:BielBdeLuna,项目名称:dhewm3,代码行数:52,代码来源:draw_common.cpp
示例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);
}
}
开发者ID:AreaScout,项目名称:dante-doom3-odroid,代码行数:51,代码来源:draw_common.cpp
示例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);
}
开发者ID:asvo,项目名称:quake3.gpl.old,代码行数:49,代码来源:tr_backend.c
示例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 );
}
开发者ID:cfr,项目名称:qfusion,代码行数:26,代码来源:r_backend.c
示例16: 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 ) {
vec3_t quad[4] = {
{-100.0f, 100.0f, -10.0f},
{ 100.0f, 100.0f, -10.0f},
{ 100.0f, -100.0f, -10.0f},
{-100.0f, -100.0f, -10.0f}
};
glIndex_t indicies[6] = { 0, 1, 2, 0, 3, 2 };
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 ();
glColor4f( 0.6f, 0.6f, 0.6f, 1.0f );
GL_State( GLS_DEPTHMASK_TRUE | GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO );
// glColor4f( 1, 0, 0, 1 );
// GL_State( GLS_DEPTHMASK_TRUE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO );
qglVertexPointer(3, GL_FLOAT, 0, quad);
qglDrawElements(GL_TRIANGLE_STRIP, 6, GL_INDEX_TYPE, indicies);
glColor4f(1,1,1,1);
qglDisable( GL_STENCIL_TEST );
}
开发者ID:AbandonedCart,项目名称:XperiaPlayNative,代码行数:47,代码来源:tr_shadows.c
示例17: 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;
}
//
// gamma stuff
//
if ( r_gamma->modified ) {
r_gamma->modified = qfalse;
R_IssuePendingRenderCommands();
R_SetColorMappings();
}
// check for errors
if ( !r_ignoreGLErrors->integer )
{
int err;
R_IssuePendingRenderCommands();
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 );
}
//.........这里部分代码省略.........
开发者ID:mecwerks,项目名称:spearmint-ios,代码行数:101,代码来源:tr_cmds.c
示例18: RB_ProjectionShadowDeform
/*
=================
RB_ProjectionShadowDeform
=================
*/
void RB_ProjectionShadowDeform( void ) {
#ifdef _XBOX
float shadowMat[4][4];
vec3_t light, ground;
float d, dot;
ground[0] = backEnd.ori.axis[0][2];
ground[1] = backEnd.ori.axis[1][2];
ground[2] = backEnd.ori.axis[2][2];
d = backEnd.ori.origin[2] - backEnd.currentEntity->e.shadowPlane;
light[0] = backEnd.currentEntity->lightDir[0];
light[1] = backEnd.currentEntity->lightDir[1];
light[2] = backEnd.currentEntity->lightDir[2];
dot = ground[0] * light[0] +
ground[1] * light[1] +
ground[2] * light[2];
// don't let the shadows get too long or go negative
if ( dot < 0.5 )
{
VectorMA( light, (0.5 - dot), ground, light );
dot = DotProduct( light, ground );
}
shadowMat[0][0] = dot - light[0] * ground[0];
shadowMat[1][0] = 0.f - light[0] * ground[1];
shadowMat[2][0] = 0.f - light[0] * ground[2];
shadowMat[3][0] = 0.f - light[0] * d;
shadowMat[0][1] = 0.f - light[1] * ground[0];
shadowMat[1][1] = dot - light[1] * ground[1];
shadowMat[2][1] = 0.f - light[1] * ground[2];
shadowMat[3][1] = 0.f - light[1] * d;
shadowMat[0][2] = 0.f - light[2] * ground[0];
shadowMat[1][2] = 0.f - light[2] * ground[1];
shadowMat[2][2] = dot - light[2] * ground[2];
shadowMat[3][2] = 0.f - light[2] * d;
shadowMat[0][3] = 0.f;
shadowMat[1][3] = 0.f;
shadowMat[2][3] = 0.f;
shadowMat[3][3] = dot;
qglMatrixMode(GL_MODELVIEW);
qglMultMatrixf(&shadowMat[0][0]);
// Turn on stenciling
// This is done to prevent overlapping shadow artifacts
qglEnable( GL_STENCIL_TEST );
qglStencilFunc( GL_NOTEQUAL, 0x1, 0xffffffff );
qglStencilMask( 0xffffffff );
qglStencilOp( GL_KEEP, GL_KEEP, GL_INCR );
#else
float *xyz;
int i;
float h;
vec3_t ground;
vec3_t light;
float groundDist;
float d;
vec3_t lightDir;
xyz = ( float * ) tess.xyz;
ground[0] = backEnd.ori.axis[0][2];
ground[1] = backEnd.ori.axis[1][2];
ground[2] = backEnd.ori.axis[2][2];
groundDist = backEnd.ori.origin[2] - backEnd.currentEntity->e.shadowPlane;
VectorCopy( backEnd.currentEntity->lightDir, lightDir );
d = DotProduct( lightDir, ground );
// don't let the shadows get too long or go negative
if ( d < 0.5 ) {
VectorMA( lightDir, (0.5 - d), ground, lightDir );
d = DotProduct( lightDir, ground );
}
d = 1.0 / d;
light[0] = lightDir[0] * d;
light[1] = lightDir[1] * d;
light[2] = lightDir[2] * d;
for ( i = 0; i < tess.numVertexes; i++, xyz += 4 ) {
h = DotProduct( xyz, ground ) + groundDist;
xyz[0] -= light[0] * h;
xyz[1] -= light[1] * h;
xyz[2] -= light[2] * h;
}
#endif // _XBOX
}
开发者ID:3ddy,项目名称:Jedi-Outcast,代码行数:97,代码来源:tr_shadows.cpp
示例19: RB_DistortionFill
void RB_DistortionFill(void)
{
float alpha = tr_distortionAlpha;
float spost = 0.0f;
float spost2 = 0.0f;
if ( glConfig.stencilBits < 4 )
{
return;
}
//ok, cap the stupid thing now I guess
if (!tr_distortionPrePost)
{
RB_CaptureScreenImage();
}
qglEnable(GL_STENCIL_TEST);
qglStencilFunc(GL_NOTEQUAL, 0, 0xFFFFFFFF);
qglStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
qglDisable (GL_CLIP_PLANE0);
GL_Cull( CT_TWO_SIDED );
//reset the view matrices and go into ortho mode
qglMatrixMode(GL_PROJECTION);
qglPushMatrix();
qglLoadIdentity();
qglOrtho(0, glConfig.vidWidth, glConfig.vidHeight, 32, -1, 1);
qglMatrixMode(GL_MODELVIEW);
qglPushMatrix();
qglLoadIdentity();
if (tr_distortionStretch)
{ //override
spost = tr_distortionStretch;
spost2 = tr_distortionStretch;
}
else
{ //do slow stretchy effect
spost = sin(tr.refdef.time*0.0005f);
if (spost < 0.0f)
{
spost = -spost;
}
spost *= 0.2f;
spost2 = sin(tr.refdef.time*0.0005f);
if (spost2 < 0.0f)
{
spost2 = -spost2;
}
spost2 *= 0.08f;
}
if (alpha != 1.0f)
{ //blend
GL_State(GLS_SRCBLEND_SRC_ALPHA|GLS_DSTBLEND_SRC_ALPHA);
}
else
{ //be sure to reset the draw state
GL_State(0);
}
#ifdef _XBOX
qglBeginEXT(GL_QUADS, 4, 0, 0, 4, 0);
#else
qglBegin(GL_QUADS);
#endif // _XBOX
qglColor4f(1.0f, 1.0f, 1.0f, alpha);
qglTexCoord2f(0+spost2, 1-spost);
qglVertex2f(0, 0);
qglTexCoord2f(0+spost2, 0+spost);
qglVertex2f(0, glConfig.vidHeight);
qglTexCoord2f(1-spost2, 0+spost);
qglVertex2f(glConfig.vidWidth, glConfig.vidHeight);
qglTexCoord2f(1-spost2, 1-spost);
qglVertex2f(glConfig.vidWidth, 0);
qglEnd();
if (tr_distortionAlpha == 1.0f && tr_distortionStretch == 0.0f)
{ //no overrides
if (tr_distortionNegate)
{ //probably the crazy alternate saber trail
alpha = 0.8f;
GL_State(GLS_SRCBLEND_ZERO|GLS_DSTBLEND_ONE_MINUS_SRC_COLOR);
}
else
{
alpha = 0.5f;
GL_State(GLS_SRCBLEND_SRC_ALPHA|GLS_DSTBLEND_SRC_ALPHA);
}
spost = sin(tr.refdef.time*0.0008f);
if (spost < 0.0f)
{
spost = -spost;
//.........这里部分代码省略.........
开发者ID:3ddy,项目名称:Jedi-Outcast,代码行数:101,代码来源:tr_shadows.cpp
示例20: RB_DoShadowTessEnd
//.........这里部分代码省略.........
planeEq[3] = -( v1[0]*( v2[1]*v3[2] - v3[1]*v2[2] ) +
v2[0]*(v3[1]*v1[2] - v1[1]*v3[2]) +
v3[0]*(v1[1]*v2[2] - v2[1]*v1[2]) );
d = planeEq[0]*lightPos[0]+
planeEq[1]*lightPos[1]+
planeEq[2]*lightPos[2]+
planeEq[3];
}
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 ] );
}
GL_Bind( tr.whiteImage );
//qglEnable( GL_CULL_FACE );
GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO );
#ifndef _DEBUG_STENCIL_SHADOWS
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 );
#else
qglColor3f( 1.0f, 0.0f, 0.0f );
qglPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
//qglDisable(GL_DEPTH_TEST);
#endif
#ifdef _STENCIL_REVERSE
qglDepthFunc(GL_LESS);
//now using the Carmack Reverse<tm> -rww
if ( backEnd.viewParms.isMirror ) {
//qglCullFace( GL_BACK );
GL_Cull(CT_BACK_SIDED);
qglStencilOp( GL_KEEP, GL_INCR, GL_KEEP );
R_RenderShadowEdges();
//qglCullFace( GL_FRONT );
GL_Cull(CT_FRONT_SIDED);
qglStencilOp( GL_KEEP, GL_DECR, GL_KEEP );
R_RenderShadowEdges();
} else {
//qglCullFace( GL_FRONT );
GL_Cull(CT_FRONT_SIDED);
qglStencilOp( GL_KEEP, GL_INCR, GL_KEEP );
R_RenderShadowEdges();
//qglCullFace( GL_BACK );
GL_Cull(CT_BACK_SIDED);
qglStencilOp( GL_KEEP, GL_DECR, GL_KEEP );
开发者ID:3ddy,项目名称:Jedi-Outcast,代码行数:67,代码来源:tr_shadows.cpp
注:本文中的qglStencilFunc函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论