[gtk/wip/ebassi/gdk-egl-x11-v2: 1/7] Use the generic names for glFramebuffer functions
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/ebassi/gdk-egl-x11-v2: 1/7] Use the generic names for glFramebuffer functions
- Date: Thu, 18 Jul 2019 18:12:13 +0000 (UTC)
commit ca1b5b53eb6754ae8d8bc60a70caeb6fb9f75ff4
Author: Emmanuele Bassi <ebassi gnome org>
Date: Fri Dec 16 14:47:07 2016 +0000
Use the generic names for glFramebuffer functions
We can rely on libepoxy to resolve them using the appropriate function
names from extensions, if we're running on legacy platforms.
gdk/gdkgl.c | 12 ++++----
gtk/gtkglarea.c | 85 +++++++++++++++++++++++++++++++--------------------------
2 files changed, 52 insertions(+), 45 deletions(-)
---
diff --git a/gdk/gdkgl.c b/gdk/gdkgl.c
index 933e204439..be24be7e9f 100644
--- a/gdk/gdkgl.c
+++ b/gdk/gdkgl.c
@@ -671,19 +671,19 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
cairo_surface_set_device_scale (image, buffer_scale, buffer_scale);
framebuffer = paint_data->tmp_framebuffer;
- glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, framebuffer);
+ glBindFramebuffer (GL_FRAMEBUFFER, framebuffer);
if (source_type == GL_RENDERBUFFER)
{
/* Create a framebuffer with the source renderbuffer and
make it the current target for reads */
- glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
- GL_RENDERBUFFER_EXT, source);
+ glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+ GL_RENDERBUFFER, source);
}
else
{
- glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
- GL_TEXTURE_2D, source, 0);
+ glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+ GL_TEXTURE_2D, source, 0);
}
glPixelStorei (GL_PACK_ALIGNMENT, 4);
@@ -699,7 +699,7 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
glPixelStorei (GL_PACK_ROW_LENGTH, 0);
- glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0);
+ glBindFramebuffer (GL_FRAMEBUFFER_EXT, 0);
cairo_surface_mark_dirty (image);
diff --git a/gtk/gtkglarea.c b/gtk/gtkglarea.c
index 9a56443725..322626930f 100644
--- a/gtk/gtkglarea.c
+++ b/gtk/gtkglarea.c
@@ -391,7 +391,7 @@ gtk_gl_area_ensure_buffers (GtkGLArea *area)
priv->have_buffers = TRUE;
- glGenFramebuffersEXT (1, &priv->frame_buffer);
+ glGenFramebuffers (1, &priv->frame_buffer);
if (priv->has_alpha)
{
@@ -402,7 +402,7 @@ gtk_gl_area_ensure_buffers (GtkGLArea *area)
/* Delete old render buffer if any */
if (priv->render_buffer != 0)
{
- glDeleteRenderbuffersEXT(1, &priv->render_buffer);
+ glDeleteRenderbuffers(1, &priv->render_buffer);
priv->render_buffer = 0;
}
}
@@ -410,7 +410,7 @@ gtk_gl_area_ensure_buffers (GtkGLArea *area)
{
/* For non-alpha we use render buffers so we can blit instead of texture the result */
if (priv->render_buffer == 0)
- glGenRenderbuffersEXT (1, &priv->render_buffer);
+ glGenRenderbuffers (1, &priv->render_buffer);
/* Delete old texture if any */
if (priv->texture != 0)
@@ -423,12 +423,12 @@ gtk_gl_area_ensure_buffers (GtkGLArea *area)
if ((priv->has_depth_buffer || priv->has_stencil_buffer))
{
if (priv->depth_stencil_buffer == 0)
- glGenRenderbuffersEXT (1, &priv->depth_stencil_buffer);
+ glGenRenderbuffers (1, &priv->depth_stencil_buffer);
}
else if (priv->depth_stencil_buffer != 0)
{
/* Delete old depth/stencil buffer */
- glDeleteRenderbuffersEXT (1, &priv->depth_stencil_buffer);
+ glDeleteRenderbuffers (1, &priv->depth_stencil_buffer);
priv->depth_stencil_buffer = 0;
}
@@ -515,23 +515,23 @@ gtk_gl_area_attach_buffers (GtkGLArea *area)
else if (priv->needs_resize)
gtk_gl_area_allocate_buffers (area);
- glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, priv->frame_buffer);
+ glBindFramebuffer (GL_FRAMEBUFFER, priv->frame_buffer);
if (priv->texture)
- glFramebufferTexture2D (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
+ glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, priv->texture, 0);
else if (priv->render_buffer)
- glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
- GL_RENDERBUFFER_EXT, priv->render_buffer);
+ glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+ GL_RENDERBUFFER, priv->render_buffer);
if (priv->depth_stencil_buffer)
{
if (priv->has_depth_buffer)
- glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
- GL_RENDERBUFFER_EXT, priv->depth_stencil_buffer);
+ glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
+ GL_RENDERBUFFER, priv->depth_stencil_buffer);
if (priv->has_stencil_buffer)
- glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT,
- GL_RENDERBUFFER_EXT, priv->depth_stencil_buffer);
+ glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
+ GL_RENDERBUFFER, priv->depth_stencil_buffer);
}
}
@@ -547,7 +547,7 @@ gtk_gl_area_delete_buffers (GtkGLArea *area)
if (priv->render_buffer != 0)
{
- glDeleteRenderbuffersEXT (1, &priv->render_buffer);
+ glDeleteRenderbuffers (1, &priv->render_buffer);
priv->render_buffer = 0;
}
@@ -559,14 +559,14 @@ gtk_gl_area_delete_buffers (GtkGLArea *area)
if (priv->depth_stencil_buffer != 0)
{
- glDeleteRenderbuffersEXT (1, &priv->depth_stencil_buffer);
+ glDeleteRenderbuffers (1, &priv->depth_stencil_buffer);
priv->depth_stencil_buffer = 0;
}
if (priv->frame_buffer != 0)
{
- glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0);
- glDeleteFramebuffersEXT (1, &priv->frame_buffer);
+ glBindFramebuffer (GL_FRAMEBUFFER, 0);
+ glDeleteFramebuffers (1, &priv->frame_buffer);
priv->frame_buffer = 0;
}
}
@@ -698,6 +698,21 @@ gtk_gl_area_draw (GtkWidget *widget,
gtk_gl_area_attach_buffers (area);
+ status = glCheckFramebufferStatus (GL_FRAMEBUFFER);
+ if (status != GL_FRAMEBUFFER_COMPLETE)
+ {
+ g_set_error_literal (&priv->error,
+ GDK_GL_ERROR, GDK_GL_ERROR_UNSUPPORTED_FORMAT,
+ "Unsupported framebuffer configuration");
+
+ gtk_gl_area_draw_error_screen (area,
+ cr,
+ gtk_widget_get_allocated_width (widget),
+ gtk_widget_get_allocated_height (widget));
+
+ return FALSE;
+ }
+
if (priv->has_depth_buffer)
glEnable (GL_DEPTH_TEST);
else
@@ -707,34 +722,26 @@ gtk_gl_area_draw (GtkWidget *widget,
w = gtk_widget_get_allocated_width (widget) * scale;
h = gtk_widget_get_allocated_height (widget) * scale;
- status = glCheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT);
- if (status == GL_FRAMEBUFFER_COMPLETE_EXT)
+ if (priv->needs_render || priv->auto_render)
{
- if (priv->needs_render || priv->auto_render)
+ if (priv->needs_resize)
{
- if (priv->needs_resize)
- {
- g_signal_emit (area, area_signals[RESIZE], 0, w, h, NULL);
- priv->needs_resize = FALSE;
- }
-
- g_signal_emit (area, area_signals[RENDER], 0, priv->context, &unused);
+ g_signal_emit (area, area_signals[RESIZE], 0, w, h, NULL);
+ priv->needs_resize = FALSE;
}
- priv->needs_render = FALSE;
-
- gdk_cairo_draw_from_gl (cr,
- gtk_widget_get_window (widget),
- priv->texture ? priv->texture : priv->render_buffer,
- priv->texture ? GL_TEXTURE : GL_RENDERBUFFER,
- scale, 0, 0, w, h);
- gtk_gl_area_make_current (area);
- }
- else
- {
- g_warning ("fb setup not supported");
+ g_signal_emit (area, area_signals[RENDER], 0, priv->context, &unused);
}
+ priv->needs_render = FALSE;
+
+ gdk_cairo_draw_from_gl (cr,
+ gtk_widget_get_window (widget),
+ priv->texture ? priv->texture : priv->render_buffer,
+ priv->texture ? GL_TEXTURE : GL_RENDERBUFFER,
+ scale, 0, 0, w, h);
+ gtk_gl_area_make_current (area);
+
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]