summaryrefslogtreecommitdiff
path: root/cogl/cogl-framebuffer.c
diff options
context:
space:
mode:
authorNeil Roberts <neil@linux.intel.com>2011-07-06 21:51:00 +0100
committerNeil Roberts <neil@linux.intel.com>2011-07-08 15:35:46 +0100
commit2b119b07da34f7aad987f032fb0987af9e7fbac6 (patch)
tree79466967949021f50e714a5d96d824dec61f7dc5 /cogl/cogl-framebuffer.c
parentdae02a99a5c8c5f17188a0efb60eb8555e3e471f (diff)
downloadcogl-2b119b07da34f7aad987f032fb0987af9e7fbac6.tar.gz
Use all core GL functions through indirect pointers
cogl-ext-functions.h now contains definitions for all of the core GL and GLES functions that we would normally link to directly. All of the code has changed to access them through the cogl context pointer. The GE macro now takes an extra parameter to specify the context because the macro itself needs to make GL calls but various points in the Cogl source use different names for the context variable.
Diffstat (limited to 'cogl/cogl-framebuffer.c')
-rw-r--r--cogl/cogl-framebuffer.c144
1 files changed, 64 insertions, 80 deletions
diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c
index e96f1f6d..d5b4ad43 100644
--- a/cogl/cogl-framebuffer.c
+++ b/cogl/cogl-framebuffer.c
@@ -40,25 +40,6 @@
#include "cogl-journal-private.h"
#include "cogl-winsys-private.h"
-#ifndef HAVE_COGL_GLES2
-
-#define glGenRenderbuffers ctx->glGenRenderbuffers
-#define glDeleteRenderbuffers ctx->glDeleteRenderbuffers
-#define glBindRenderbuffer ctx->glBindRenderbuffer
-#define glRenderbufferStorage ctx->glRenderbufferStorage
-#define glGenFramebuffers ctx->glGenFramebuffers
-#define glBindFramebuffer ctx->glBindFramebuffer
-#define glFramebufferTexture2D ctx->glFramebufferTexture2D
-#define glFramebufferRenderbuffer ctx->glFramebufferRenderbuffer
-#define glCheckFramebufferStatus ctx->glCheckFramebufferStatus
-#define glDeleteFramebuffers ctx->glDeleteFramebuffers
-#define glGetFramebufferAttachmentParameteriv \
- ctx->glGetFramebufferAttachmentParameteriv
-
-#endif
-
-#define glBlitFramebuffer ctx->glBlitFramebuffer
-
#ifndef GL_FRAMEBUFFER
#define GL_FRAMEBUFFER 0x8D40
#endif
@@ -252,9 +233,11 @@ _cogl_clear4f (unsigned long buffers,
{
GLbitfield gl_buffers = 0;
+ _COGL_GET_CONTEXT (ctx, NO_RETVAL);
+
if (buffers & COGL_BUFFER_BIT_COLOR)
{
- GE( glClearColor (red, green, blue, alpha) );
+ GE( ctx, glClearColor (red, green, blue, alpha) );
gl_buffers |= GL_COLOR_BUFFER_BIT;
}
@@ -277,7 +260,7 @@ _cogl_clear4f (unsigned long buffers,
return;
}
- GE (glClear (gl_buffers));
+ GE (ctx, glClear (gl_buffers));
}
void
@@ -626,9 +609,7 @@ _cogl_framebuffer_flush_dependency_journals (CoglFramebuffer *framebuffer)
static inline void
_cogl_framebuffer_init_bits (CoglFramebuffer *framebuffer)
{
-#ifdef HAVE_COGL_GL
CoglContext *ctx = framebuffer->context;
-#endif
if (G_LIKELY (!framebuffer->dirty_bitmasks))
return;
@@ -642,36 +623,39 @@ _cogl_framebuffer_init_bits (CoglFramebuffer *framebuffer)
attachment = GL_COLOR_ATTACHMENT0;
pname = GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE;
- GE( glGetFramebufferAttachmentParameteriv (GL_FRAMEBUFFER,
- attachment,
- pname,
- &framebuffer->red_bits) );
+ GE( ctx, glGetFramebufferAttachmentParameteriv (GL_FRAMEBUFFER,
+ attachment,
+ pname,
+ &framebuffer->red_bits) );
pname = GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE;
- GE( glGetFramebufferAttachmentParameteriv (GL_FRAMEBUFFER,
- attachment,
- pname,
- &framebuffer->green_bits) );
+ GE( ctx, glGetFramebufferAttachmentParameteriv (GL_FRAMEBUFFER,
+ attachment,
+ pname,
+ &framebuffer->green_bits)
+ );
pname = GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE;
- GE( glGetFramebufferAttachmentParameteriv (GL_FRAMEBUFFER,
- attachment,
- pname,
- &framebuffer->blue_bits) );
+ GE( ctx, glGetFramebufferAttachmentParameteriv (GL_FRAMEBUFFER,
+ attachment,
+ pname,
+ &framebuffer->blue_bits)
+ );
pname = GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE;
- GE( glGetFramebufferAttachmentParameteriv (GL_FRAMEBUFFER,
- attachment,
- pname,
- &framebuffer->alpha_bits) );
+ GE( ctx, glGetFramebufferAttachmentParameteriv (GL_FRAMEBUFFER,
+ attachment,
+ pname,
+ &framebuffer->alpha_bits)
+ );
}
else
#endif /* HAVE_COGL_GL */
{
- GE( glGetIntegerv (GL_RED_BITS, &framebuffer->red_bits) );
- GE( glGetIntegerv (GL_GREEN_BITS, &framebuffer->green_bits) );
- GE( glGetIntegerv (GL_BLUE_BITS, &framebuffer->blue_bits) );
- GE( glGetIntegerv (GL_ALPHA_BITS, &framebuffer->alpha_bits) );
+ GE( ctx, glGetIntegerv (GL_RED_BITS, &framebuffer->red_bits) );
+ GE( ctx, glGetIntegerv (GL_GREEN_BITS, &framebuffer->green_bits) );
+ GE( ctx, glGetIntegerv (GL_BLUE_BITS, &framebuffer->blue_bits) );
+ GE( ctx, glGetIntegerv (GL_ALPHA_BITS, &framebuffer->alpha_bits) );
}
@@ -729,28 +713,30 @@ try_creating_fbo (CoglOffscreen *offscreen,
ctx->dirty_bound_framebuffer = 1;
/* Generate framebuffer */
- glGenFramebuffers (1, &fbo_gl_handle);
- GE (glBindFramebuffer (GL_FRAMEBUFFER, fbo_gl_handle));
+ ctx->glGenFramebuffers (1, &fbo_gl_handle);
+ GE (ctx, glBindFramebuffer (GL_FRAMEBUFFER, fbo_gl_handle));
offscreen->fbo_handle = fbo_gl_handle;
- GE (glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
- tex_gl_target, tex_gl_handle, data->level));
+ GE (ctx, glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+ tex_gl_target, tex_gl_handle, data->level));
if (flags & _TRY_DEPTH_STENCIL)
{
/* Create a renderbuffer for depth and stenciling */
- GE (glGenRenderbuffers (1, &gl_depth_stencil_handle));
- GE (glBindRenderbuffer (GL_RENDERBUFFER, gl_depth_stencil_handle));
- GE (glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH_STENCIL,
- data->level_width,
- data->level_height));
- GE (glBindRenderbuffer (GL_RENDERBUFFER, 0));
- GE (glFramebufferRenderbuffer (GL_FRAMEBUFFER,
- GL_STENCIL_ATTACHMENT,
- GL_RENDERBUFFER, gl_depth_stencil_handle));
- GE (glFramebufferRenderbuffer (GL_FRAMEBUFFER,
- GL_DEPTH_ATTACHMENT,
- GL_RENDERBUFFER, gl_depth_stencil_handle));
+ GE (ctx, glGenRenderbuffers (1, &gl_depth_stencil_handle));
+ GE (ctx, glBindRenderbuffer (GL_RENDERBUFFER, gl_depth_stencil_handle));
+ GE (ctx, glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH_STENCIL,
+ data->level_width,
+ data->level_height));
+ GE (ctx, glBindRenderbuffer (GL_RENDERBUFFER, 0));
+ GE (ctx, glFramebufferRenderbuffer (GL_FRAMEBUFFER,
+ GL_STENCIL_ATTACHMENT,
+ GL_RENDERBUFFER,
+ gl_depth_stencil_handle));
+ GE (ctx, glFramebufferRenderbuffer (GL_FRAMEBUFFER,
+ GL_DEPTH_ATTACHMENT,
+ GL_RENDERBUFFER,
+ gl_depth_stencil_handle));
offscreen->renderbuffers =
g_slist_prepend (offscreen->renderbuffers,
GUINT_TO_POINTER (gl_depth_stencil_handle));
@@ -758,15 +744,15 @@ try_creating_fbo (CoglOffscreen *offscreen,
if (flags & _TRY_DEPTH)
{
- GE (glGenRenderbuffers (1, &gl_depth_handle));
- GE (glBindRenderbuffer (GL_RENDERBUFFER, gl_depth_handle));
+ GE (ctx, glGenRenderbuffers (1, &gl_depth_handle));
+ GE (ctx, glBindRenderbuffer (GL_RENDERBUFFER, gl_depth_handle));
/* For now we just ask for GL_DEPTH_COMPONENT16 since this is all that's
* available under GLES */
- GE (glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH_COMPONENT16,
+ GE (ctx, glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH_COMPONENT16,
data->level_width,
data->level_height));
- GE (glBindRenderbuffer (GL_RENDERBUFFER, 0));
- GE (glFramebufferRenderbuffer (GL_FRAMEBUFFER,
+ GE (ctx, glBindRenderbuffer (GL_RENDERBUFFER, 0));
+ GE (ctx, glFramebufferRenderbuffer (GL_FRAMEBUFFER,
GL_DEPTH_ATTACHMENT,
GL_RENDERBUFFER, gl_depth_handle));
offscreen->renderbuffers =
@@ -776,13 +762,13 @@ try_creating_fbo (CoglOffscreen *offscreen,
if (flags & _TRY_STENCIL)
{
- GE (glGenRenderbuffers (1, &gl_stencil_handle));
- GE (glBindRenderbuffer (GL_RENDERBUFFER, gl_stencil_handle));
- GE (glRenderbufferStorage (GL_RENDERBUFFER, GL_STENCIL_INDEX8,
+ GE (ctx, glGenRenderbuffers (1, &gl_stencil_handle));
+ GE (ctx, glBindRenderbuffer (GL_RENDERBUFFER, gl_stencil_handle));
+ GE (ctx, glRenderbufferStorage (GL_RENDERBUFFER, GL_STENCIL_INDEX8,
data->level_width,
data->level_height));
- GE (glBindRenderbuffer (GL_RENDERBUFFER, 0));
- GE (glFramebufferRenderbuffer (GL_FRAMEBUFFER,
+ GE (ctx, glBindRenderbuffer (GL_RENDERBUFFER, 0));
+ GE (ctx, glFramebufferRenderbuffer (GL_FRAMEBUFFER,
GL_STENCIL_ATTACHMENT,
GL_RENDERBUFFER, gl_stencil_handle));
offscreen->renderbuffers =
@@ -791,18 +777,18 @@ try_creating_fbo (CoglOffscreen *offscreen,
}
/* Make sure it's complete */
- status = glCheckFramebufferStatus (GL_FRAMEBUFFER);
+ status = ctx->glCheckFramebufferStatus (GL_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE)
{
GSList *l;
- GE (glDeleteFramebuffers (1, &fbo_gl_handle));
+ GE (ctx, glDeleteFramebuffers (1, &fbo_gl_handle));
for (l = offscreen->renderbuffers; l; l = l->next)
{
GLuint renderbuffer = GPOINTER_TO_UINT (l->data);
- GE (glDeleteRenderbuffers (1, &renderbuffer));
+ GE (ctx, glDeleteRenderbuffers (1, &renderbuffer));
}
g_slist_free (offscreen->renderbuffers);
@@ -941,9 +927,7 @@ static void
_cogl_offscreen_free (CoglOffscreen *offscreen)
{
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (offscreen);
-#ifndef HAVE_COGL_GLES2
CoglContext *ctx = framebuffer->context;
-#endif
GSList *l;
/* Chain up to parent */
@@ -952,11 +936,11 @@ _cogl_offscreen_free (CoglOffscreen *offscreen)
for (l = offscreen->renderbuffers; l; l = l->next)
{
GLuint renderbuffer = GPOINTER_TO_UINT (l->data);
- GE (glDeleteRenderbuffers (1, &renderbuffer));
+ GE (ctx, glDeleteRenderbuffers (1, &renderbuffer));
}
g_slist_free (offscreen->renderbuffers);
- GE (glDeleteFramebuffers (1, &offscreen->fbo_handle));
+ GE (ctx, glDeleteFramebuffers (1, &offscreen->fbo_handle));
if (offscreen->texture != COGL_INVALID_HANDLE)
cogl_handle_unref (offscreen->texture);
@@ -1368,7 +1352,7 @@ bind_gl_framebuffer (CoglContext *ctx,
CoglFramebuffer *framebuffer)
{
if (framebuffer->type == COGL_FRAMEBUFFER_TYPE_OFFSCREEN)
- GE (glBindFramebuffer (target,
+ GE (ctx, glBindFramebuffer (target,
COGL_OFFSCREEN (framebuffer)->fbo_handle));
else
{
@@ -1377,7 +1361,7 @@ bind_gl_framebuffer (CoglContext *ctx,
winsys->onscreen_bind (COGL_ONSCREEN (framebuffer));
/* glBindFramebuffer is an an extension with OpenGL ES 1.1 */
if (cogl_features_available (COGL_FEATURE_OFFSCREEN))
- GE (glBindFramebuffer (target, 0));
+ GE (ctx, glBindFramebuffer (target, 0));
}
}
@@ -1435,7 +1419,7 @@ _cogl_framebuffer_flush_state (CoglFramebuffer *draw_buffer,
draw_buffer->viewport_width,
draw_buffer->viewport_height);
- GE (glViewport (draw_buffer->viewport_x,
+ GE (ctx, glViewport (draw_buffer->viewport_x,
gl_viewport_y,
draw_buffer->viewport_width,
draw_buffer->viewport_height));
@@ -1596,7 +1580,7 @@ _cogl_blit_framebuffer (unsigned int src_x,
the scissor */
_cogl_clip_stack_flush (NULL);
- glBlitFramebuffer (src_x, src_y,
+ ctx->glBlitFramebuffer (src_x, src_y,
src_x + width, src_y + height,
dst_x, dst_y,
dst_x + width, dst_y + height,