[gtk+/wip/ebassi/gles: 3/17] gl: Use the appropriate format on GLES



commit a2d46976765c4d0bcc7fc334d706942971e56065
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Sat Apr 23 10:21:13 2016 +0100

    gl: Use the appropriate format on GLES
    
    When uploading a Cairo image surface to a GL texture we cannot use
    GL_BGRA and GL_UNSIGNED_INT_8_8_8_8_REV on OpenGL ES, as they do not
    exist in the core spec.

 gdk/gdkglcontext.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/gdk/gdkglcontext.c b/gdk/gdkglcontext.c
index 8eb39f1..ca29955 100644
--- a/gdk/gdkglcontext.c
+++ b/gdk/gdkglcontext.c
@@ -248,12 +248,20 @@ gdk_gl_context_upload_texture (GdkGLContext    *context,
   /* GL_UNPACK_ROW_LENGTH is available on desktop GL, OpenGL ES >= 3.0, or if
    * the GL_EXT_unpack_subimage extension for OpenGL ES 2.0 is available
    */
-  if (epoxy_is_desktop_gl () || priv->gl_version >= 30 || priv->has_unpack_subimage)
+  if (!gdk_gl_context_get_use_es (context) ||
+      (gdk_gl_context_get_use_es (context) &&
+       (priv->gl_version >= 30 || priv->has_unpack_subimage)))
     {
       glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
       glPixelStorei (GL_UNPACK_ROW_LENGTH, cairo_image_surface_get_stride (image_surface) / 4);
-      glTexImage2D (texture_target, 0, GL_RGBA, width, height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
-                    cairo_image_surface_get_data (image_surface));
+
+      if (gdk_gl_context_get_use_es (context))
+        glTexImage2D (texture_target, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE,
+                      cairo_image_surface_get_data (image_surface));
+      else
+        glTexImage2D (texture_target, 0, GL_RGBA, width, height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
+                      cairo_image_surface_get_data (image_surface));
+
       glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
     }
   else


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]