diff mde/SDL.d @ 22:249eb6620685

Changes to Options, particularly regarding window sizes. Window sizes for fullscreen and windowed modes are now independant. Window resizes by the WM are now persistant. Options class contents are now generated by templates. committer: Diggory Hardy <diggory.hardy@gmail.com>
author Diggory Hardy <diggory.hardy@gmail.com>
date Tue, 25 Mar 2008 12:24:04 +0000
parents a60cbb7359dd
children 47478557428d
line wrap: on
line diff
--- a/mde/SDL.d	Mon Mar 24 17:53:28 2008 +0000
+++ b/mde/SDL.d	Tue Mar 25 12:24:04 2008 +0000
@@ -36,6 +36,8 @@
     init4.addFunc (&setupWindow);
 }
 
+private uint flags = 0;
+
 void initSdlAndGl() {   // init2 func
     logger.trace ("init2: initSdlAndGl() started");
     
@@ -78,8 +80,7 @@
     // Window creation flags
     /* NOTE: I'm getting an API mismatch error from the nvidia driver when using OpenGL,
     * thus I've temporarily disabled it. */
-    version (MDE_OPENGL) uint flags = SDL_OPENGL;
-    else uint flags = 0;
+    version (MDE_OPENGL) flags = SDL_OPENGL;
     if (Options.video.fullscreen) flags |= SDL_FULLSCREEN;
     else {
         if (Options.video.resizable) flags |= SDL_RESIZABLE;
@@ -98,7 +99,13 @@
     }
     
     // Open a window
-    if (SDL_SetVideoMode (Options.video.width, Options.video.height, 32, flags) is null) {
+    SDL_Surface* surface;
+    if (Options.video.fullscreen) {
+        surface = SDL_SetVideoMode (Options.video.screenW, Options.video.screenH, 32, flags);
+    } else {
+        surface = SDL_SetVideoMode (Options.video.windowW, Options.video.windowH, 32, flags);
+    }
+    if (surface is null) {
         logger.fatal ("Unable to set video mode:");
         char* msg = SDL_GetError ();
         logger.fatal (msg ? fromStringz(msg) : "no reason available");
@@ -114,6 +121,20 @@
     logger.trace ("init4: setupWindow() finished");
 }
 
+void resizeWindow (int w, int h) {
+    if (Options.video.fullscreen) {
+        Options.video.screenW = w;
+        Options.video.screenH = h;
+    } else {
+        Options.video.windowW = w;
+        Options.video.windowH = h;
+    }
+    
+    /+ Does SDL_SetVideoMode need to be called?
+    setupWindow ();
+    +/
+}
+
 void cleanupSDL () {    // cleanup2 func
     logger.trace ("cleanup2: cleanupSDL() started");
     SDL_Quit();