SDL support

This commit is contained in:
Vadim Lopatin 2014-04-28 16:47:49 +04:00
parent ce71e7dc1a
commit 5375d03ebe
2 changed files with 24 additions and 11 deletions

View File

@ -97,10 +97,13 @@
"../../3rdparty/win32/ws2tcpip.d", "../../3rdparty/win32/ws2tcpip.d",
"../../3rdparty/win32/wtypes.d" "../../3rdparty/win32/wtypes.d"
], ],
"sourceFiles": [ "sourceFiles": [
"src/main.d" "src/main.d"
], ],
"copyFiles-windows": [ "copyFiles-windows": [
"../../lib/SDL2.dll",
"../../lib/FreeImage.dll", "../../lib/FreeImage.dll",
"../../lib/libfreetype-6.dll", "../../lib/libfreetype-6.dll",
"../../lib/libpng15.dll", "../../lib/libpng15.dll",

View File

@ -43,6 +43,7 @@ version(USE_SDL) {
Log.d("Creating SDL window"); Log.d("Creating SDL window");
create(); create();
} }
~this() { ~this() {
Log.d("Destroying window"); Log.d("Destroying window");
if (_renderer) if (_renderer)
@ -219,17 +220,26 @@ version(USE_SDL) {
bool quit = false; bool quit = false;
while(true) { while(true) {
redrawWindows(); redrawWindows();
//if (SDL_PollEvent(&event)) {
SDL_PollEvent(&event); if (SDL_WaitEvent(&event)) {
//Log.d("Event.type = ", event.type); //Log.d("Event.type = ", event.type);
if (event.type == SDL_QUIT) { if (event.type == SDL_QUIT) {
Log.i("event.type == SDL_QUIT"); Log.i("event.type == SDL_QUIT");
break; break;
} } else if (event.type == SDL_WINDOWEVENT) {
switch (event.window.event) {
case SDL_WINDOWEVENT_RESIZED:
//SDL_PumpEvents(); Log.d("SDL_WINDOWEVENT_RESIZED win=", event.window.windowID, " pos=", event.window.data1,
SDL_Delay(10); ",", event.window.data2);
break;
case SDL_WINDOWEVENT_CLOSE:
Log.d("SDL_WINDOWEVENT_CLOSE win=", event.window.windowID);
break;
default:
break;
}
}
}
} }
Log.i("exiting message loop"); Log.i("exiting message loop");
return 0; return 0;