port Input to new Graphics, still a bit hacky, but everything seems to work now
#ifndef GRAPHICS_DISPLAY_HH
#define GRAPHICS_DISPLAY_HH
#include "../Types.hh"
#include "../Config.hh"
namespace graphics
{
struct DisplayConfig {
/** Display resolution */
PixelDimensions resolution;
/** Fullscreen mode? */
bool fullscreen;
/** Defaults */
DisplayConfig (void) : resolution(GRAPHICS_RESOLUTION_WIDTH, GRAPHICS_RESOLUTION_HEIGHT), fullscreen(GRAPHICS_FULLSCREEN) { }
};
class Display;
}
#include "View.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 configuration
*/
DisplayConfig config;
/**
* Target fullscreen resolution
*/
PixelDimensions fullscreen_resolution;
/**
* Our timer that drives redraws
*/
Timer update_timer;
/**
* What we draw
*/
View *current_view;
CL_SlotContainer slots;
public:
/**
* Construct default display, empty window unless otherwise build
*/
Display (const DisplayConfig &config);
/**
* Returns a vector of CL_DisplayModes that lists possible display modes to use for fullscreen mode.
*/
static const std::vector<CL_DisplayMode> & getDisplayModes (void);
/**
* Returns the "best" CL_DisplayMode to use for fullscreen mode.
*
* Currently, this just means the largest resolution.
*/
static const CL_DisplayMode getBestMode (void);
/**
* Get current resolution
*
* XXX: should be PixelDimensions...
*/
PixelCoordinate getResolution (void) {
return PixelCoordinate(get_width(), get_height());
}
/**
* Display the given view, this will initialize resize it to the right size
*/
void setView (View *view);
/**
* Shift back and forth between fullscreen and windowed mode, retaining resolutions
*/
void toggleFullscreen (void);
private:
/**
* Draw next frame
*/
void on_update (TimeMS dt);
/**
* Handles window resize. This just updates resolution
*/
void on_window_resize (int new_x, int new_y);
};
}
#endif