Commit 0aafa7da by Sebastian Eichelbaum

[FIX] - fixes offscreen render problem on MacOS X

parent c5643cb3
......@@ -34,6 +34,17 @@ WGEOffscreenFinalPass::WGEOffscreenFinalPass( size_t textureWidth, size_t textur
// initialize members
setRenderTargetImplementation( osg::Camera::FRAME_BUFFER );
setRenderOrder( osg::Camera::NESTED_RENDER, 0 );
// render before the hud
if ( m_hud )
{
getOrCreateStateSet()->setRenderBinDetails( m_hud->getRenderBin() - 1, "RenderBin" );
}
else
{
getOrCreateStateSet()->setRenderBinDetails( 10000, "RenderBin" );
}
osg::StateSet* state = this->getOrCreateStateSet();
state->setMode( GL_DEPTH_TEST, osg::StateAttribute::ON );
}
......@@ -45,6 +56,17 @@ WGEOffscreenFinalPass::WGEOffscreenFinalPass( size_t textureWidth, size_t textur
// initialize members
setRenderTargetImplementation( osg::Camera::FRAME_BUFFER );
setRenderOrder( osg::Camera::NESTED_RENDER, 0 );
// render before the hud
if ( m_hud )
{
getOrCreateStateSet()->setRenderBinDetails( m_hud->getRenderBin() - 1, "RenderBin" );
}
else
{
getOrCreateStateSet()->setRenderBinDetails( 10000, "RenderBin" );
}
osg::StateSet* state = this->getOrCreateStateSet();
state->setMode( GL_DEPTH_TEST, osg::StateAttribute::ON );
}
......
......@@ -91,7 +91,11 @@ osg::ref_ptr< osg::Texture2D > WGEOffscreenRenderPass::attach( BufferComponent b
}
else
{
#if defined(__APPLE__)
tex = createTexture( GL_RGBA ); // on MacOS X, only RGBA textures work as attachment for FBO's
#else
tex = createTexture( internalFormat );
#endif
}
attach( buffer, tex );
return tex;
......
......@@ -44,10 +44,11 @@ WGETextureHud::WGETextureHud():
osg::Projection(),
m_group( new WGEGroupNode() ),
m_maxElementWidth( 256 ),
m_renderBin( 10000 ),
m_viewport( new osg::Viewport() ),
m_coupleTexViewport( false )
{
getOrCreateStateSet()->setRenderBinDetails( 1000, "RenderBin" );
getOrCreateStateSet()->setRenderBinDetails( m_renderBin, "RenderBin" );
m_group->addUpdateCallback( new SafeUpdateCallback( this ) );
addChild( m_group );
}
......@@ -310,3 +311,8 @@ osg::ref_ptr< osg::Texture2D > WGETextureHud::WGETextureHudEntry::getTexture() c
return m_texture;
}
size_t WGETextureHud::getRenderBin() const
{
return m_renderBin;
}
......@@ -183,6 +183,13 @@ public:
*/
void coupleViewportWithTextureViewport( bool couple = true );
/**
* Returns the render bin used by the HUD.
*
* \return the bin number
*/
size_t getRenderBin() const;
protected:
/**
......@@ -197,6 +204,11 @@ protected:
unsigned int m_maxElementWidth;
/**
* The render bin to use
*/
size_t m_renderBin;
/**
* The current viewport of
*/
osg::Viewport* m_viewport;
......
......@@ -45,8 +45,22 @@ float scaleZeroOne( in float threshold, in float min, in float max )
*
* \return true if zero.
*/
bool isZero( in float value, in float epsilon = 0.001 )
bool isZero( in float value, in float epsilon )
{
return ( abs( value ) <= epsilon );
}
/**
* Evaluates a given value whether it is zero, or more exactly, if it can be seen as zero.
* \note This version is needed for portability as the GLSL compiler on MacOS X does not allow argument default values in functions.
*
* \param value the value to check
* \param epsilon the epsilon to use. Default is 0.001. Much lower is not recommended since floating point precision in GLSL is not that high.
*
* \return true if zero.
*/
bool isZero( in float value )
{
return ( abs( value ) <= 0.001 );
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment