mirror of https://github.com/buggins/dlangui.git
ability to set GL context version by application
This commit is contained in:
parent
26e5e831d2
commit
4723343eaf
|
|
@ -1253,6 +1253,19 @@ class Platform {
|
||||||
* Window w/o Resizable nor Fullscreen will be created with size based on measurement of its content widget
|
* Window w/o Resizable nor Fullscreen will be created with size based on measurement of its content widget
|
||||||
*/
|
*/
|
||||||
abstract Window createWindow(dstring windowCaption, Window parent, uint flags = WindowFlag.Resizable, uint width = 0, uint height = 0);
|
abstract Window createWindow(dstring windowCaption, Window parent, uint flags = WindowFlag.Resizable, uint width = 0, uint height = 0);
|
||||||
|
|
||||||
|
static if (ENABLE_OPENGL) {
|
||||||
|
/**
|
||||||
|
* OpenGL context major version.
|
||||||
|
* Note: if the version is invalid or not supported, this value will be set to supported one.
|
||||||
|
*/
|
||||||
|
int GLVersionMajor = 3;
|
||||||
|
/**
|
||||||
|
* OpenGL context minor version.
|
||||||
|
* Note: if the version is invalid or not supported, this value will be set to supported one.
|
||||||
|
*/
|
||||||
|
int GLVersionMinor = 2;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* close window
|
* close window
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -127,8 +127,11 @@ class SDLWindow : Window {
|
||||||
_context = SDL_GL_CreateContext(_win); // Create the actual context and make it current
|
_context = SDL_GL_CreateContext(_win); // Create the actual context and make it current
|
||||||
if (!_context)
|
if (!_context)
|
||||||
Log.e("SDL_GL_CreateContext failed: ", fromStringz(SDL_GetError()));
|
Log.e("SDL_GL_CreateContext failed: ", fromStringz(SDL_GetError()));
|
||||||
else
|
else {
|
||||||
Log.i("Created successfully");
|
Log.i("Created successfully");
|
||||||
|
_platform.GLVersionMajor = versionMajor;
|
||||||
|
_platform.GLVersionMinor = versionMinor;
|
||||||
|
}
|
||||||
return _context !is null;
|
return _context !is null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -176,21 +179,24 @@ class SDLWindow : Window {
|
||||||
|
|
||||||
static if (ENABLE_OPENGL) {
|
static if (ENABLE_OPENGL) {
|
||||||
if (_enableOpengl) {
|
if (_enableOpengl) {
|
||||||
createContext(3, 2);
|
bool success = createContext(_platform.GLVersionMajor, _platform.GLVersionMinor);
|
||||||
if (!_context) {
|
if (!success) {
|
||||||
Log.e("SDL_GL_CreateContext failed: ", fromStringz(SDL_GetError()));
|
|
||||||
Log.w("trying other versions of OpenGL");
|
Log.w("trying other versions of OpenGL");
|
||||||
bool flg = false;
|
// Lazy conditions.
|
||||||
flg = flg || createContext(3, 3);
|
if(_platform.GLVersionMajor >= 4)
|
||||||
flg = flg || createContext(3, 1);
|
success = success || createContext(4, 0);
|
||||||
flg = flg || createContext(4, 0);
|
success = success || createContext(3, 3);
|
||||||
flg = flg || createContext(2, 1);
|
success = success || createContext(3, 2);
|
||||||
if (!flg) {
|
success = success || createContext(3, 1);
|
||||||
|
success = success || createContext(2, 1);
|
||||||
|
if (!success) {
|
||||||
_enableOpengl = false;
|
_enableOpengl = false;
|
||||||
|
_platform.GLVersionMajor = 0;
|
||||||
|
_platform.GLVersionMinor = 0;
|
||||||
Log.w("OpenGL support is disabled");
|
Log.w("OpenGL support is disabled");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_context && !_glSupport) {
|
if (success && !_glSupport) {
|
||||||
_enableOpengl = initGLSupport(false);
|
_enableOpengl = initGLSupport(false);
|
||||||
fixSize();
|
fixSize();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue