trying to fix OpenGL problem on MAC

This commit is contained in:
Vadim Lopatin 2015-03-16 17:04:42 +03:00
parent 057a37df3e
commit 945aabfc1d
2 changed files with 12 additions and 19 deletions

View File

@ -84,10 +84,17 @@ class GLProgram {
import core.stdc.stdlib;
import std.string;
Log.d("compileShader glsl=", glslversion, " code: ", src);
char[] versionLine;
versionLine ~= "#version ";
foreach(ch; glslversion)
if (ch >= '0' && ch <= '9')
versionLine ~= ch;
versionLine ~= "\n\n";
string sourceCode = versionLine ~ src;
Log.d("compileShader glsl=", glslversion, " code: ", sourceCode);
GLuint shader = glCreateShader(type);//GL_VERTEX_SHADER
const char * psrc = src.toStringz;
const char * psrc = sourceCode.toStringz;
GLuint len = cast(uint)src.length;
glShaderSource(shader, 1, &psrc, cast(const(int)*)&len);
glCompileShader(shader);

View File

@ -147,23 +147,9 @@ class SDLWindow : Window {
Log.i("Trying to create OpenGL 3.2 context");
_context = SDL_GL_CreateContext(_win); // Create the actual context and make it current
if (!_context) {
Log.e("SDL_GL_CreateContext failed for version 3.2: ", fromStringz(SDL_GetError()));
Log.w("Trying to create OpenGL 2.1 context");
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION,2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION,1);
_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 to create OpenGL 2.0 context");
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION,2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION,0);
_context = SDL_GL_CreateContext(_win); // Create the actual context and make it current
if (!_context) {
Log.e("SDL_GL_CreateContext failed: ", fromStringz(SDL_GetError()));
_enableOpengl = false;
Log.w("OpenGL support is disabled");
}
}
Log.e("SDL_GL_CreateContext failed: ", fromStringz(SDL_GetError()));
_enableOpengl = false;
Log.w("OpenGL support is disabled");
}
if (_context && !_gl3Reloaded) {
DerelictGL3.reload();