terom@410: #ifndef GRAPHICS_DISPLAY_HH terom@410: #define GRAPHICS_DISPLAY_HH terom@410: terom@410: namespace graphics terom@410: { terom@410: terom@410: struct DisplayConfig { terom@410: /** Display resolution */ terom@410: PixelDimensions resolution; terom@410: terom@410: /** Fullscreen mode? */ terom@410: bool fullscreen; terom@411: terom@411: /** Defaults */ terom@411: DisplayConfig (void) : resolution(GRAPHICS_RESOLUTION_WIDTH, GRAPHICS_RESOLUTION_HEIGHT), fullscreen(GRAPHICS_FULLSCREEN) { } terom@410: }; terom@410: terom@411: class Display; terom@411: terom@411: } terom@411: terom@411: #include "Drawable.hh" terom@411: #include "../Types.hh" terom@411: #include "../Config.hh" terom@411: #include "../Timer.hh" terom@411: terom@411: #include terom@411: terom@411: namespace graphics terom@411: { terom@411: terom@410: /** terom@410: * We wrap ClanLib's DisplayWindow for our own functionality. This is the core of the graphics code terom@410: */ terom@410: class Display : public CL_DisplayWindow { terom@410: private: terom@410: /** terom@410: * Our configuration terom@410: */ terom@410: DisplayConfig config; terom@411: terom@411: /** terom@411: * Target fullscreen resolution terom@411: */ terom@411: PixelDimensions fullscreen_resolution; terom@410: terom@410: /** terom@410: * Our timer that drives redraws terom@410: */ terom@410: Timer update_timer; terom@410: terom@411: /** terom@411: * What we draw terom@411: */ terom@411: Drawable *target; terom@411: terom@410: CL_SlotContainer slots; terom@410: terom@410: public: terom@410: /** terom@410: * Construct default display, empty window unless otherwise build terom@410: */ terom@411: Display (const DisplayConfig &config); terom@410: terom@410: /** terom@410: * Returns a vector of CL_DisplayModes that lists possible display modes to use for fullscreen mode. terom@410: */ terom@410: static const std::vector & getDisplayModes (void); terom@410: terom@410: /** terom@410: * Returns the "best" CL_DisplayMode to use for fullscreen mode. terom@410: * terom@410: * Currently, this just means the largest resolution. terom@410: */ terom@410: static const CL_DisplayMode getBestMode (void); terom@410: terom@410: /** terom@410: * Get current resolution terom@410: * terom@410: * XXX: should be PixelDimensions... terom@410: */ terom@410: PixelCoordinate getResolution (void) { terom@410: return PixelCoordinate(get_width(), get_height()); terom@410: } terom@410: terom@411: /** terom@411: * Set draw target terom@411: */ terom@411: void setTarget (Drawable *target) { terom@411: this->target = target; terom@411: } terom@411: terom@411: /** terom@411: * Shift back and forth between fullscreen and windowed mode, retaining resolutions terom@411: */ terom@411: void toggle_fullscreen (void); terom@411: terom@410: private: terom@410: /** terom@410: * Draw next frame terom@410: */ terom@410: void on_update (TimeMS dt); terom@410: terom@410: /** terom@410: * Handles window resize. This just updates resolution terom@410: */ terom@410: void on_window_resize (int new_x, int new_y); terom@410: terom@410: }; terom@410: terom@410: } terom@410: terom@410: #endif