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.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
|
||||
private void LVGLFillColor(uint color, float * buf, int count) {
|
||||
float r = ((color >> 16) & 255) / 255.0f;
|
||||
|
@ -85,8 +101,11 @@ class GLProgram {
|
|||
}
|
||||
|
||||
private void compatibilityFixes(ref char[] code, GLuint type) {
|
||||
if (glslversionInt < 150)
|
||||
if (glslversionInt < 150) {
|
||||
code = replace(code, " texture(", " texture2D(");
|
||||
code = replace(code, "in ", "");
|
||||
code = replace(code, "out ", "");
|
||||
}
|
||||
}
|
||||
|
||||
private GLuint compileShader(string src, GLuint type) {
|
||||
|
@ -277,11 +296,17 @@ class SolidFillProgram : GLProgram {
|
|||
|
||||
matrixLocation = glGetUniformLocation(program, "matrix");
|
||||
checkError("glGetUniformLocation matrix");
|
||||
if (matrixLocation == 0)
|
||||
Log.e("glGetUniformLocation failed for matrixLocation");
|
||||
vertexLocation = glGetAttribLocation(program, "vertex");
|
||||
checkError("glGetAttribLocation vertex");
|
||||
colAttrLocation = glGetAttribLocation(program, "colAttr");
|
||||
if (vertexLocation == 0)
|
||||
Log.e("glGetUniformLocation failed for vertexLocation");
|
||||
colAttrLocation = glGetAttribLocation(program, "colAttr");
|
||||
checkError("glGetAttribLocation colAttr");
|
||||
return res && matrixLocation >= 0 && vertexLocation >= 0 && colAttrLocation >= 0;
|
||||
if (colAttrLocation == 0)
|
||||
Log.e("glGetUniformLocation failed for colAttrLocation");
|
||||
return res && matrixLocation >= 0 && vertexLocation >= 0 && colAttrLocation >= 0;
|
||||
}
|
||||
|
||||
bool execute(float[] vertices, float[] colors) {
|
||||
|
|
|
@ -175,7 +175,8 @@ class SDLWindow : Window {
|
|||
version(USE_OPENGL) {
|
||||
if (_enableOpengl) {
|
||||
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) {
|
||||
Log.e("SDL_GL_CreateContext failed: ", fromStringz(SDL_GetError()));
|
||||
Log.w("trying other versions of OpenGL");
|
||||
|
@ -190,11 +191,17 @@ class SDLWindow : Window {
|
|||
}
|
||||
}
|
||||
if (_context && !_gl3Reloaded) {
|
||||
DerelictGL3.reload();
|
||||
_gl3Reloaded = true;
|
||||
if (!glSupport.valid && !glSupport.initShaders())
|
||||
_enableOpengl = false;
|
||||
fixSize();
|
||||
try {
|
||||
DerelictGL3.missingSymbolCallback = &gl3MissingSymFunc;
|
||||
DerelictGL3.reload(GLVersion.GL21, GLVersion.GL40);
|
||||
_gl3Reloaded = true;
|
||||
if (!glSupport.valid && !glSupport.initShaders())
|
||||
_enableOpengl = false;
|
||||
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) {
|
||||
try {
|
||||
DerelictGL3.missingSymbolCallback = &gl3MissingSymFunc;
|
||||
DerelictGL3.load();
|
||||
_enableOpengl = true;
|
||||
} catch (Exception e) {
|
||||
|
|
Loading…
Reference in New Issue