src/Graphics/Display.hh
branchnew_graphics
changeset 411 106aaf6eadfe
parent 410 41fd46cffc52
child 412 721c60072091
--- a/src/Graphics/Display.hh	Wed Jan 21 01:57:24 2009 +0200
+++ b/src/Graphics/Display.hh	Wed Jan 21 03:33:35 2009 +0200
@@ -1,12 +1,6 @@
 #ifndef GRAPHICS_DISPLAY_HH
 #define GRAPHICS_DISPLAY_HH
 
-#include "../Types.hh"
-#include "../Config.hh"
-#include "../Timer.hh"
-
-#include <ClanLib/display.h>
-
 namespace graphics
 {
 
@@ -16,42 +10,57 @@
 
     /** Fullscreen mode? */
     bool fullscreen;
+
+    /** Defaults */
+    DisplayConfig (void) : resolution(GRAPHICS_RESOLUTION_WIDTH, GRAPHICS_RESOLUTION_HEIGHT), fullscreen(GRAPHICS_FULLSCREEN) { }
 };
 
+class Display;
+
+}
+
+#include "Drawable.hh"
+#include "../Types.hh"
+#include "../Config.hh"
+#include "../Timer.hh"
+
+#include <ClanLib/display.h>
+
+namespace graphics
+{
+
 /**
  * We wrap ClanLib's DisplayWindow for our own functionality. This is the core of the graphics code
  */
 class Display : public CL_DisplayWindow {
 private:
     /**
-     * Our engine reference
-     */
-    Engine &engine;
-
-    /**
      * Our configuration
      */
     DisplayConfig config;
+
+    /**
+     * Target fullscreen resolution
+     */
+    PixelDimensions fullscreen_resolution;
     
     /**
      * Our timer that drives redraws
      */
     Timer update_timer;
 
+    /**
+     * What we draw
+     */
+    Drawable *target;
+
     CL_SlotContainer slots;
 
 public:
     /**
      * Construct default display, empty window unless otherwise build
      */
-    Display (Engine &engine, const DisplayConfig &config) :
-        engine(engine), config(config), update_timer(GRAPHICS_UPDATE_INTERVAL_MS)
-    {
-        // connect timer signal
-        slots.connect(update_timer.sig_tick(), this, &Display::on_update);
-        slots.connect(this->sig_resize(), this, &Display::on_window_resize);
-
-    }
+    Display (const DisplayConfig &config);
 
     /**
      * Returns a vector of CL_DisplayModes that lists possible display modes to use for fullscreen mode.
@@ -74,6 +83,18 @@
         return PixelCoordinate(get_width(), get_height());
     }
 
+    /**
+     * Set draw target
+     */
+    void setTarget (Drawable *target) {
+        this->target = target;
+    }
+
+    /**
+     * Shift back and forth between fullscreen and windowed mode, retaining resolutions
+     */
+    void toggle_fullscreen (void);
+
 private:
     /**
      * Draw next frame