[gl] Use GLEW to detect required extension presence.

This commit is contained in:
Eric Anholt 2009-03-28 20:59:01 -07:00
parent 2df498ba45
commit 93c437d4b9
2 changed files with 22 additions and 0 deletions

View file

@ -196,6 +196,15 @@ CAIRO_ENABLE_SURFACE_BACKEND(gl, gl, no, [
gl_REQUIRES="gl" gl_REQUIRES="gl"
PKG_CHECK_MODULES(gl, $gl_REQUIRES, , [AC_MSG_RESULT(no) PKG_CHECK_MODULES(gl, $gl_REQUIRES, , [AC_MSG_RESULT(no)
use_gl="no (requires gl.pc)"]) use_gl="no (requires gl.pc)"])
AC_CHECK_LIB(GLEW, glewInit, [
AC_CHECK_HEADER(GL/glew.h, [], [
have_gl="no (requires glew http://glew.sourceforge.net/)"
])
], [
have_gl="no (requires glew http://glew.sourceforge.net/)"
])
gl_NONPKGCONFIG_LIBS="-lGLEW"
]) ])
dnl =========================================================================== dnl ===========================================================================

View file

@ -38,6 +38,7 @@
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <GL/glew.h>
#define GL_GLEXT_PROTOTYPES #define GL_GLEXT_PROTOTYPES
#include <GL/glx.h> #include <GL/glx.h>
#include <GL/glext.h> #include <GL/glext.h>
@ -127,6 +128,7 @@ cairo_gl_context_t *
cairo_gl_glx_context_create (Display *dpy, GLXContext gl_ctx) cairo_gl_glx_context_create (Display *dpy, GLXContext gl_ctx)
{ {
cairo_gl_context_t *ctx; cairo_gl_context_t *ctx;
GLenum err;
ctx = calloc (1, sizeof(cairo_gl_context_t)); ctx = calloc (1, sizeof(cairo_gl_context_t));
if (ctx == NULL) if (ctx == NULL)
@ -143,6 +145,17 @@ cairo_gl_glx_context_create (Display *dpy, GLXContext gl_ctx)
*/ */
glXMakeCurrent(dpy, RootWindow (dpy, DefaultScreen (dpy)), gl_ctx); glXMakeCurrent(dpy, RootWindow (dpy, DefaultScreen (dpy)), gl_ctx);
err = glewInit();
if (err != GLEW_OK) {
free(ctx);
return NULL;
}
if (!GLEW_EXT_framebuffer_object || !GLEW_ARB_texture_env_combine) {
free(ctx);
return NULL;
}
/* Set up the dummy texture for tex_env_combine with constant color. */ /* Set up the dummy texture for tex_env_combine with constant color. */
glGenTextures (1, &ctx->dummy_tex); glGenTextures (1, &ctx->dummy_tex);
glBindTexture (GL_TEXTURE_2D, ctx->dummy_tex); glBindTexture (GL_TEXTURE_2D, ctx->dummy_tex);