RE: [Plib-users] Overriding face culling
Brought to you by:
sjbaker
From: Norman V. <nh...@ca...> - 2003-02-19 15:59:49
|
Paolo Leoncini writes: > > Can anybody explain why? and how to force disabling back face culling? Maybe this code snippet will help /* Multipass rendering sometimes required: * Wire plus filled * Filled-front-faces with wire backfaces. * Selected polygons have white wire faces. */ if ( rendermode & RENDER_TEXTURE ) { glEnable ( GL_TEXTURE_2D ) ; ssgOverrideTexture ( FALSE ) ; } else { glDisable ( GL_TEXTURE_2D ) ; ssgOverrideTexture ( TRUE ) ; } /* If filled AND not wire AND not backfaces - then need wire as a first pass. */ if ( (rendermode & RENDER_FILLED )!=0 && (rendermode & RENDER_WIRE )==0 && (rendermode & RENDER_BACKFACES )==0 ) { /* First pass: Both faces, wireframe */ glPolygonMode ( GL_FRONT_AND_BACK, GL_LINE ) ; glDisable ( GL_CULL_FACE ) ; ssgOverrideCullface ( TRUE ) ; ssgCullAndDraw ( getSceneRoot() ) ; /* Zap the Z buffer */ glClear ( GL_DEPTH_BUFFER_BIT ) ; /* Second pass: Front faces only - filled */ glPolygonMode ( GL_FRONT_AND_BACK, GL_FILL ) ; glEnable ( GL_CULL_FACE ) ; ssgOverrideCullface ( FALSE ) ; ssgCullAndDraw ( getSceneRoot() ) ; } else /* If filled AND wire - then need wire as a second pass. */ if ( (rendermode & RENDER_FILLED)!=0 && (rendermode & RENDER_WIRE )!=0 ) { setOffsetProjectionMatrix ( PUSH_BACK ) ; glPolygonMode ( GL_FRONT_AND_BACK, GL_FILL ) ; glDisable ( GL_CULL_FACE ) ; ssgOverrideCullface ( TRUE ) ; ssgCullAndDraw ( getSceneRoot() ) ; glPolygonMode ( GL_FRONT_AND_BACK, GL_LINE ) ; glEnable ( GL_CULL_FACE ) ; ssgOverrideCullface ( FALSE ) ; ssgCullAndDraw ( getSceneRoot() ) ; } else /* We only need one pass. */ { if ( rendermode & RENDER_WIRE ) glPolygonMode ( GL_FRONT_AND_BACK, GL_LINE ) ; else glPolygonMode ( GL_FRONT_AND_BACK, GL_FILL ) ; if ( rendermode & RENDER_BACKFACES ) { glDisable ( GL_CULL_FACE ) ; ssgOverrideCullface ( TRUE ) ; } else { glEnable ( GL_CULL_FACE ) ; ssgOverrideCullface ( FALSE ) ; } ssgCullAndDraw ( getSceneRoot() ) ; } glFinish () ; Ciao Norman |