diff --git a/source/window.d b/source/window.d index 1f554f9..caf0617 100644 --- a/source/window.d +++ b/source/window.d @@ -29,24 +29,45 @@ struct Window { SDL_Window* window; SDL_GLContext context; - extern(Windows) nothrow @nogc - static void openGLCallbackFunction( - GLenum source, GLenum type, - GLuint id, GLenum severity, - GLsizei length, const (GLchar)* message, - void* userParam) - { + version(Windows) { + extern(Windows) nothrow @nogc + static void openGLCallbackFunction( + GLenum source, GLenum type, + GLuint id, GLenum severity, + GLsizei length, const (GLchar)* message, + void* userParam) + { - printf("Message: %s \nSource: %s \nType: %s \nID: %d \nSeverity: %s\n\n", - message, to!(char*)(source), to!(char*)(type), id, to!(char*)(severity)); + printf("Message: %s \nSource: %s \nType: %s \nID: %d \nSeverity: %s\n\n", + message, to!(char*)(source), to!(char*)(type), id, to!(char*)(severity)); - if (severity == GL_DEBUG_SEVERITY_HIGH) { - printf("Aborting...\n"); - import core.stdc.stdlib : exit; - exit(-1); - } + if (severity == GL_DEBUG_SEVERITY_HIGH) { + printf("Aborting...\n"); + import core.stdc.stdlib : exit; + exit(-1); + } - } // openGLCallbackFunction + } // openGLCallbackFunction + } else { + extern(C) nothrow @nogc + static void openGLCallbackFunction( + GLenum source, GLenum type, + GLuint id, GLenum severity, + GLsizei length, const (GLchar*) message, // TODO: look at why it's GLchar* for non-windows and the other works on windows.. + void* userParam) + { + + printf("Message: %s \nSource: %s \nType: %s \nID: %d \nSeverity: %s\n\n", + message, to!(char*)(source), to!(char*)(type), id, to!(char*)(severity)); + + if (severity == GL_DEBUG_SEVERITY_HIGH) { + printf("Aborting...\n"); + import core.stdc.stdlib : exit; + exit(-1); + } + + } // openGLCallbackFunction + } void createWindow(int w, int h, const char* title = "Chipd8 Emu") { assert(w > 0, "window width must be > 0"); @@ -177,4 +198,4 @@ const (char*) to(T : char*)(GLenum value) { } -} // to!string(GLenum) \ No newline at end of file +} // to!string(GLenum)