A bit more work toward trying to get a framebuffer without color attachment

This commit is contained in:
rdb 2013-08-15 09:06:58 +00:00
parent a343eef6b1
commit ef9e2def2e
2 changed files with 27 additions and 19 deletions

View File

@ -1100,8 +1100,15 @@ open_buffer() {
// Rounding the depth bits is not spectacular, but at least we're // Rounding the depth bits is not spectacular, but at least we're
// telling the user *something* about what we're going to get. // telling the user *something* about what we're going to get.
// Temporary bug workaround: it seems that my Intel HD Graphics 4000 // A lot of code seems to depend on being able to get a
// does not like our FBO if we don't have a colour attachment. // 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) { if (_fb_properties.get_color_bits() == 0) {
_fb_properties.set_color_bits(1); _fb_properties.set_color_bits(1);
} }

View File

@ -1939,15 +1939,17 @@ clear(DrawableRegion *clearable) {
} }
} }
if (clearable->get_clear_color_active()) { if (_current_properties->get_color_bits() > 0) {
LColor v = clearable->get_clear_color(); if (clearable->get_clear_color_active()) {
GLP(ClearColor)(v[0],v[1],v[2],v[3]); LColor v = clearable->get_clear_color();
if (CLP(color_mask)) { GLP(ClearColor)(v[0],v[1],v[2],v[3]);
GLP(ColorMask)(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 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()) { if (clearable->get_clear_depth_active()) {
@ -5838,27 +5840,26 @@ set_draw_buffer(int rbtype) {
GLuint buffers[16]; GLuint buffers[16];
int nbuffers=0; int nbuffers=0;
if (rbtype & RenderBuffer::T_color) { int index = 0;
buffers[nbuffers++] = GL_COLOR_ATTACHMENT0_EXT; 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++) { for (int i=0; i<_current_properties->get_aux_rgba(); i++) {
if (rbtype & (RenderBuffer::T_aux_rgba_0 << 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++) { for (int i=0; i<_current_properties->get_aux_hrgba(); i++) {
if (rbtype & (RenderBuffer::T_aux_hrgba_0 << 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++) { for (int i=0; i<_current_properties->get_aux_float(); i++) {
if (rbtype & (RenderBuffer::T_aux_float_0 << 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); _glDrawBuffers(nbuffers, buffers);