|
@@ -116,9 +116,14 @@ Error ContextGL_X11::initialize() {
|
|
|
};
|
|
|
|
|
|
int fbcount;
|
|
|
- GLXFBConfig fbconfig;
|
|
|
+ GLXFBConfig fbconfig = 0;
|
|
|
XVisualInfo *vi = NULL;
|
|
|
|
|
|
+ XSetWindowAttributes swa;
|
|
|
+ swa.event_mask = StructureNotifyMask;
|
|
|
+ swa.border_pixel = 0;
|
|
|
+ unsigned long valuemask = CWBorderPixel | CWColormap | CWEventMask;
|
|
|
+
|
|
|
if (OS::get_singleton()->is_layered_allowed()) {
|
|
|
GLXFBConfig *fbc = glXChooseFBConfig(x11_display, DefaultScreen(x11_display), visual_attribs_layered, &fbcount);
|
|
|
ERR_FAIL_COND_V(!fbc, ERR_UNCONFIGURED);
|
|
@@ -142,16 +147,10 @@ Error ContextGL_X11::initialize() {
|
|
|
}
|
|
|
ERR_FAIL_COND_V(!fbconfig, ERR_UNCONFIGURED);
|
|
|
|
|
|
- XSetWindowAttributes swa;
|
|
|
-
|
|
|
- swa.colormap = XCreateColormap(x11_display, RootWindow(x11_display, vi->screen), vi->visual, AllocNone);
|
|
|
- swa.border_pixel = 0;
|
|
|
swa.background_pixmap = None;
|
|
|
swa.background_pixel = 0;
|
|
|
swa.border_pixmap = None;
|
|
|
- swa.event_mask = StructureNotifyMask;
|
|
|
-
|
|
|
- x11_window = XCreateWindow(x11_display, RootWindow(x11_display, vi->screen), 0, 0, OS::get_singleton()->get_video_mode().width, OS::get_singleton()->get_video_mode().height, 0, vi->depth, InputOutput, vi->visual, CWBorderPixel | CWColormap | CWEventMask | CWBackPixel, &swa);
|
|
|
+ valuemask |= CWBackPixel;
|
|
|
|
|
|
} else {
|
|
|
GLXFBConfig *fbc = glXChooseFBConfig(x11_display, DefaultScreen(x11_display), visual_attribs, &fbcount);
|
|
@@ -160,42 +159,21 @@ Error ContextGL_X11::initialize() {
|
|
|
vi = glXGetVisualFromFBConfig(x11_display, fbc[0]);
|
|
|
|
|
|
fbconfig = fbc[0];
|
|
|
-
|
|
|
- XSetWindowAttributes swa;
|
|
|
-
|
|
|
- swa.colormap = XCreateColormap(x11_display, RootWindow(x11_display, vi->screen), vi->visual, AllocNone);
|
|
|
- swa.border_pixel = 0;
|
|
|
- swa.event_mask = StructureNotifyMask;
|
|
|
-
|
|
|
- x11_window = XCreateWindow(x11_display, RootWindow(x11_display, vi->screen), 0, 0, OS::get_singleton()->get_video_mode().width, OS::get_singleton()->get_video_mode().height, 0, vi->depth, InputOutput, vi->visual, CWBorderPixel | CWColormap | CWEventMask, &swa);
|
|
|
}
|
|
|
|
|
|
- ERR_FAIL_COND_V(!x11_window, ERR_UNCONFIGURED);
|
|
|
- set_class_hint(x11_display, x11_window);
|
|
|
- XMapWindow(x11_display, x11_window);
|
|
|
-
|
|
|
- int (*oldHandler)(Display *, XErrorEvent *) =
|
|
|
- XSetErrorHandler(&ctxErrorHandler);
|
|
|
+ int (*oldHandler)(Display *, XErrorEvent *) = XSetErrorHandler(&ctxErrorHandler);
|
|
|
|
|
|
switch (context_type) {
|
|
|
- case GLES_2_0_COMPATIBLE:
|
|
|
case OLDSTYLE: {
|
|
|
+
|
|
|
p->glx_context = glXCreateContext(x11_display, vi, 0, GL_TRUE);
|
|
|
+ ERR_FAIL_COND_V(!p->glx_context, ERR_UNCONFIGURED);
|
|
|
} break;
|
|
|
- /*
|
|
|
- case ContextType::GLES_2_0_COMPATIBLE: {
|
|
|
-
|
|
|
- static int context_attribs[] = {
|
|
|
- GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
|
|
|
- GLX_CONTEXT_MINOR_VERSION_ARB, 0,
|
|
|
- None
|
|
|
- };
|
|
|
+ case GLES_2_0_COMPATIBLE: {
|
|
|
|
|
|
- p->glx_context = glXCreateContextAttribsARB(x11_display, fbconfig, NULL, true, context_attribs);
|
|
|
- ERR_EXPLAIN("Could not obtain an OpenGL 3.0 context!");
|
|
|
+ p->glx_context = glXCreateNewContext(x11_display, fbconfig, GLX_RGBA_TYPE, 0, true);
|
|
|
ERR_FAIL_COND_V(!p->glx_context, ERR_UNCONFIGURED);
|
|
|
} break;
|
|
|
- */
|
|
|
case GLES_3_0_COMPATIBLE: {
|
|
|
|
|
|
static int context_attribs[] = {
|
|
@@ -207,24 +185,22 @@ Error ContextGL_X11::initialize() {
|
|
|
};
|
|
|
|
|
|
p->glx_context = glXCreateContextAttribsARB(x11_display, fbconfig, NULL, true, context_attribs);
|
|
|
- ERR_EXPLAIN("Could not obtain an OpenGL 3.3 context!");
|
|
|
ERR_FAIL_COND_V(ctxErrorOccurred || !p->glx_context, ERR_UNCONFIGURED);
|
|
|
} break;
|
|
|
}
|
|
|
|
|
|
+ swa.colormap = XCreateColormap(x11_display, RootWindow(x11_display, vi->screen), vi->visual, AllocNone);
|
|
|
+ x11_window = XCreateWindow(x11_display, RootWindow(x11_display, vi->screen), 0, 0, OS::get_singleton()->get_video_mode().width, OS::get_singleton()->get_video_mode().height, 0, vi->depth, InputOutput, vi->visual, valuemask, &swa);
|
|
|
+
|
|
|
+ ERR_FAIL_COND_V(!x11_window, ERR_UNCONFIGURED);
|
|
|
+ set_class_hint(x11_display, x11_window);
|
|
|
+ XMapWindow(x11_display, x11_window);
|
|
|
+
|
|
|
XSync(x11_display, False);
|
|
|
XSetErrorHandler(oldHandler);
|
|
|
|
|
|
glXMakeCurrent(x11_display, x11_window, p->glx_context);
|
|
|
|
|
|
- /*
|
|
|
- glWrapperInit(wrapper_get_proc_address);
|
|
|
- glFlush();
|
|
|
-
|
|
|
- glXSwapBuffers(x11_display,x11_window);
|
|
|
-*/
|
|
|
- //glXMakeCurrent(x11_display, None, NULL);
|
|
|
-
|
|
|
XFree(vi);
|
|
|
|
|
|
return OK;
|
|
@@ -297,7 +273,6 @@ ContextGL_X11::ContextGL_X11(::Display *p_x11_display, ::Window &p_x11_window, c
|
|
|
ContextGL_X11::~ContextGL_X11() {
|
|
|
release_current();
|
|
|
glXDestroyContext(x11_display, p->glx_context);
|
|
|
-
|
|
|
memdelete(p);
|
|
|
}
|
|
|
|