From ef9e2def2e021efdffdc4bc2c301dd3a6c3dc941 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 15 Aug 2013 09:06:58 +0000 Subject: [PATCH] A bit more work toward trying to get a framebuffer without color attachment --- panda/src/glstuff/glGraphicsBuffer_src.cxx | 11 ++++-- .../glstuff/glGraphicsStateGuardian_src.cxx | 35 ++++++++++--------- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/panda/src/glstuff/glGraphicsBuffer_src.cxx b/panda/src/glstuff/glGraphicsBuffer_src.cxx index df1be8b5ed..8e42dd8436 100644 --- a/panda/src/glstuff/glGraphicsBuffer_src.cxx +++ b/panda/src/glstuff/glGraphicsBuffer_src.cxx @@ -1100,8 +1100,15 @@ open_buffer() { // Rounding the depth bits is not spectacular, but at least we're // telling the user *something* about what we're going to get. - // Temporary bug workaround: it seems that my Intel HD Graphics 4000 - // does not like our FBO if we don't have a colour attachment. + // A lot of code seems to depend on being able to get a + // color buffer by just setting the rgb_color bit. + if (_fb_properties.get_color_bits() == 0 && + _fb_properties.get_rgb_color() > 0) { + _fb_properties.set_color_bits(1); + } + + // Actually, let's always get a colour buffer for now until we + // figure out why Intel HD Graphics cards complain otherwise. if (_fb_properties.get_color_bits() == 0) { _fb_properties.set_color_bits(1); } diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 533ac003d1..59822dfde9 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -1939,15 +1939,17 @@ clear(DrawableRegion *clearable) { } } - if (clearable->get_clear_color_active()) { - LColor v = clearable->get_clear_color(); - GLP(ClearColor)(v[0],v[1],v[2],v[3]); - if (CLP(color_mask)) { - GLP(ColorMask)(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + if (_current_properties->get_color_bits() > 0) { + if (clearable->get_clear_color_active()) { + LColor v = clearable->get_clear_color(); + GLP(ClearColor)(v[0],v[1],v[2],v[3]); + if (CLP(color_mask)) { + GLP(ColorMask)(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + } + _state_mask.clear_bit(ColorWriteAttrib::get_class_slot()); + mask |= GL_COLOR_BUFFER_BIT; + set_draw_buffer(clearable->get_draw_buffer_type()); } - _state_mask.clear_bit(ColorWriteAttrib::get_class_slot()); - mask |= GL_COLOR_BUFFER_BIT; - set_draw_buffer(clearable->get_draw_buffer_type()); } if (clearable->get_clear_depth_active()) { @@ -5838,27 +5840,26 @@ set_draw_buffer(int rbtype) { GLuint buffers[16]; int nbuffers=0; - if (rbtype & RenderBuffer::T_color) { - buffers[nbuffers++] = GL_COLOR_ATTACHMENT0_EXT; + int index = 0; + if (_current_properties->get_color_bits() > 0) { + if (rbtype & RenderBuffer::T_color) { + buffers[nbuffers++] = GL_COLOR_ATTACHMENT0_EXT + (index++); + } } - int index = 1; for (int i=0; i<_current_properties->get_aux_rgba(); i++) { if (rbtype & (RenderBuffer::T_aux_rgba_0 << i)) { - buffers[nbuffers++] = GL_COLOR_ATTACHMENT0_EXT + index; + buffers[nbuffers++] = GL_COLOR_ATTACHMENT0_EXT + (index++); } - index += 1; } for (int i=0; i<_current_properties->get_aux_hrgba(); i++) { if (rbtype & (RenderBuffer::T_aux_hrgba_0 << i)) { - buffers[nbuffers++] = GL_COLOR_ATTACHMENT0_EXT + index; + buffers[nbuffers++] = GL_COLOR_ATTACHMENT0_EXT + (index++); } - index += 1; } for (int i=0; i<_current_properties->get_aux_float(); i++) { if (rbtype & (RenderBuffer::T_aux_float_0 << i)) { - buffers[nbuffers++] = GL_COLOR_ATTACHMENT0_EXT + index; + buffers[nbuffers++] = GL_COLOR_ATTACHMENT0_EXT + (index++); } - index += 1; } _glDrawBuffers(nbuffers, buffers);