8 Display::Display (const DisplayConfig &config) : |
8 Display::Display (const DisplayConfig &config) : |
9 CL_DisplayWindow(GRAPHICS_WINDOW_TITLE, config.resolution.width, config.resolution.height, config.fullscreen, true), |
9 CL_DisplayWindow(GRAPHICS_WINDOW_TITLE, config.resolution.width, config.resolution.height, config.fullscreen, true), |
10 config(config), |
10 config(config), |
11 fullscreen_resolution(0, 0), |
11 fullscreen_resolution(0, 0), |
12 update_timer(GRAPHICS_UPDATE_INTERVAL_MS), |
12 update_timer(GRAPHICS_UPDATE_INTERVAL_MS), |
13 target(NULL) |
13 current_view(NULL) |
14 { |
14 { |
15 // connect timer signal |
15 // connect timer signal |
16 slots.connect(update_timer.sig_tick(), this, &Display::on_update); |
16 slots.connect(update_timer.sig_tick(), this, &Display::on_update); |
17 slots.connect(this->sig_resize(), this, &Display::on_window_resize); |
17 slots.connect(this->sig_resize(), this, &Display::on_window_resize); |
|
18 |
|
19 // enable timer |
|
20 update_timer.start(); |
18 |
21 |
19 // set correct fullscreen resolution |
22 // set correct fullscreen resolution |
20 if (config.fullscreen) { |
23 if (config.fullscreen) { |
21 fullscreen_resolution = config.resolution; |
24 fullscreen_resolution = config.resolution; |
22 |
25 |
47 throw Error("No available video modes!"); |
50 throw Error("No available video modes!"); |
48 |
51 |
49 return *best_mode; |
52 return *best_mode; |
50 } |
53 } |
51 |
54 |
|
55 void Display::setView (View *view) { |
|
56 this->current_view = view; |
|
57 |
|
58 // resize to fill display |
|
59 if (view) |
|
60 view->resize(PixelArea(0, 0, get_width(), get_height())); |
|
61 } |
|
62 |
52 void Display::toggle_fullscreen (void) { |
63 void Display::toggle_fullscreen (void) { |
53 if (is_fullscreen()) { |
64 if (is_fullscreen()) { |
54 // enter windowed mode |
65 // enter windowed mode |
55 set_windowed(); |
66 set_windowed(); |
56 |
67 |