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
|
||||
*/
|
||||
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
|
||||
*
|
||||
|
|
|
|||
|
|
@ -127,8 +127,11 @@ class SDLWindow : Window {
|
|||
_context = SDL_GL_CreateContext(_win); // Create the actual context and make it current
|
||||
if (!_context)
|
||||
Log.e("SDL_GL_CreateContext failed: ", fromStringz(SDL_GetError()));
|
||||
else
|
||||
else {
|
||||
Log.i("Created successfully");
|
||||
_platform.GLVersionMajor = versionMajor;
|
||||
_platform.GLVersionMinor = versionMinor;
|
||||
}
|
||||
return _context !is null;
|
||||
}
|
||||
}
|
||||
|
|
@ -176,21 +179,24 @@ class SDLWindow : Window {
|
|||
|
||||
static if (ENABLE_OPENGL) {
|
||||
if (_enableOpengl) {
|
||||
createContext(3, 2);
|
||||
if (!_context) {
|
||||
Log.e("SDL_GL_CreateContext failed: ", fromStringz(SDL_GetError()));
|
||||
bool success = createContext(_platform.GLVersionMajor, _platform.GLVersionMinor);
|
||||
if (!success) {
|
||||
Log.w("trying other versions of OpenGL");
|
||||
bool flg = false;
|
||||
flg = flg || createContext(3, 3);
|
||||
flg = flg || createContext(3, 1);
|
||||
flg = flg || createContext(4, 0);
|
||||
flg = flg || createContext(2, 1);
|
||||
if (!flg) {
|
||||
// Lazy conditions.
|
||||
if(_platform.GLVersionMajor >= 4)
|
||||
success = success || createContext(4, 0);
|
||||
success = success || createContext(3, 3);
|
||||
success = success || createContext(3, 2);
|
||||
success = success || createContext(3, 1);
|
||||
success = success || createContext(2, 1);
|
||||
if (!success) {
|
||||
_enableOpengl = false;
|
||||
_platform.GLVersionMajor = 0;
|
||||
_platform.GLVersionMinor = 0;
|
||||
Log.w("OpenGL support is disabled");
|
||||
}
|
||||
}
|
||||
if (_context && !_glSupport) {
|
||||
if (success && !_glSupport) {
|
||||
_enableOpengl = initGLSupport(false);
|
||||
fixSize();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue