src/Graphics/Display.cc
branchnew_graphics
changeset 412 721c60072091
parent 411 106aaf6eadfe
child 413 7dddc163489a
equal deleted inserted replaced
411:106aaf6eadfe 412:721c60072091
     1 
     1 
     2 #include "Display.hh"
     2 #include "Display.hh"
       
     3 #include "../Error.hh"
     3 
     4 
     4 namespace graphics
     5 namespace graphics
     5 {
     6 {
     6 
     7 
     7 Display::Display (const DisplayConfig &config) :
     8 Display::Display (const DisplayConfig &config) :
    20         fullscreen_resolution = config.resolution;
    21         fullscreen_resolution = config.resolution;
    21 
    22 
    22     } else {
    23     } else {
    23         CL_DisplayMode best_mode = getBestMode();
    24         CL_DisplayMode best_mode = getBestMode();
    24 
    25 
    25         fullscreen_resolution = PixelCoordinate(best_mode.get_resolution().width, best_mode.get_resolution().height);
    26         fullscreen_resolution = PixelDimensions(best_mode.get_resolution().width, best_mode.get_resolution().height);
    26     }
    27     }
    27 }
    28 }
    28 
    29 
    29 const std::vector<CL_DisplayMode> & Display::getDisplayModes (void) {
    30 const std::vector<CL_DisplayMode> & Display::getDisplayModes (void) {
    30     return CL_DisplayMode::get_display_modes();
    31     return CL_DisplayMode::get_display_modes();
    31 }
    32 }
    32 
    33 
    33 const CL_DisplayMode Display::getBestMode (void) {
    34 const CL_DisplayMode Display::getBestMode (void) {
    34     const std::vector<CL_DisplayMode> &modes = Graphics::getDisplayModes();
    35     const std::vector<CL_DisplayMode> &modes = getDisplayModes();
    35 
    36 
    36     const CL_DisplayMode *best_mode = NULL;
    37     const CL_DisplayMode *best_mode = NULL;
    37     
    38     
    38     for (std::vector<CL_DisplayMode>::const_iterator it = modes.begin(); it != modes.end(); it++)
    39     for (std::vector<CL_DisplayMode>::const_iterator it = modes.begin(); it != modes.end(); it++)
    39         if (best_mode == NULL || (
    40         if (best_mode == NULL || (
    63     (void) dt;
    64     (void) dt;
    64 
    65 
    65     // do we have something to draw?
    66     // do we have something to draw?
    66     if (target) {
    67     if (target) {
    67         // draw it
    68         // draw it
    68         target->draw(this);
    69         target->draw(*this);
    69 
    70 
    70         // flip buffers, sync
    71         // flip buffers, sync
    71         flip(1);
    72         flip(1);
    72     }
    73     }
    73 }
    74 }
    74 
    75 
    75 void Display::on_window_resize (int new_x, int new_y) {
    76 void Display::on_window_resize (int new_x, int new_y) {
       
    77     (void) new_x;
       
    78     (void) new_y;
       
    79 
    76     // ignore resize in fullscreen mode
    80     // ignore resize in fullscreen mode
    77     if (is_fullscreen())
    81     if (is_fullscreen())
    78         return;
    82         return;
    79 }
    83 }
    80 
    84