[Fix] Needs a better fix. But fullscreen is working again!

This commit is contained in:
Allanis 2013-03-23 03:19:46 +00:00
parent afe8fd40d6
commit 4fead727b4

View File

@ -538,14 +538,17 @@ void gl_drawCircleInRect(const double cx, const double cy, const double r,
// Initialize SDL/OpenGL etc.
int gl_init(void) {
int doublebuf, depth, i, j, off, toff, supported = 0;
int doublebuf, depth, i, j, off, toff, supported;
SDL_Rect** modes;
int flags = SDL_OPENGL;
flags |= SDL_FULLSCREEN * (gl_has(OPENGL_FULLSCREEN) ? 1: 0);
supported = 0;
modes = NULL;
// Initializes video.
if(SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) {
WARN("Unable to initialize SDL: %s", SDL_GetError());
WARN("Unable to initialize SDL Video: %s", SDL_GetError());
return -1;
}
@ -590,23 +593,22 @@ int gl_init(void) {
gl_screen.w = modes[j]->w;
gl_screen.h = modes[j]->h;
}
// Free the video modes.
for(i = 0; modes[i]; ++i)
free(modes[i]);
free(modes);
}
// Test the setup.
// Test the setup - aim for 32.
depth = SDL_VideoModeOK(gl_screen.w, gl_screen.h, gl_screen.depth, flags);
if(depth == 0)
WARN("Video mode %dx%d @ %d bpp not supported"
" going to try to create it anyway...",
gl_screen.w, gl_screen.h, gl_screen.depth);
if(depth != gl_screen.depth)
WARN("Depth: %d bpp unavailable, will use %d bpp", gl_screen.depth, depth);
LOG("Depth: %d bpp unavailable, will use %d bpp", gl_screen.depth, depth);
gl_screen.depth = depth;
// Actually creating the screen.
if(SDL_SetVideoMode(gl_screen.w, gl_screen.h, gl_screen.depth, flags) == NULL) {
ERR("Unable to create OpenGL window: %s", SDL_GetError());
SDL_Quit();
return -1;
}
@ -648,6 +650,14 @@ int gl_init(void) {
glClear(GL_COLOR_BUFFER_BIT);
// Cleanup.
if(modes != NULL) {
// Free the modes.
for(i = 0; modes[i]; ++i)
free(modes[i]);
free(modes);
}
return 0;
}