terom@410: #ifndef GRAPHICS_DISPLAY_HH terom@410: #define GRAPHICS_DISPLAY_HH terom@410: terom@412: #include "../Types.hh" terom@412: #include "../Config.hh" terom@412: terom@410: namespace graphics terom@410: { terom@410: terom@411: class Display; terom@411: terom@411: } terom@411: terom@413: #include "View.hh" terom@411: #include "../Timer.hh" terom@417: #include "../Configuration.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@413: View *current_view; 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@413: * Display the given view, this will initialize resize it to the right size terom@411: */ terom@413: void setView (View *view); terom@411: terom@411: /** terom@411: * Shift back and forth between fullscreen and windowed mode, retaining resolutions terom@411: */ terom@414: void toggleFullscreen (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