From Tim Moore, "This contains a couple of fixes to support changing FrameBufferObject configurations on the fly; the user changes the camera attachments and calls Renderer::setCameraRequiresSetUp(). The major part of this submission is a comprehensive example of setting up floating point depth buffers. The user can change the near plane value and cycle through the available combinations of depth format and multisample buffer formats."

This commit is contained in:
Robert Osfield
2010-04-19 11:43:06 +00:00
parent 488eac94f7
commit c0e9fcbb67
8 changed files with 1045 additions and 2 deletions

View File

@@ -40,6 +40,7 @@ IF(DYNAMIC_OPENSCENEGRAPH)
ADD_SUBDIRECTORY(osgfadetext)
ADD_SUBDIRECTORY(osgfont)
ADD_SUBDIRECTORY(osgforest)
ADD_SUBDIRECTORY(osgfpdepth)
ADD_SUBDIRECTORY(osgfxbrowser)
ADD_SUBDIRECTORY(osgoutline)
ADD_SUBDIRECTORY(osggameoflife)

View File

@@ -0,0 +1,4 @@
SET(TARGET_SRC osgfpdepth.cpp )
#### end var setup ###
SETUP_EXAMPLE(osgfpdepth)

File diff suppressed because it is too large Load Diff

View File

@@ -153,6 +153,7 @@ namespace osg
typedef void APIENTRY TglFramebufferRenderbuffer(GLenum, GLenum, GLenum, GLuint);
typedef void APIENTRY TglGenerateMipmap(GLenum);
typedef void APIENTRY TglBlitFramebuffer(GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum);
typedef void APIENTRY TglGetRenderbufferParameteriv(GLenum, GLenum, GLint*);
TglBindRenderbuffer* glBindRenderbuffer;
TglGenRenderbuffers* glGenRenderbuffers;
@@ -171,6 +172,7 @@ namespace osg
TglFramebufferRenderbuffer* glFramebufferRenderbuffer;
TglGenerateMipmap* glGenerateMipmap;
TglBlitFramebuffer* glBlitFramebuffer;
TglGetRenderbufferParameteriv* glGetRenderbufferParameteriv;
static FBOExtensions* instance(unsigned contextID, bool createIfNotInitalized);

View File

@@ -59,6 +59,7 @@ class OSGVIEWER_EXPORT Renderer : public osg::GraphicsOperation, public OpenGLQu
Renderer(osg::Camera* camera);
osgUtil::SceneView* getSceneView(unsigned int i) { return _sceneView[i].get(); }
const osgUtil::SceneView* getSceneView(unsigned int i) const { return _sceneView[i].get(); }
void setDone(bool done) { _done = done; }
bool getDone() { return _done; }
@@ -126,6 +127,10 @@ class OSGVIEWER_EXPORT Renderer : public osg::GraphicsOperation, public OpenGLQu
void setConservativeTimeRatio(double ratio) { _conservativeTimeRatio = ratio; }
double getConservativeTimeRatio() const { return _conservativeTimeRatio; }
/** Force update of state associated with cameras. */
void setCameraRequiresSetUp(bool flag);
bool getCameraRequiresSetUp() const;
protected:
virtual ~Renderer();

View File

@@ -75,6 +75,7 @@ FBOExtensions::FBOExtensions(unsigned int contextID)
LOAD_FBO_EXT(glFramebufferTextureLayer);
LOAD_FBO_EXT(glFramebufferRenderbuffer);
LOAD_FBO_EXT(glGenerateMipmap);
LOAD_FBO_EXT(glGetRenderbufferParameteriv);
_supported =
glBindRenderbuffer != 0 &&
@@ -89,7 +90,8 @@ FBOExtensions::FBOExtensions(unsigned int contextID)
glFramebufferTexture2D != 0 &&
glFramebufferTexture3D != 0 &&
glFramebufferRenderbuffer != 0 &&
glGenerateMipmap != 0;
glGenerateMipmap != 0 &&
glGetRenderbufferParameteriv != 0;
LOAD_FBO_EXT(glBlitFramebuffer);
LOAD_FBO_EXT(glRenderbufferStorageMultisample);

View File

@@ -331,7 +331,7 @@ void RenderStage::runCameraSetUp(osg::RenderInfo& renderInfo)
osg::FBOExtensions* fbo_ext = osg::FBOExtensions::instance(state.getContextID(),true);
bool fbo_supported = fbo_ext && fbo_ext->isSupported();
if (fbo_supported && !_fbo)
if (fbo_supported)
{
OSG_NOTIFY(osg::INFO)<<"Setting up osg::Camera::FRAME_BUFFER_OBJECT"<<std::endl;

View File

@@ -743,3 +743,25 @@ void Renderer::release()
_availableQueue.release();
_drawQueue.release();
}
void Renderer::setCameraRequiresSetUp(bool flag)
{
for (int i = 0; i < 2; ++i)
{
osgUtil::SceneView* sv = getSceneView(i);
osgUtil::RenderStage* rs = sv ? sv->getRenderStage() : 0;
if (rs) rs->setCameraRequiresSetUp(flag);
}
}
bool Renderer::getCameraRequiresSetUp() const
{
bool result = false;
for (int i = 0; i < 2; ++i)
{
const osgUtil::SceneView* sv = getSceneView(i);
const osgUtil::RenderStage* rs = sv ? sv->getRenderStage() : 0;
if (rs) result = result || rs->getCameraRequiresSetUp();
}
return result;
}