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

View File

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