Skip to content

Commit

Permalink
libgui|GLFramebuffer: Fall back to no depth/stencil texture (just color)
Browse files Browse the repository at this point in the history
It is conceivable that some OpenGL drivers do not support a
depth24/stencil8 texture in a FBO attachments. In this case, we’ll
try to make do without depth information.
  • Loading branch information
skyjake committed Dec 20, 2013
1 parent 7e95c1f commit d57f2dc
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions doomsday/libgui/src/glframebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ DENG2_PIMPL(GLFramebuffer)
{
if(!self.isReady() || size == Size()) return;

// Configure textures for the framebuffer.
color.setUndefinedImage(size, colorFormat);
color.setWrap(gl::ClampToEdge, gl::ClampToEdge);
color.setFilter(gl::Nearest, gl::Nearest, gl::MipNone);
Expand All @@ -144,7 +145,22 @@ DENG2_PIMPL(GLFramebuffer)
depthStencil.setWrap(gl::ClampToEdge, gl::ClampToEdge);
depthStencil.setFilter(gl::Nearest, gl::Nearest, gl::MipNone);

target.configure(&color, &depthStencil);
try
{
// We'd like to use texture attachments for both color and depth/stencil.
target.configure(&color, &depthStencil);
}
catch(GLTarget::ConfigError const &er)
{
// Alternatively try without depth/stencil texture (some renderer features
// will not be available!).
LOG_WARNING("Texture-based framebuffer failed:\n %s\n"
"Trying fallback without depth/stencil texture")
<< er.asText();

target.configure(GLTarget::Color, color, GLTarget::DepthStencil);
}

target.clear(GLTarget::ColorDepthStencil);

if(isMultisampled())
Expand Down Expand Up @@ -245,6 +261,8 @@ void GLFramebuffer::glInit()
{
if(isReady()) return;

LOG_AS("GLFramebuffer");

d->alloc();
setState(Ready);

Expand All @@ -266,7 +284,7 @@ void GLFramebuffer::setSampleCount(int sampleCount)

if(d->_samples != sampleCount)
{
qDebug() << "GLFramebuffer: Sample count changed to" << sampleCount;
LOG_AS("GLFramebuffer");

d->_samples = sampleCount;
d->reconfigure();
Expand Down

0 comments on commit d57f2dc

Please sign in to comment.