example1: GlGears - trying on OSX

This commit is contained in:
Vadim Lopatin 2015-12-19 08:14:18 +03:00
parent 872b77241b
commit d2049653ba
2 changed files with 15 additions and 4 deletions

View File

@ -180,7 +180,7 @@ class Window {
_mainWidget.window = this;
}
// Abstract methods : override in platform implementation
// Abstract methods : override in platform implementatino
/// show window
abstract void show();
@ -1375,6 +1375,11 @@ static if (ENABLE_OPENGL) {
else
glyphDestroyCallback = null;
}
} else {
@property bool openglEnabled() { return false; }
void setOpenglEnabled(bool enabled = true) {
// ignore
}
}
version (Windows) {

View File

@ -84,6 +84,7 @@ class SDLWindow : Window {
_dx = width;
_dy = height;
create(flags);
Log.i(_enableOpengl ? "OpenGL is enabled" : "OpenGL is disabled");
}
~this() {
@ -152,7 +153,7 @@ class SDLWindow : Window {
windowFlags |= SDL_WINDOW_OPENGL;
if (!_glSupport) {
version(OSX) {
bool useLegacyOpengl = true;
bool useLegacyOpengl = false; //true;
} else {
bool useLegacyOpengl = false;
}
@ -182,6 +183,7 @@ class SDLWindow : Window {
static if (ENABLE_OPENGL) {
if (_enableOpengl) {
Log.i("Trying to create OpenGL 3.2 context");
createContext(3, 2);
//_context = SDL_GL_CreateContext(_win); // Create the actual context and make it current
if (!_context) {
@ -199,11 +201,14 @@ class SDLWindow : Window {
}
if (_context && !_gl3Reloaded) {
try {
Log.d("Reloading DerelictGL3");
DerelictGL3.missingSymbolCallback = &gl3MissingSymFunc;
DerelictGL3.reload(GLVersion.GL21, GLVersion.GL40);
_gl3Reloaded = true;
if (!glSupport.valid && !glSupport.initShaders())
if (!glSupport.valid && !glSupport.initShaders()) {
Log.e("Failed to initialize OpenGL - disabling OpenGL support");
_enableOpengl = false;
}
fixSize();
} catch (derelict.util.exception.SymbolLoadException e) {
Log.e("Exception in DerelictGL3.reload ", e);
@ -220,6 +225,7 @@ class SDLWindow : Window {
}
fixSize();
}
setOpenglEnabled(_enableOpengl);
windowCaption = _caption;
return true;
}