Commit 938d66c3 authored by Jan Möbius's avatar Jan Möbius
Browse files

Merge branch 'FBO_depthstencil' into 'master'

Fbo packed depthstencil renderbuffer

Tried to use a separate stencil attachment on my gpu, but it wasn't working as expected. A packed depth-stencil renderbuffer works fine though.

See merge request !33
parents 587472de 55e6c4f9
Pipeline #103 skipped
......@@ -402,6 +402,46 @@ addStencilBuffer( GLuint _width, GLuint _height )
unbind();
}
//-----------------------------------------------------------------------------
void
FBO::
addDepthStencilBuffer( GLuint _width, GLuint _height )
{
if (depthbuffer_)
glDeleteRenderbuffersEXT(1, &depthbuffer_);
if (stencilbuffer_)
glDeleteRenderbuffersEXT(1, &stencilbuffer_);
depthbuffer_ = stencilbuffer_ = 0;
// create renderbuffer
glGenRenderbuffersEXT(1, &depthbuffer_);
// bind renderbuffer
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depthbuffer_);
// malloc
#ifdef GL_ARB_texture_multisample
glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, samples_, GL_DEPTH_STENCIL, _width, _height);
#else
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_STENCIL, _width, _height);
#endif
// attach to framebuffer object
if (bind())
{
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthbuffer_);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthbuffer_);
}
// check status
checkFramebufferStatus();
// normal render mode
unbind();
}
//-----------------------------------------------------------------------------
......@@ -604,7 +644,6 @@ GLsizei FBO::setMultisampling( GLsizei _samples, GLboolean _fixedsamplelocations
}
//=============================================================================
} // namespace ACG
//=============================================================================
......@@ -142,6 +142,9 @@ public:
/// function to add a stencil renderbuffer to the fbo
void addStencilBuffer( GLuint _width, GLuint _height );
/// add a packed depth24_stencil8 renderbuffer
void addDepthStencilBuffer( GLuint _width, GLuint _height );
/// return attached texture id
GLuint getAttachment( GLenum _attachment );
......
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