clear some code

This commit is contained in:
gazer 2016-01-04 21:03:35 +03:00
parent 57002757b7
commit 936838bf2d
2 changed files with 17 additions and 40 deletions

View File

@ -114,16 +114,16 @@ class SDLWindow : Window {
} }
static if (ENABLE_OPENGL) { static if (ENABLE_OPENGL)
{
static private bool _gl3Reloaded = false; static private bool _gl3Reloaded = false;
private SDL_GLContext _context; private SDL_GLContext _context;
}
static if (ENABLE_OPENGL) {
protected bool createContext(int versionMajor, int versionMinor) { protected bool createContext(int versionMajor, int versionMinor) {
Log.i("Trying to create OpenGL ", versionMajor, ".", versionMinor, " context"); Log.i("Trying to create OpenGL ", versionMajor, ".", versionMinor, " context");
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, versionMajor); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, versionMajor);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, versionMinor); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, versionMinor);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
_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)
Log.e("SDL_GL_CreateContext failed: ", fromStringz(SDL_GetError())); Log.e("SDL_GL_CreateContext failed: ", fromStringz(SDL_GetError()));
@ -176,9 +176,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
if (!_context) { if (!_context) {
Log.e("SDL_GL_CreateContext failed: ", fromStringz(SDL_GetError())); Log.e("SDL_GL_CreateContext failed: ", fromStringz(SDL_GetError()));
Log.w("trying other versions of OpenGL"); Log.w("trying other versions of OpenGL");
@ -887,23 +885,16 @@ private __gshared bool _enableOpengl;
class SDLPlatform : Platform { class SDLPlatform : Platform {
this() { this() {
} }
private SDLWindow[uint] _windowMap;
~this() { ~this() {
foreach(ref SDLWindow wnd; _windowMap) { foreach(ref SDLWindow wnd; _windowMap) {
destroy(wnd); destroy(wnd);
wnd = null; wnd = null;
} }
destroy(_windowMap); destroy(_windowMap);
disconnect();
}
void disconnect() {
/* Cleanup */
}
bool connect() {
return true;
} }
SDLWindow getWindow(uint id) { SDLWindow getWindow(uint id) {
@ -944,7 +935,6 @@ class SDLPlatform : Platform {
event.user.windowID = windowId; event.user.windowID = windowId;
event.user.code = code; event.user.code = code;
SDL_PushEvent(&event); SDL_PushEvent(&event);
} }
override Window createWindow(dstring windowCaption, Window parent, uint flags = WindowFlag.Resizable, uint width = 0, uint height = 0) { override Window createWindow(dstring windowCaption, Window parent, uint flags = WindowFlag.Resizable, uint width = 0, uint height = 0) {
@ -982,8 +972,6 @@ class SDLPlatform : Platform {
bool skipNextQuit = false; bool skipNextQuit = false;
while(!quit) { while(!quit) {
//redrawWindows(); //redrawWindows();
//if (SDL_PollEvent(&event)) {
if (SDL_WaitEvent(&event)) { if (SDL_WaitEvent(&event)) {
//Log.d("Event.type = ", event.type); //Log.d("Event.type = ", event.type);
@ -1150,9 +1138,7 @@ class SDLPlatform : Platform {
} }
_windowToClose = null; _windowToClose = null;
} }
//
if (_windowMap.length == 0) { if (_windowMap.length == 0) {
//quit = true;
SDL_Quit(); SDL_Quit();
quit = true; quit = true;
} }
@ -1179,8 +1165,6 @@ class SDLPlatform : Platform {
string s = toUTF8(text); string s = toUTF8(text);
SDL_SetClipboardText(s.toStringz); SDL_SetClipboardText(s.toStringz);
} }
protected SDLWindow[uint] _windowMap;
} }
version (Windows) { version (Windows) {
@ -1321,13 +1305,9 @@ int sdlmain(string[] args) {
USER_EVENT_ID = SDL_RegisterEvents(1); USER_EVENT_ID = SDL_RegisterEvents(1);
TIMER_EVENT_ID = SDL_RegisterEvents(1); TIMER_EVENT_ID = SDL_RegisterEvents(1);
int request = SDL_GetDesktopDisplayMode(0,&displayMode); int request = SDL_GetDesktopDisplayMode(0, &displayMode);
static if (ENABLE_OPENGL) { static if (ENABLE_OPENGL) {
// we want OpenGL 3.2
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION,3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION,2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
// Set OpenGL attributes // Set OpenGL attributes
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
@ -1335,10 +1315,7 @@ int sdlmain(string[] args) {
SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1); SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1);
} }
SDLPlatform sdl = new SDLPlatform(); auto sdl = new SDLPlatform;
if (!sdl.connect()) {
return 1;
}
Platform.setInstance(sdl); Platform.setInstance(sdl);

View File

@ -966,7 +966,7 @@ class X11Platform : Platform {
this() { this() {
} }
X11Window[XWindow] _windowMap; private X11Window[XWindow] _windowMap;
/** /**
* create window * create window