28 #include <osg/Texture>
29 #include <osg/Texture2D>
31 #include "core/common/WLogger.h"
32 #include "../WGETextureHud.h"
34 #include "WGEOffscreenRenderPass.h"
38 m_width( textureWidth ),
39 m_height( textureHeight ),
40 m_fbo( new osg::FrameBufferObject() ),
44 setClearColor( osg::Vec4( 0.0, 0.0, 0.0, 0.0 ) );
45 setClearMask( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
46 setReferenceFrame( osg::Transform::RELATIVE_RF );
47 setRenderTargetImplementation( osg::Camera::FRAME_BUFFER_OBJECT );
48 setRenderOrder( osg::Camera::PRE_RENDER, num );
54 m_width( textureWidth ),
55 m_height( textureHeight ),
56 m_fbo( new osg::FrameBufferObject() ),
61 setClearColor( osg::Vec4( 0.0, 0.0, 0.0, 0.0 ) );
62 setClearMask( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
63 setReferenceFrame( osg::Transform::RELATIVE_RF );
64 setRenderTargetImplementation( osg::Camera::FRAME_BUFFER_OBJECT );
65 setRenderOrder( osg::Camera::PRE_RENDER, num );
75 m_fbo->setAttachment( buffer, osg::FrameBufferAttachment( texture ) );
82 osg::Camera::attach( buffer, texture );
87 osg::ref_ptr< osg::Texture2D > tex;
88 if( buffer == DEPTH_BUFFER )
94 #if defined(__APPLE__)
95 if( internalFormat != GL_RGBA )
97 wlog::warn(
"WGEOffscreenRenderPass::attach:" ) <<
98 "Changing internal format to GL_RGBA because the original format is not supported on Mac OSX.";
112 if(
m_hud && osg::Camera::getBufferAttachmentMap().count( buffer ) )
114 m_hud->removeTexture( osg::Camera::getBufferAttachmentMap()[ buffer ]._texture );
117 m_fbo->setAttachment( buffer, osg::FrameBufferAttachment() );
119 osg::Camera::detach( buffer );
124 osg::ref_ptr< osg::Texture2D > tex =
new osg::Texture2D;
126 tex->setInternalFormat( internalFormat );
129 tex->setFilter( osg::Texture::MIN_FILTER, osg::Texture::LINEAR );
130 tex->setFilter( osg::Texture::MAG_FILTER, osg::Texture::LINEAR );
133 tex->setWrap( osg::Texture::WRAP_S, osg::Texture::REPEAT );
134 tex->setWrap( osg::Texture::WRAP_T, osg::Texture::REPEAT );
156 this->getOrCreateStateSet()->addUniform( uniform );
167 case PACKED_DEPTH_STENCIL_BUFFER:
168 return "Depth+Stencil";