mirror of https://github.com/buggins/dlangui.git
Merge pull request #173 from g4z3r/gl
ability to set GL context version by application
This commit is contained in:
commit
c5119fdc07
|
|
@ -125,8 +125,9 @@ class GLProgram {
|
||||||
private char[] glslversionString;
|
private char[] glslversionString;
|
||||||
|
|
||||||
private void compatibilityFixes(ref char[] code, GLuint type) {
|
private void compatibilityFixes(ref char[] code, GLuint type) {
|
||||||
if (glslversionInt < 150) {
|
if (glslversionInt < 150)
|
||||||
code = replace(code, " texture(", " texture2D(");
|
code = replace(code, " texture(", " texture2D(");
|
||||||
|
if (glslversionInt < 140) {
|
||||||
if(type == GL_VERTEX_SHADER)
|
if(type == GL_VERTEX_SHADER)
|
||||||
{
|
{
|
||||||
code = replace(code, "in ", "attribute ");
|
code = replace(code, "in ", "attribute ");
|
||||||
|
|
@ -134,6 +135,8 @@ class GLProgram {
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
code = replace(code, "in ", "varying ");
|
code = replace(code, "in ", "varying ");
|
||||||
|
code = replace(code, "out vec4 outColor;", "");
|
||||||
|
code = replace(code, "outColor", "gl_FragColor");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -220,7 +220,7 @@ class X11Window : DWindow {
|
||||||
swamask |= CWColormap;
|
swamask |= CWColormap;
|
||||||
swa.colormap = x11cmap;
|
swa.colormap = x11cmap;
|
||||||
visual = cast(Visual*)x11visual.visual;
|
visual = cast(Visual*)x11visual.visual;
|
||||||
depth = x11visutal.depth;
|
depth = x11visual.depth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue