mirror of https://github.com/buggins/dlangui.git
Fix opengl support, switch to bindbc
This commit is contained in:
parent
352f7f94f2
commit
d19ff3c042
14
dub.json
14
dub.json
|
@ -29,6 +29,12 @@
|
||||||
"sourceFiles-windows-x86-dmd": ["$PACKAGE_DIR/src/win_app.def"],
|
"sourceFiles-windows-x86-dmd": ["$PACKAGE_DIR/src/win_app.def"],
|
||||||
"excludedSourceFiles-windows": ["3rdparty/fontconfig/*"],
|
"excludedSourceFiles-windows": ["3rdparty/fontconfig/*"],
|
||||||
|
|
||||||
|
"dependencies": {
|
||||||
|
"bindbc-opengl": "~>1.0.0"
|
||||||
|
},
|
||||||
|
|
||||||
|
"versions": ["GL_AllowDeprecated", "GL_30"],
|
||||||
|
|
||||||
"subPackages": [
|
"subPackages": [
|
||||||
"./examples/helloworld/",
|
"./examples/helloworld/",
|
||||||
"./examples/example1/",
|
"./examples/example1/",
|
||||||
|
@ -50,7 +56,6 @@
|
||||||
"versions-windows": ["Unicode"],
|
"versions-windows": ["Unicode"],
|
||||||
"libs-windows": ["opengl32"],
|
"libs-windows": ["opengl32"],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"derelict-gl3": "~>2.0.0-beta.8",
|
|
||||||
"derelict-ft": "~>2.0.0-beta.5",
|
"derelict-ft": "~>2.0.0-beta.5",
|
||||||
"icontheme": "~>1.2.3"
|
"icontheme": "~>1.2.3"
|
||||||
},
|
},
|
||||||
|
@ -74,7 +79,6 @@
|
||||||
"versions": ["USE_EXTERNAL"],
|
"versions": ["USE_EXTERNAL"],
|
||||||
"libs-windows": ["opengl32"],
|
"libs-windows": ["opengl32"],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"derelict-gl3": "~>2.0.0-beta.8",
|
|
||||||
"derelict-ft": "~>2.0.0-beta.5",
|
"derelict-ft": "~>2.0.0-beta.5",
|
||||||
"icontheme": "~>1.2.3"
|
"icontheme": "~>1.2.3"
|
||||||
}
|
}
|
||||||
|
@ -86,7 +90,6 @@
|
||||||
"versions-windows": ["Unicode" ,"NO_OPENGL"],
|
"versions-windows": ["Unicode" ,"NO_OPENGL"],
|
||||||
"libs-windows": ["opengl32"],
|
"libs-windows": ["opengl32"],
|
||||||
"dependencies-posix": {
|
"dependencies-posix": {
|
||||||
"derelict-gl3": "~>2.0.0-beta.8",
|
|
||||||
"derelict-sdl2": "~>3.0.0-beta.8",
|
"derelict-sdl2": "~>3.0.0-beta.8",
|
||||||
"derelict-ft": "~>2.0.0-beta.5",
|
"derelict-ft": "~>2.0.0-beta.5",
|
||||||
"icontheme": "~>1.2.3"
|
"icontheme": "~>1.2.3"
|
||||||
|
@ -97,14 +100,13 @@
|
||||||
"versions": ["USE_SDL", "USE_OPENGL", "USE_FREETYPE", "EmbedStandardResources"],
|
"versions": ["USE_SDL", "USE_OPENGL", "USE_FREETYPE", "EmbedStandardResources"],
|
||||||
"versions-windows": ["Unicode"],
|
"versions-windows": ["Unicode"],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"derelict-gl3": "~>2.0.0-beta.8",
|
|
||||||
"derelict-ft": "~>2.0.0-beta.5",
|
"derelict-ft": "~>2.0.0-beta.5",
|
||||||
"derelict-sdl2": "~>3.0.0-beta.8",
|
"derelict-sdl2": "~>3.0.0-beta.8",
|
||||||
"icontheme": "~>1.2.3"
|
"icontheme": "~>1.2.3"
|
||||||
},
|
},
|
||||||
"copyFiles-windows-x86_64": [
|
"copyFiles-windows-x86_64": [
|
||||||
"libs/windows/x86_64/libfreetype-6.dll",
|
"libs/windows/x86_64/libfreetype-6.dll",
|
||||||
"libs/windows/x86_64/SDL2.dll",
|
"libs/windows/x86_64/SDL2.dll"
|
||||||
],
|
],
|
||||||
"copyFiles-windows-x86": [
|
"copyFiles-windows-x86": [
|
||||||
"libs/windows/x86/libfreetype-6.dll",
|
"libs/windows/x86/libfreetype-6.dll",
|
||||||
|
@ -116,7 +118,6 @@
|
||||||
"versions": ["USE_X11", "USE_FREETYPE", "EmbedStandardResources"],
|
"versions": ["USE_X11", "USE_FREETYPE", "EmbedStandardResources"],
|
||||||
"versions-windows": ["Unicode"],
|
"versions-windows": ["Unicode"],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"derelict-gl3": "~>2.0.0-beta.8",
|
|
||||||
"derelict-ft": "~>2.0.0-beta.5",
|
"derelict-ft": "~>2.0.0-beta.5",
|
||||||
"x11": "~>1.0.21",
|
"x11": "~>1.0.21",
|
||||||
"icontheme": "~>1.2.3"
|
"icontheme": "~>1.2.3"
|
||||||
|
@ -127,7 +128,6 @@
|
||||||
"versions": ["USE_DSFML", "USE_OPENGL", "USE_FREETYPE", "EmbedStandardResources"],
|
"versions": ["USE_DSFML", "USE_OPENGL", "USE_FREETYPE", "EmbedStandardResources"],
|
||||||
"versions-windows": ["Unicode"],
|
"versions-windows": ["Unicode"],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"derelict-gl3": "~>2.0.0-beta.7",
|
|
||||||
"derelict-ft": "~>2.0.0-beta.4",
|
"derelict-ft": "~>2.0.0-beta.4",
|
||||||
"dsfml": "~>2.1.0",
|
"dsfml": "~>2.1.0",
|
||||||
"icontheme": "~>1.2.3"
|
"icontheme": "~>1.2.3"
|
||||||
|
|
|
@ -33,8 +33,6 @@ extern (C) int UIAppMain(string[] args) {
|
||||||
|
|
||||||
static if (ENABLE_OPENGL):
|
static if (ENABLE_OPENGL):
|
||||||
|
|
||||||
import derelict.opengl3.gl3;
|
|
||||||
import derelict.opengl3.gl;
|
|
||||||
import dlangui.graphics.glsupport;
|
import dlangui.graphics.glsupport;
|
||||||
import dlangui.graphics.gldrawbuf;
|
import dlangui.graphics.gldrawbuf;
|
||||||
|
|
||||||
|
|
|
@ -48,31 +48,7 @@ version (Android) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
enum SUPPORT_LEGACY_OPENGL = false; //true;
|
enum SUPPORT_LEGACY_OPENGL = false; //true;
|
||||||
public import derelict.opengl;
|
public import bindbc.opengl;
|
||||||
import derelict.util.exception;
|
|
||||||
//public import derelict.opengl.types;
|
|
||||||
//public import derelict.opengl.versions.base;
|
|
||||||
//public import derelict.opengl.versions.gl3x;
|
|
||||||
//public import derelict.opengl.gl;
|
|
||||||
|
|
||||||
derelict.util.exception.ShouldThrow gl3MissingSymFunc( string symName ) {
|
|
||||||
import std.algorithm : equal;
|
|
||||||
static import derelict.util.exception;
|
|
||||||
foreach(s; ["glGetError", "glShaderSource", "glCompileShader",
|
|
||||||
"glGetShaderiv", "glGetShaderInfoLog", "glGetString",
|
|
||||||
"glCreateProgram", "glUseProgram", "glDeleteProgram",
|
|
||||||
"glDeleteShader", "glEnable", "glDisable", "glBlendFunc",
|
|
||||||
"glUniformMatrix4fv", "glGetAttribLocation", "glGetUniformLocation",
|
|
||||||
"glGenVertexArrays", "glBindVertexArray", "glBufferData",
|
|
||||||
"glBindBuffer", "glBufferSubData"]) {
|
|
||||||
if (symName.equal(s)) // Symbol is used
|
|
||||||
return derelict.util.exception.ShouldThrow.Yes;
|
|
||||||
}
|
|
||||||
// Don't throw for unused symbol
|
|
||||||
return derelict.util.exception.ShouldThrow.No;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
import dlangui.graphics.scene.mesh;
|
import dlangui.graphics.scene.mesh;
|
||||||
|
@ -668,40 +644,16 @@ bool initGLSupport(bool legacy = false) {
|
||||||
version(Android) {
|
version(Android) {
|
||||||
Log.d("initGLSupport");
|
Log.d("initGLSupport");
|
||||||
} else {
|
} else {
|
||||||
static bool DERELICT_GL3_RELOADED;
|
|
||||||
static bool gl3ReloadedOk;
|
auto support = loadOpenGL();
|
||||||
static bool glReloadedOk;
|
if(support < bindbc.opengl.GLSupport.gl11) // No context! Error!
|
||||||
if (!DERELICT_GL3_RELOADED) {
|
{
|
||||||
DERELICT_GL3_RELOADED = true;
|
Log.e("OpenGL wasn't loaded successfully");
|
||||||
try {
|
|
||||||
Log.v("Reloading DerelictGL3");
|
|
||||||
import derelict.opengl; //.gl3;
|
|
||||||
DerelictGL3.missingSymbolCallback = &gl3MissingSymFunc;
|
|
||||||
DerelictGL3.reload();
|
|
||||||
gl3ReloadedOk = true;
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.e("Derelict exception while reloading DerelictGL3", e);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
Log.v("Reloading DerelictGL");
|
|
||||||
import derelict.opengl; //.gl;
|
|
||||||
DerelictGL3.missingSymbolCallback = &gl3MissingSymFunc;
|
|
||||||
DerelictGL3.reload();
|
|
||||||
glReloadedOk = true;
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.e("Derelict exception while reloading DerelictGL", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!gl3ReloadedOk && !glReloadedOk) {
|
|
||||||
Log.e("Neither DerelictGL3 nor DerelictGL were reloaded successfully");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!gl3ReloadedOk)
|
legacy = false;
|
||||||
legacy = true;
|
|
||||||
else if (!glReloadedOk)
|
|
||||||
legacy = false;
|
|
||||||
}
|
}
|
||||||
if (!_glSupport) {
|
if (!_glSupport) { // TODO_GRIM: Legacy looks very broken to me.
|
||||||
Log.d("glSupport not initialized: trying to create");
|
Log.d("glSupport not initialized: trying to create");
|
||||||
int major = *cast(int*)(glGetString(GL_VERSION)[0 .. 1].ptr);
|
int major = *cast(int*)(glGetString(GL_VERSION)[0 .. 1].ptr);
|
||||||
legacy = legacy || (major < 3);
|
legacy = legacy || (major < 3);
|
||||||
|
|
|
@ -160,7 +160,7 @@ static if (ENABLE_OPENGL) {
|
||||||
|
|
||||||
/// Shared opengl context helper
|
/// Shared opengl context helper
|
||||||
struct SharedGLContext {
|
struct SharedGLContext {
|
||||||
import derelict.opengl; //3.wgl;
|
import bindbc.opengl;
|
||||||
|
|
||||||
HGLRC _hGLRC; // opengl context
|
HGLRC _hGLRC; // opengl context
|
||||||
HPALETTE _hPalette;
|
HPALETTE _hPalette;
|
||||||
|
@ -323,8 +323,6 @@ class Win32Window : Window {
|
||||||
EndPaint(_hwnd, &ps);
|
EndPaint(_hwnd, &ps);
|
||||||
|
|
||||||
|
|
||||||
import derelict.opengl; //3.gl3;
|
|
||||||
import derelict.opengl; //3.wgl;
|
|
||||||
import dlangui.graphics.gldrawbuf;
|
import dlangui.graphics.gldrawbuf;
|
||||||
//Log.d("onPaint() start drawing opengl viewport: ", _dx, "x", _dy);
|
//Log.d("onPaint() start drawing opengl viewport: ", _dx, "x", _dy);
|
||||||
//PAINTSTRUCT ps;
|
//PAINTSTRUCT ps;
|
||||||
|
@ -1308,35 +1306,6 @@ string[] splitCmdLine(string line) {
|
||||||
|
|
||||||
private __gshared Win32Platform w32platform;
|
private __gshared Win32Platform w32platform;
|
||||||
|
|
||||||
static if (ENABLE_OPENGL) {
|
|
||||||
import derelict.opengl; //3.gl3;
|
|
||||||
//import derelict.opengl3.gl;
|
|
||||||
|
|
||||||
void initOpenGL() {
|
|
||||||
try {
|
|
||||||
Log.d("Loading Derelict GL");
|
|
||||||
//DerelictGL.load();
|
|
||||||
DerelictGL3.load();
|
|
||||||
Log.d("Derelict GL - loaded");
|
|
||||||
//
|
|
||||||
//// just to check OpenGL context
|
|
||||||
//Log.i("Trying to setup OpenGL context");
|
|
||||||
//Win32Window tmpWindow = new Win32Window(w32platform, ""d, null, 0);
|
|
||||||
//destroy(tmpWindow);
|
|
||||||
//if (openglEnabled)
|
|
||||||
// Log.i("OpenGL support is enabled");
|
|
||||||
//else
|
|
||||||
// Log.w("OpenGL support is disabled");
|
|
||||||
//// process messages
|
|
||||||
//platform.enterMessageLoop();
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.e("Exception while trying to init OpenGL", e);
|
|
||||||
setOpenglEnabled(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int myWinMain(void* hInstance, void* hPrevInstance, char* lpCmdLine, int iCmdShow)
|
int myWinMain(void* hInstance, void* hPrevInstance, char* lpCmdLine, int iCmdShow)
|
||||||
{
|
{
|
||||||
initLogs();
|
initLogs();
|
||||||
|
@ -1376,12 +1345,6 @@ int myWinMain(void* hInstance, void* hPrevInstance, char* lpCmdLine, int iCmdSho
|
||||||
|
|
||||||
currentTheme = createDefaultTheme();
|
currentTheme = createDefaultTheme();
|
||||||
|
|
||||||
static if (ENABLE_OPENGL) {
|
|
||||||
initOpenGL();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load versions 1.2+ and all supported ARB and EXT extensions.
|
|
||||||
|
|
||||||
Log.i("Entering UIAppMain: ", args);
|
Log.i("Entering UIAppMain: ", args);
|
||||||
int result = -1;
|
int result = -1;
|
||||||
try {
|
try {
|
||||||
|
@ -1443,12 +1406,6 @@ int myWinMainProfile(string[] args)
|
||||||
|
|
||||||
currentTheme = createDefaultTheme();
|
currentTheme = createDefaultTheme();
|
||||||
|
|
||||||
static if (ENABLE_OPENGL) {
|
|
||||||
initOpenGL();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load versions 1.2+ and all supported ARB and EXT extensions.
|
|
||||||
|
|
||||||
Log.i("Entering UIAppMain: ", args);
|
Log.i("Entering UIAppMain: ", args);
|
||||||
int result = -1;
|
int result = -1;
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue