terom@410: #ifndef GRAPHICS_DISPLAY_HH terom@410: #define GRAPHICS_DISPLAY_HH terom@410: terom@410: #include "../Types.hh" terom@410: #include "../Config.hh" terom@410: #include "../Timer.hh" terom@410: terom@410: #include 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@410: }; terom@410: 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 engine reference terom@410: */ terom@410: Engine &engine; terom@410: terom@410: /** terom@410: * Our configuration terom@410: */ terom@410: DisplayConfig config; terom@410: terom@410: /** terom@410: * Our timer that drives redraws terom@410: */ terom@410: Timer update_timer; terom@410: 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@410: Display (Engine &engine, const DisplayConfig &config) : terom@410: engine(engine), config(config), update_timer(GRAPHICS_UPDATE_INTERVAL_MS) terom@410: { terom@410: // connect timer signal terom@410: slots.connect(update_timer.sig_tick(), this, &Display::on_update); terom@410: slots.connect(this->sig_resize(), this, &Display::on_window_resize); terom@410: terom@410: } 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@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