gdkglcontext: Track whether to use GL_TEXTURE_2D or GL_TEXTURE_RECTANGL_ARB

This commit is contained in:
Alexander Larsson 2014-10-27 21:12:40 +01:00
parent 5f40f58c36
commit 72a6459d73
3 changed files with 40 additions and 0 deletions

View File

@ -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

View File

@ -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);
}
/**

View File

@ -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);