mirror of https://github.com/buggins/dlangui.git
trying to fix OpenGL under virtualBox
This commit is contained in:
parent
4ca288209d
commit
6764ce322b
|
@ -27,6 +27,22 @@ import std.conv;
|
||||||
import std.string;
|
import std.string;
|
||||||
import std.array;
|
import std.array;
|
||||||
|
|
||||||
|
derelict.util.exception.ShouldThrow gl3MissingSymFunc( string symName ) {
|
||||||
|
import std.algorithm : equal;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
// utility function to fill 4-float array of vertex colors with converted CR 32bit color
|
// utility function to fill 4-float array of vertex colors with converted CR 32bit color
|
||||||
private void LVGLFillColor(uint color, float * buf, int count) {
|
private void LVGLFillColor(uint color, float * buf, int count) {
|
||||||
float r = ((color >> 16) & 255) / 255.0f;
|
float r = ((color >> 16) & 255) / 255.0f;
|
||||||
|
@ -85,8 +101,11 @@ class GLProgram {
|
||||||
}
|
}
|
||||||
|
|
||||||
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(");
|
||||||
|
code = replace(code, "in ", "");
|
||||||
|
code = replace(code, "out ", "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private GLuint compileShader(string src, GLuint type) {
|
private GLuint compileShader(string src, GLuint type) {
|
||||||
|
@ -277,10 +296,16 @@ class SolidFillProgram : GLProgram {
|
||||||
|
|
||||||
matrixLocation = glGetUniformLocation(program, "matrix");
|
matrixLocation = glGetUniformLocation(program, "matrix");
|
||||||
checkError("glGetUniformLocation matrix");
|
checkError("glGetUniformLocation matrix");
|
||||||
|
if (matrixLocation == 0)
|
||||||
|
Log.e("glGetUniformLocation failed for matrixLocation");
|
||||||
vertexLocation = glGetAttribLocation(program, "vertex");
|
vertexLocation = glGetAttribLocation(program, "vertex");
|
||||||
checkError("glGetAttribLocation vertex");
|
checkError("glGetAttribLocation vertex");
|
||||||
|
if (vertexLocation == 0)
|
||||||
|
Log.e("glGetUniformLocation failed for vertexLocation");
|
||||||
colAttrLocation = glGetAttribLocation(program, "colAttr");
|
colAttrLocation = glGetAttribLocation(program, "colAttr");
|
||||||
checkError("glGetAttribLocation colAttr");
|
checkError("glGetAttribLocation colAttr");
|
||||||
|
if (colAttrLocation == 0)
|
||||||
|
Log.e("glGetUniformLocation failed for colAttrLocation");
|
||||||
return res && matrixLocation >= 0 && vertexLocation >= 0 && colAttrLocation >= 0;
|
return res && matrixLocation >= 0 && vertexLocation >= 0 && colAttrLocation >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -175,7 +175,8 @@ class SDLWindow : Window {
|
||||||
version(USE_OPENGL) {
|
version(USE_OPENGL) {
|
||||||
if (_enableOpengl) {
|
if (_enableOpengl) {
|
||||||
Log.i("Trying to create OpenGL 3.2 context");
|
Log.i("Trying to create OpenGL 3.2 context");
|
||||||
_context = SDL_GL_CreateContext(_win); // Create the actual context and make it current
|
createContext(3, 2);
|
||||||
|
//_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()));
|
||||||
Log.w("trying other versions of OpenGL");
|
Log.w("trying other versions of OpenGL");
|
||||||
|
@ -190,11 +191,17 @@ class SDLWindow : Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_context && !_gl3Reloaded) {
|
if (_context && !_gl3Reloaded) {
|
||||||
DerelictGL3.reload();
|
try {
|
||||||
|
DerelictGL3.missingSymbolCallback = &gl3MissingSymFunc;
|
||||||
|
DerelictGL3.reload(GLVersion.GL21, GLVersion.GL40);
|
||||||
_gl3Reloaded = true;
|
_gl3Reloaded = true;
|
||||||
if (!glSupport.valid && !glSupport.initShaders())
|
if (!glSupport.valid && !glSupport.initShaders())
|
||||||
_enableOpengl = false;
|
_enableOpengl = false;
|
||||||
fixSize();
|
fixSize();
|
||||||
|
} catch (derelict.util.exception.SymbolLoadException e) {
|
||||||
|
Log.e("Exception in DerelictGL3.reload ", e);
|
||||||
|
_enableOpengl = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1301,6 +1308,7 @@ int sdlmain(string[] args) {
|
||||||
|
|
||||||
version(USE_OPENGL) {
|
version(USE_OPENGL) {
|
||||||
try {
|
try {
|
||||||
|
DerelictGL3.missingSymbolCallback = &gl3MissingSymFunc;
|
||||||
DerelictGL3.load();
|
DerelictGL3.load();
|
||||||
_enableOpengl = true;
|
_enableOpengl = true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
Loading…
Reference in New Issue