Permalink
Browse files

Requested resolution may change during Graphics::Init, so make sure i…

…t is passed to Renderer as well
  • Loading branch information...
1 parent 5890a30 commit 5a97493372729d4533f7774826389cf4ab09cd12 @Luomu committed Sep 23, 2012
Showing with 9 additions and 12 deletions.
  1. +8 −11 src/graphics/Graphics.cpp
  2. +1 −1 src/graphics/Graphics.h
View
@@ -53,21 +53,18 @@ void UnbindAllBuffers()
BindArrayBuffer(0);
}
-Renderer* Init(const Settings &vs)
+Renderer* Init(Settings vs)
{
assert(!initted);
if (initted) return 0;
- int width = vs.width;
- int height = vs.height;
-
// no mode set, find an ok one
- if ((width <= 0) || (height <= 0)) {
+ if ((vs.width <= 0) || (vs.height <= 0)) {
const std::vector<VideoMode> modes = GetAvailableVideoModes();
assert(!modes.empty());
- width = modes.front().width;
- height = modes.front().height;
+ vs.width = modes.front().width;
+ vs.height = modes.front().height;
}
const SDL_VideoInfo *info = SDL_GetVideoInfo();
@@ -100,15 +97,15 @@ Renderer* Init(const Settings &vs)
// attempt sequence is:
// 1- requested mode
- SDL_Surface *scrSurface = SDL_SetVideoMode(width, height, info->vfmt->BitsPerPixel, flags);
+ SDL_Surface *scrSurface = SDL_SetVideoMode(vs.width, vs.height, info->vfmt->BitsPerPixel, flags);
// 2- requested mode with no anti-aliasing (skipped if no AA was requested anyway)
if (!scrSurface && vs.requestedSamples) {
fprintf(stderr, "Failed to set video mode. (%s). Re-trying without multisampling.\n", SDL_GetError());
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
- scrSurface = SDL_SetVideoMode(width, height, info->vfmt->BitsPerPixel, flags);
+ scrSurface = SDL_SetVideoMode(vs.width, vs.height, info->vfmt->BitsPerPixel, flags);
}
// 3- requested mode with 16 bit depth buffer
@@ -118,7 +115,7 @@ Renderer* Init(const Settings &vs)
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, vs.requestedSamples);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
- scrSurface = SDL_SetVideoMode(width, height, info->vfmt->BitsPerPixel, flags);
+ scrSurface = SDL_SetVideoMode(vs.width, vs.height, info->vfmt->BitsPerPixel, flags);
}
// 4- requested mode with 16-bit depth buffer and no anti-aliasing
@@ -129,7 +126,7 @@ Renderer* Init(const Settings &vs)
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
- scrSurface = SDL_SetVideoMode(width, height, info->vfmt->BitsPerPixel, flags);
+ scrSurface = SDL_SetVideoMode(vs.width, vs.height, info->vfmt->BitsPerPixel, flags);
}
// 5- abort!
View
@@ -53,7 +53,7 @@ namespace Graphics {
extern Material *vtxColorMaterial;
// does SDL video init, constructs appropriate Renderer
- Renderer* Init(const Settings&);
+ Renderer* Init(Settings);
void Uninit();
bool AreShadersEnabled();
std::vector<VideoMode> GetAvailableVideoModes();

0 comments on commit 5a97493

Please sign in to comment.