Support context creation on GLX 1.3.

This commit is contained in:
Brandon Wright 2018-10-27 15:12:21 -05:00
parent 752da257b8
commit dc3dd8e709
2 changed files with 17 additions and 2 deletions

View File

@ -12,6 +12,9 @@ GTKGLXContext::GTKGLXContext ()
display = NULL; display = NULL;
vi = NULL; vi = NULL;
context = NULL; context = NULL;
version_major = -1;
version_minor = -1;
} }
GTKGLXContext::~GTKGLXContext () GTKGLXContext::~GTKGLXContext ()
@ -32,7 +35,6 @@ bool GTKGLXContext::attach (GtkWidget *widget)
GdkWindow *window; GdkWindow *window;
GLXFBConfig *fbconfigs; GLXFBConfig *fbconfigs;
int num_fbconfigs; int num_fbconfigs;
int screen;
int attribs[] = { int attribs[] = {
GLX_DOUBLEBUFFER, True, GLX_DOUBLEBUFFER, True,
@ -55,6 +57,10 @@ bool GTKGLXContext::attach (GtkWidget *widget)
screen = gdk_x11_screen_get_screen_number (gdk_screen); screen = gdk_x11_screen_get_screen_number (gdk_screen);
display = GDK_DISPLAY_XDISPLAY (gdk_display); display = GDK_DISPLAY_XDISPLAY (gdk_display);
glXQueryVersion (display, &version_major, &version_minor);
if (version_major < 2 && version_minor < 3)
return false;
fbconfigs = glXChooseFBConfig (display, screen, attribs, &num_fbconfigs); fbconfigs = glXChooseFBConfig (display, screen, attribs, &num_fbconfigs);
if (!fbconfigs || num_fbconfigs < 1) if (!fbconfigs || num_fbconfigs < 1)
{ {
@ -89,7 +95,12 @@ bool GTKGLXContext::create_context ()
None None
}; };
const char *extensions = glXQueryExtensionsString (display, screen);
if (strstr (extensions, "GLX_ARB_create_context"))
context = glXCreateContextAttribsARB (display, fbconfig, NULL, True, context_attribs); context = glXCreateContextAttribsARB (display, fbconfig, NULL, True, context_attribs);
if (!context)
context = glXCreateNewContext (display, fbconfig, GLX_RGBA_TYPE, NULL, True);
if (!context) if (!context)
{ {

View File

@ -26,6 +26,10 @@ struct GTKGLXContext : OpenGLContext
GLXContext context; GLXContext context;
GLXFBConfig fbconfig; GLXFBConfig fbconfig;
Display *display; Display *display;
int screen;
XVisualInfo *vi; XVisualInfo *vi;
Window xid; Window xid;
int version_major;
int version_minor;
}; };