diff mde/setup/Screen.d @ 86:79d816b3e2d2

New InitStage system, Screen & Screen.Drawable, separate testing and guiDemo binaries. This (and the previous) commit are the result of several quite significant changes to mde. All the unittests run, but it hasn't had a huge amount of testing so don't be surprised if bugs show up.
author Diggory Hardy <diggory.hardy@gmail.com>
date Fri, 12 Sep 2008 17:36:14 +0100
parents 56c0ddd90193
children 4d5d53e4f881
line wrap: on
line diff
--- a/mde/setup/Screen.d	Thu Sep 11 11:33:51 2008 +0100
+++ b/mde/setup/Screen.d	Fri Sep 12 17:36:14 2008 +0100
@@ -35,7 +35,7 @@
 struct Screen {
     // TYPES (these mustn't be static):
     /** Interface for anything hooking into the screen for drawing, etc. */
-    interface Drawable {
+    interface IDrawable {
         /** Called on window creation and whenever the window manager resizes the window, before
          * the new size is set. The new size is passed.
          *
@@ -63,7 +63,6 @@
             
             throw new InitException ("SDL Initialization failed");
         }
-        debug logger.trace ("SDL initialised");
         return StageState.ACTIVE;
     }
     /** SDL shutdown */
@@ -99,7 +98,6 @@
         SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1);
         
         // Open a window
-        debug logger.trace ("Opening a window (this can crash if the libraries are messed up)");
         if (setWindow (w, h)) {
             throw new InitException ("Failed to open a window");
         }
@@ -169,11 +167,12 @@
             imde.run = false;
     }
     
-    /** Add a drawable element to the screen (see Drawable interface).
+    /** Add a drawable element to the screen (see IDrawable interface).
      *
-     * Should be called before Init to get initial size. Currently no means to remove drawables,
-     * and not really designed for more than one. */
-    void addDrawable (Drawable d) {
+     * Should be called before Init to get the initial size (sizeEvent is only called when the size
+     * is set). Currently no means to remove drawables, and not really designed for more than one.
+     */
+    void addDrawable (IDrawable d) {
         drawables ~= d;
     }
     
@@ -181,13 +180,10 @@
     void draw (TimeSpan) {
         glClear(GL_COLOR_BUFFER_BIT);
         
-        foreach (Drawable d; drawables)
+        foreach (IDrawable d; drawables)
             d.draw;
         
-        debug (drawGlyphCache) {
-            logger.trace ("Drawing font texture");
-            FontStyle.drawTexture;
-        }
+        debug (drawGlyphCache) FontStyle.drawTexture;
         
         // Error check:
         GLenum err = glGetError();
@@ -206,7 +202,7 @@
         foreach (d; drawables)  // Tell all drawables the new window size.
             d.sizeEvent (w,h);
         
-        debug logger.trace ("Setting video mode {}x{}, 32-bit, flags: {}", w,h,flags);
+        //debug logger.trace ("Setting video mode {}x{}, 32-bit, flags: {}", w,h,flags);
         if (SDL_SetVideoMode (w, h, 32, flags) is null) {
             logger.fatal ("Unable to set video mode:");
             char* msg = SDL_GetError ();
@@ -263,7 +259,7 @@
     // DATA:
 private:
     uint flags = 0;
-    Drawable[] drawables;
+    IDrawable[] drawables;
     Logger logger;
     OptionsVideo vidOpts;
 }