Fix X11 OpenGL support

This commit is contained in:
Grim Maple 2022-10-25 18:54:45 +03:00
parent af36d0d76c
commit 65d74b2945
2 changed files with 29 additions and 20 deletions

View File

@ -120,13 +120,15 @@
}, },
{ {
"name": "x11", "name": "x11",
"versions": ["USE_X11", "USE_FREETYPE", "EmbedStandardResources", "GL_32"], "versions": ["USE_X11", "USE_FREETYPE", "EmbedStandardResources", "USE_OPENGL", "GL_32"],
"versions-windows": ["Unicode"], "versions-windows": ["Unicode"],
"libs-posix": ["GLX"],
"dependencies": { "dependencies": {
"bindbc-opengl": "~>1.0.0", "bindbc-opengl": "~>1.0.0",
"bindbc-freetype": "~>1.0.0", "bindbc-freetype": "~>1.0.0",
"x11": "~>1.0.21", "x11": "~>1.0.21",
"icontheme": "~>1.2.3" "icontheme": "~>1.2.3",
"glx-d": "~>1.0.0"
} }
}, },
{ {

View File

@ -28,13 +28,12 @@ import x11.Xatom;
import x11.X; import x11.X;
static if (ENABLE_OPENGL) { static if (ENABLE_OPENGL) {
import derelict.opengl3.gl3; import bindbc.opengl;
import derelict.opengl3.gl;
import dlangui.graphics.gldrawbuf; import dlangui.graphics.gldrawbuf;
import dlangui.graphics.glsupport; import dlangui.graphics.glsupport;
import derelict.opengl3.glx; import glx.glx;
private __gshared derelict.util.xtypes.XVisualInfo * x11visual; private __gshared XVisualInfo * x11visual;
private __gshared Colormap x11cmap; private __gshared Colormap x11cmap;
private __gshared bool _gl3Reloaded = false; private __gshared bool _gl3Reloaded = false;
} }
@ -1292,6 +1291,8 @@ private immutable int TIMER_EVENT = 8;
class X11Platform : Platform { class X11Platform : Platform {
this() { this() {
static if(ENABLE_OPENGL)
_enableOpengl = true;
import std.file : thisExePath; import std.file : thisExePath;
import std.path : baseName; import std.path : baseName;
_classname = (baseName(thisExePath()) ~ "\0").dup.ptr; _classname = (baseName(thisExePath()) ~ "\0").dup.ptr;
@ -1947,10 +1948,15 @@ extern(C) int DLANGUImain(string[] args)
static if (ENABLE_OPENGL) { static if (ENABLE_OPENGL) {
try { try {
DerelictGL3.missingSymbolCallback = &gl3MissingSymFunc; import bindbc.opengl : GLVersion = GLSupport;
DerelictGL3.load(); GLVersion support = loadOpenGL();
DerelictGL.missingSymbolCallback = &gl3MissingSymFunc; if(support == GLVersion.badLibrary)
DerelictGL.load(); {
_enableOpengl = false;
Log.e("Error loading OpenGL library");
}
else
{
Log.d("OpenGL library loaded ok"); Log.d("OpenGL library loaded ok");
GLint[] att = [ GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_DOUBLEBUFFER, None ]; GLint[] att = [ GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_DOUBLEBUFFER, None ];
XWindow root; XWindow root;
@ -1962,6 +1968,7 @@ extern(C) int DLANGUImain(string[] args)
} else { } else {
Log.e("Cannot find suitable Visual for using of OpenGL"); Log.e("Cannot find suitable Visual for using of OpenGL");
} }
}
} catch (Exception e) { } catch (Exception e) {
Log.e("Cannot load OpenGL library", e); Log.e("Cannot load OpenGL library", e);
} }