gl: Do not use deprecated constants with the GL3 driver

glGetIntegerv (GL_DEPTH_BITS, ...) and friends are deprecated in GL3; we
have to use glGetFramebufferAttachmentParameteriv() instead, like we do
for offscreen framebuffers.

Based on a patch by: Adel Gadllah <adel.gadllah@gmail.com>
Signed-off-by: Emmanuele Bassi <ebassi@gnome.org>

https://bugzilla.gnome.org/show_bug.cgi?id=753295
This commit is contained in:
Emmanuele Bassi 2015-08-06 12:19:52 +01:00
parent e7f54e6e60
commit f20cc24292

View File

@ -1037,29 +1037,35 @@ _cogl_framebuffer_init_bits (CoglFramebuffer *framebuffer)
COGL_FRAMEBUFFER_STATE_BIND); COGL_FRAMEBUFFER_STATE_BIND);
#ifdef HAVE_COGL_GL #ifdef HAVE_COGL_GL
if (_cogl_has_private_feature if ((ctx->driver == COGL_DRIVER_GL3 &&
(ctx, COGL_PRIVATE_FEATURE_QUERY_FRAMEBUFFER_BITS) && framebuffer->type == COGL_FRAMEBUFFER_TYPE_ONSCREEN) ||
framebuffer->type == COGL_FRAMEBUFFER_TYPE_OFFSCREEN) (_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_QUERY_FRAMEBUFFER_BITS) &&
framebuffer->type == COGL_FRAMEBUFFER_TYPE_OFFSCREEN))
{ {
static const struct gboolean is_offscreen = framebuffer->type == COGL_FRAMEBUFFER_TYPE_OFFSCREEN;
{ const struct {
GLenum attachment, pname; GLenum attachment, pname;
size_t offset; size_t offset;
} params[] = } params[] = {
{ { is_offscreen ? GL_COLOR_ATTACHMENT0 : GL_BACK_LEFT,
{ GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE, GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE,
offsetof (CoglFramebufferBits, red) }, offsetof (CoglFramebufferBits, red) },
{ GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE, { is_offscreen ? GL_COLOR_ATTACHMENT0 : GL_BACK_LEFT,
offsetof (CoglFramebufferBits, green) }, GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE,
{ GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE, offsetof (CoglFramebufferBits, green) },
offsetof (CoglFramebufferBits, blue) }, { is_offscreen ? GL_COLOR_ATTACHMENT0 : GL_BACK_LEFT,
{ GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE, GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE,
offsetof (CoglFramebufferBits, alpha) }, offsetof (CoglFramebufferBits, blue) },
{ GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE, { is_offscreen ? GL_COLOR_ATTACHMENT0 : GL_BACK_LEFT,
offsetof (CoglFramebufferBits, depth) }, GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE,
{ GL_STENCIL_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE, offsetof (CoglFramebufferBits, alpha) },
offsetof (CoglFramebufferBits, stencil) }, { is_offscreen ? GL_DEPTH_ATTACHMENT : GL_DEPTH,
}; GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE,
offsetof (CoglFramebufferBits, depth) },
{ is_offscreen ? GL_STENCIL_ATTACHMENT : GL_STENCIL,
GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE,
offsetof (CoglFramebufferBits, stencil) },
};
int i; int i;
for (i = 0; i < G_N_ELEMENTS (params); i++) for (i = 0; i < G_N_ELEMENTS (params); i++)