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

View File

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