[gtk+] gdkglcontext: Track whether to use GL_TEXTURE_2D or GL_TEXTURE_RECTANGL_ARB
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] gdkglcontext: Track whether to use GL_TEXTURE_2D or GL_TEXTURE_RECTANGL_ARB
- Date: Mon, 27 Oct 2014 20:17:23 +0000 (UTC)
commit 72a6459d73ed2af6cc032a7fc0c1704c9ed6faba
Author: Alexander Larsson <alexl redhat com>
Date: Mon Oct 27 21:12:40 2014 +0100
gdkglcontext: Track whether to use GL_TEXTURE_2D or GL_TEXTURE_RECTANGL_ARB
gdk/gdkdisplayprivate.h | 3 +++
gdk/gdkglcontext.c | 36 ++++++++++++++++++++++++++++++++++++
gdk/gdkglcontextprivate.h | 1 +
3 files changed, 40 insertions(+), 0 deletions(-)
---
diff --git a/gdk/gdkdisplayprivate.h b/gdk/gdkdisplayprivate.h
index 0cd45f8..6bd87d1 100644
--- a/gdk/gdkdisplayprivate.h
+++ b/gdk/gdkdisplayprivate.h
@@ -116,6 +116,9 @@ struct _GdkDisplay
guint double_click_time; /* Maximum time between clicks in msecs */
guint double_click_distance; /* Maximum distance between clicks in pixels */
+
+ guint has_gl_extension_texture_non_power_of_two : 1;
+ guint has_gl_extension_texture_rectangle : 1;
};
struct _GdkDisplayClass
diff --git a/gdk/gdkglcontext.c b/gdk/gdkglcontext.c
index 1bfb17f..f1e8740 100644
--- a/gdk/gdkglcontext.c
+++ b/gdk/gdkglcontext.c
@@ -77,9 +77,15 @@
#include "gdkintl.h"
+#include <epoxy/gl.h>
+
typedef struct {
GdkWindow *window;
GdkVisual *visual;
+
+ guint realized : 1;
+ guint use_texture_rectangle : 1;
+
} GdkGLContextPrivate;
enum {
@@ -265,6 +271,33 @@ gdk_gl_context_end_frame (GdkGLContext *context,
GDK_GL_CONTEXT_GET_CLASS (context)->end_frame (context, painted, damage);
}
+gboolean
+gdk_gl_context_use_texture_rectangle (GdkGLContext *context)
+{
+ GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
+
+ return priv->use_texture_rectangle;
+}
+
+static void
+gdk_gl_context_realize (GdkGLContext *context)
+{
+ GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
+ gboolean has_npot, has_texture_rectangle;
+
+ has_npot = epoxy_has_gl_extension ("GL_ARB_texture_non_power_of_two");
+ has_texture_rectangle = epoxy_has_gl_extension ("GL_ARB_texture_rectangle");
+
+ if (has_npot)
+ priv->use_texture_rectangle = FALSE;
+ else if (has_texture_rectangle)
+ priv->use_texture_rectangle = TRUE;
+ else
+ g_warning ("Gl implementation doesn't support any form of non-power-of-two textures");
+
+ priv->realized = TRUE;
+}
+
/**
* gdk_gl_context_make_current:
* @context: a #GdkGLContext
@@ -281,6 +314,9 @@ gdk_gl_context_make_current (GdkGLContext *context)
g_return_if_fail (GDK_IS_GL_CONTEXT (context));
gdk_display_make_gl_context_current (gdk_window_get_display (priv->window), context);
+
+ if (!priv->realized)
+ gdk_gl_context_realize (context);
}
/**
diff --git a/gdk/gdkglcontextprivate.h b/gdk/gdkglcontextprivate.h
index 96d4924..c7b6937 100644
--- a/gdk/gdkglcontextprivate.h
+++ b/gdk/gdkglcontextprivate.h
@@ -49,6 +49,7 @@ struct _GdkGLContextClass
cairo_region_t *region);
};
+gboolean gdk_gl_context_use_texture_rectangle (GdkGLContext *context);
void gdk_gl_context_end_frame (GdkGLContext *context,
cairo_region_t *painted,
cairo_region_t *damage);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]