author | Tero Marttila <terom@fixme.fi> |
Wed, 21 Jan 2009 23:07:22 +0200 | |
branch | new_graphics |
changeset 412 | 721c60072091 |
parent 411 | 106aaf6eadfe |
child 413 | 7dddc163489a |
permissions | -rw-r--r-- |
410
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
1 |
#ifndef GRAPHICS_DISPLAY_HH |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
2 |
#define GRAPHICS_DISPLAY_HH |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
3 |
|
412
721c60072091
new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents:
411
diff
changeset
|
4 |
#include "../Types.hh" |
721c60072091
new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents:
411
diff
changeset
|
5 |
#include "../Config.hh" |
721c60072091
new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents:
411
diff
changeset
|
6 |
|
410
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
7 |
namespace graphics |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
8 |
{ |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
9 |
|
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
10 |
struct DisplayConfig { |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
11 |
/** Display resolution */ |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
12 |
PixelDimensions resolution; |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
13 |
|
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
14 |
/** Fullscreen mode? */ |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
15 |
bool fullscreen; |
411
106aaf6eadfe
there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents:
410
diff
changeset
|
16 |
|
106aaf6eadfe
there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents:
410
diff
changeset
|
17 |
/** Defaults */ |
106aaf6eadfe
there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents:
410
diff
changeset
|
18 |
DisplayConfig (void) : resolution(GRAPHICS_RESOLUTION_WIDTH, GRAPHICS_RESOLUTION_HEIGHT), fullscreen(GRAPHICS_FULLSCREEN) { } |
410
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
19 |
}; |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
20 |
|
411
106aaf6eadfe
there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents:
410
diff
changeset
|
21 |
class Display; |
106aaf6eadfe
there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents:
410
diff
changeset
|
22 |
|
106aaf6eadfe
there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents:
410
diff
changeset
|
23 |
} |
106aaf6eadfe
there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents:
410
diff
changeset
|
24 |
|
106aaf6eadfe
there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents:
410
diff
changeset
|
25 |
#include "Drawable.hh" |
106aaf6eadfe
there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents:
410
diff
changeset
|
26 |
#include "../Timer.hh" |
106aaf6eadfe
there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents:
410
diff
changeset
|
27 |
|
106aaf6eadfe
there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents:
410
diff
changeset
|
28 |
#include <ClanLib/display.h> |
106aaf6eadfe
there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents:
410
diff
changeset
|
29 |
|
106aaf6eadfe
there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents:
410
diff
changeset
|
30 |
namespace graphics |
106aaf6eadfe
there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents:
410
diff
changeset
|
31 |
{ |
106aaf6eadfe
there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents:
410
diff
changeset
|
32 |
|
410
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
33 |
/** |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
34 |
* We wrap ClanLib's DisplayWindow for our own functionality. This is the core of the graphics code |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
35 |
*/ |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
36 |
class Display : public CL_DisplayWindow { |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
37 |
private: |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
38 |
/** |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
39 |
* Our configuration |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
40 |
*/ |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
41 |
DisplayConfig config; |
411
106aaf6eadfe
there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents:
410
diff
changeset
|
42 |
|
106aaf6eadfe
there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents:
410
diff
changeset
|
43 |
/** |
106aaf6eadfe
there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents:
410
diff
changeset
|
44 |
* Target fullscreen resolution |
106aaf6eadfe
there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents:
410
diff
changeset
|
45 |
*/ |
106aaf6eadfe
there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents:
410
diff
changeset
|
46 |
PixelDimensions fullscreen_resolution; |
410
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
47 |
|
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
48 |
/** |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
49 |
* Our timer that drives redraws |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
50 |
*/ |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
51 |
Timer update_timer; |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
52 |
|
411
106aaf6eadfe
there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents:
410
diff
changeset
|
53 |
/** |
106aaf6eadfe
there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents:
410
diff
changeset
|
54 |
* What we draw |
106aaf6eadfe
there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents:
410
diff
changeset
|
55 |
*/ |
106aaf6eadfe
there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents:
410
diff
changeset
|
56 |
Drawable *target; |
106aaf6eadfe
there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents:
410
diff
changeset
|
57 |
|
410
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
58 |
CL_SlotContainer slots; |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
59 |
|
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
60 |
public: |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
61 |
/** |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
62 |
* Construct default display, empty window unless otherwise build |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
63 |
*/ |
411
106aaf6eadfe
there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents:
410
diff
changeset
|
64 |
Display (const DisplayConfig &config); |
410
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
65 |
|
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
66 |
/** |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
67 |
* Returns a vector of CL_DisplayModes that lists possible display modes to use for fullscreen mode. |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
68 |
*/ |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
69 |
static const std::vector<CL_DisplayMode> & getDisplayModes (void); |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
70 |
|
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
71 |
/** |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
72 |
* Returns the "best" CL_DisplayMode to use for fullscreen mode. |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
73 |
* |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
74 |
* Currently, this just means the largest resolution. |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
75 |
*/ |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
76 |
static const CL_DisplayMode getBestMode (void); |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
77 |
|
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
78 |
/** |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
79 |
* Get current resolution |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
80 |
* |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
81 |
* XXX: should be PixelDimensions... |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
82 |
*/ |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
83 |
PixelCoordinate getResolution (void) { |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
84 |
return PixelCoordinate(get_width(), get_height()); |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
85 |
} |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
86 |
|
411
106aaf6eadfe
there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents:
410
diff
changeset
|
87 |
/** |
106aaf6eadfe
there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents:
410
diff
changeset
|
88 |
* Set draw target |
106aaf6eadfe
there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents:
410
diff
changeset
|
89 |
*/ |
106aaf6eadfe
there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents:
410
diff
changeset
|
90 |
void setTarget (Drawable *target) { |
106aaf6eadfe
there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents:
410
diff
changeset
|
91 |
this->target = target; |
106aaf6eadfe
there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents:
410
diff
changeset
|
92 |
} |
106aaf6eadfe
there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents:
410
diff
changeset
|
93 |
|
106aaf6eadfe
there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents:
410
diff
changeset
|
94 |
/** |
106aaf6eadfe
there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents:
410
diff
changeset
|
95 |
* Shift back and forth between fullscreen and windowed mode, retaining resolutions |
106aaf6eadfe
there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents:
410
diff
changeset
|
96 |
*/ |
106aaf6eadfe
there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents:
410
diff
changeset
|
97 |
void toggle_fullscreen (void); |
106aaf6eadfe
there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents:
410
diff
changeset
|
98 |
|
410
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
99 |
private: |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
100 |
/** |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
101 |
* Draw next frame |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
102 |
*/ |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
103 |
void on_update (TimeMS dt); |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
104 |
|
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
105 |
/** |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
106 |
* Handles window resize. This just updates resolution |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
107 |
*/ |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
108 |
void on_window_resize (int new_x, int new_y); |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
109 |
|
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
110 |
}; |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
111 |
|
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
112 |
} |
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
113 |
|
41fd46cffc52
start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
114 |
#endif |