src/Application.cc
changeset 408 e6cfc44266af
parent 397 13fa0546ef87
child 409 1a03ff151abc
equal deleted inserted replaced
407:443f6f7abcfb 408:e6cfc44266af
    54     // set defaults
    54     // set defaults
    55     arg_graphics = false;
    55     arg_graphics = false;
    56     arg_port = NETWORK_PORT_STR;
    56     arg_port = NETWORK_PORT_STR;
    57     arg_server = false;
    57     arg_server = false;
    58     arg_connect = "";
    58     arg_connect = "";
    59     arg_fullscreen = GRAPHICS_FULLSCREEN;
    59     graphics.fullscreen = GRAPHICS_FULLSCREEN;
    60     arg_resolution = PixelCoordinate(GRAPHICS_RESOLUTION_WIDTH, GRAPHICS_RESOLUTION_HEIGHT);
    60     graphics.resolution = PixelCoordinate(GRAPHICS_RESOLUTION_WIDTH, GRAPHICS_RESOLUTION_HEIGHT);
    61 
    61 
    62     // extra state
    62     // extra state
    63     bool resolution_default = true;
    63     bool resolution_default = true;
    64     
    64     
    65     try {
    65     try {
    91             case ARG_GRAPHICS:
    91             case ARG_GRAPHICS:
    92                 arg_graphics = true;
    92                 arg_graphics = true;
    93                 break;
    93                 break;
    94 
    94 
    95             case ARG_FULLSCREEN:
    95             case ARG_FULLSCREEN:
    96                 arg_fullscreen = true;
    96                 graphics.fullscreen = true;
    97                 
    97                 
    98                 // choose best resolution unless explicitly set
    98                 // choose best resolution unless explicitly set
    99                 if (resolution_default) {
    99                 if (resolution_default) {
   100                     const CL_DisplayMode best_mode = Graphics::getBestMode();
   100                     const CL_DisplayMode best_mode = Graphics::getBestMode();
   101                     const CL_Size best_resolution = best_mode.get_resolution();
   101                     const CL_Size best_resolution = best_mode.get_resolution();
   102 
   102 
   103                     arg_resolution = PixelCoordinate(best_resolution.width, best_resolution.height);
   103                     graphics.resolution = PixelCoordinate(best_resolution.width, best_resolution.height);
   104                 }
   104                 }
   105 
   105 
   106                 break;
   106                 break;
   107 
   107 
   108             case ARG_RESOLUTION:
   108             case ARG_RESOLUTION:
   145     // sccanf as unsigned
   145     // sccanf as unsigned
   146     if (sscanf(val.c_str(), "%ux%u", &w, &h) != 2)
   146     if (sscanf(val.c_str(), "%ux%u", &w, &h) != 2)
   147         throw ArgumentError("invalid format for --resolution");
   147         throw ArgumentError("invalid format for --resolution");
   148     
   148     
   149     // store as PixelCoordinate
   149     // store as PixelCoordinate
   150     arg_resolution = PixelCoordinate(w, h);
   150     graphics.resolution = PixelCoordinate(w, h);
   151 }
   151 }
   152         
   152         
   153 void Main::dump_display_modes (void) {
   153 void Main::dump_display_modes (void) {
   154     const std::vector<CL_DisplayMode> &modes = Graphics::getDisplayModes();
   154     const std::vector<CL_DisplayMode> &modes = Graphics::getDisplayModes();
   155     
   155     
   181         // our engine
   181         // our engine
   182         Engine engine;
   182         Engine engine;
   183         
   183         
   184         // setup graphics
   184         // setup graphics
   185         if (arg_graphics)
   185         if (arg_graphics)
   186             engine.setupGraphics(arg_resolution, arg_fullscreen);
   186             engine.setupGraphics(graphics);
   187 
   187 
   188         // setup either network server, client or singleplayer
   188         // setup either network server, client or singleplayer
   189         if (arg_server) {
   189         if (arg_server) {
   190             engine.setupNetworkServer(arg_port);
   190             engine.setupNetworkServer(arg_port);
   191 
   191