| 392 | |
| 393 | |
| 394 | bool SDLDisplay::createWindow() { |
| 395 | int width; |
| 396 | int height; |
| 397 | Uint32 flags = SDL_OPENGL; |
| 398 | |
| 399 | /* anti-aliasing */ |
| 400 | if (BZDB.isSet("multisamples")) { |
| 401 | int ms = BZDB.evalInt("multisamples"); |
| 402 | if (ms == 2 || ms == 4) { |
| 403 | SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); |
| 404 | SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, ms); |
| 405 | } |
| 406 | } |
| 407 | |
| 408 | // getting width, height & flags for SetVideoMode |
| 409 | getWindowSize(width, height); |
| 410 | if (fullScreen) { |
| 411 | flags |= SDL_FULLSCREEN; |
| 412 | } |
| 413 | else { |
| 414 | flags |= SDL_RESIZABLE; |
| 415 | } |
| 416 | |
| 417 | // if they are the same, don't bother building a new window |
| 418 | if ((width == oldWidth) && |
| 419 | (height == oldHeight) && |
| 420 | (fullScreen == oldFullScreen)) { |
| 421 | return true; |
| 422 | } |
| 423 | |
| 424 | // save the values for the next |
| 425 | oldWidth = width; |
| 426 | oldHeight = height; |
| 427 | oldFullScreen = fullScreen; |
| 428 | |
| 429 | // Set the video mode and hope for no errors |
| 430 | if (!SDL_SetVideoMode(width, height, 0, flags)) { |
| 431 | printf("Could not set Video Mode: %s.\n", SDL_GetError()); |
| 432 | return false; |
| 433 | } |
| 434 | else { |
| 435 | return true; |
| 436 | } |
| 437 | } |
| 438 | |
| 439 | |
| 440 | void SDLDisplay::setFullscreen(bool on) { |
no test coverage detected