| 66 | | // Create and return a StateSet appropriate for performing an occlusion |
| 67 | | // query test (disable lighting, texture mapping, etc). Probably some |
| 68 | | // room for improvement here. Could disable shaders, for example. |
| 69 | | osg::StateSet* |
| 70 | | initOQState() |
| 71 | | { |
| 72 | | osg::StateSet* state = new osg::StateSet; |
| 73 | | // TBD Possible bug, need to allow user to set render bin number. |
| 74 | | state->setRenderBinDetails( 9, "RenderBin" ); |
| 75 | | |
| 76 | | state->setMode( GL_LIGHTING, osg::StateAttribute::OFF | |
| 77 | | osg::StateAttribute::PROTECTED); |
| 78 | | state->setTextureMode( 0, GL_TEXTURE_2D, osg::StateAttribute::OFF | |
| 79 | | osg::StateAttribute::PROTECTED); |
| 80 | | state->setMode( GL_CULL_FACE, osg::StateAttribute::ON | |
| 81 | | osg::StateAttribute::PROTECTED); |
| 82 | | |
| 83 | | osg::ColorMask* cm = new osg::ColorMask( false, false, false, false ); |
| 84 | | state->setAttributeAndModes( cm, osg::StateAttribute::ON | |
| 85 | | osg::StateAttribute::PROTECTED); |
| 86 | | osg::Depth* d = new osg::Depth( osg::Depth::LEQUAL, 0.f, 1.f, false ); |
| 87 | | state->setAttributeAndModes( d, osg::StateAttribute::ON | |
| 88 | | osg::StateAttribute::PROTECTED); |
| 89 | | osg::PolygonMode* pm = new osg::PolygonMode( |
| 90 | | osg::PolygonMode::FRONT_AND_BACK, osg::PolygonMode::FILL ); |
| 91 | | state->setAttributeAndModes( pm, osg::StateAttribute::ON | |
| 92 | | osg::StateAttribute::PROTECTED); |
| 93 | | |
| 94 | | osg::PolygonOffset* po = new osg::PolygonOffset( -1., -1. ); |
| 95 | | state->setAttributeAndModes( po, osg::StateAttribute::ON | |
| 96 | | osg::StateAttribute::PROTECTED); |
| 97 | | |
| 98 | | return state; |
| 99 | | } |
| 100 | | |
| 101 | | // Create and return a StateSet for rendering a debug representation of query geometry. |
| 102 | | osg::StateSet* |
| 103 | | initOQDebugState() |
| 104 | | { |
| 105 | | osg::StateSet* debugState = new osg::StateSet; |
| 106 | | |
| 107 | | debugState->setMode( GL_LIGHTING, osg::StateAttribute::OFF | |
| 108 | | osg::StateAttribute::PROTECTED); |
| 109 | | debugState->setTextureMode( 0, GL_TEXTURE_2D, osg::StateAttribute::OFF | |
| 110 | | osg::StateAttribute::PROTECTED); |
| 111 | | debugState->setMode( GL_CULL_FACE, osg::StateAttribute::ON | |
| 112 | | osg::StateAttribute::PROTECTED); |
| 113 | | |
| 114 | | osg::PolygonMode* pm = new osg::PolygonMode( |
| 115 | | osg::PolygonMode::FRONT_AND_BACK, osg::PolygonMode::LINE ); |
| 116 | | debugState->setAttributeAndModes( pm, osg::StateAttribute::ON | |
| 117 | | osg::StateAttribute::PROTECTED); |
| 118 | | |
| 119 | | osg::PolygonOffset* po = new osg::PolygonOffset( -1., -1. ); |
| 120 | | debugState->setAttributeAndModes( po, osg::StateAttribute::ON | |
| 121 | | osg::StateAttribute::PROTECTED); |
| 122 | | |
| 123 | | return debugState; |
| 124 | | } |
| 125 | | |