Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/video.cc')
-rw-r--r--src/client/video.cc31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/client/video.cc b/src/client/video.cc
index f3ba136..b7eb325 100644
--- a/src/client/video.cc
+++ b/src/client/video.cc
@@ -52,6 +52,7 @@ const int height_default = 768;
SDL_Window* sdlwindow = 0;
Uint32 sdlwindow_flags = 0;
+SDL_GLContext glcontext = 0;
std::string loader_message;
bool is_loading = false;
@@ -167,7 +168,7 @@ bool init()
}
else
{
- if (r_windowwidth->value() && r_windowheight->value())
+ if ((r_windowwidth->value() > 0.0f) && (r_windowheight->value() > 0.0f))
{
width = (int) r_windowwidth->value();
height = (int) r_windowheight->value();
@@ -177,10 +178,7 @@ bool init()
width = width_default;
height = height_default;
}
- sdlwindow_flags = SDL_WINDOW_OPENGL;
-#ifndef _WIN32
- sdlwindow_flags |= SDL_WINDOW_RESIZABLE;
-#endif
+ sdlwindow_flags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE;
sdlwindow = SDL_CreateWindow(sdlwindow_title.c_str(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, sdlwindow_flags);
}
@@ -190,7 +188,7 @@ bool init()
return false;
}
- SDL_GLContext glcontext = SDL_GL_CreateContext(sdlwindow);
+ glcontext = SDL_GL_CreateContext(sdlwindow);
if (!glcontext)
{
con_error << "Failed to initialize OpenGL context: " << SDL_GetError() << std::endl;
@@ -204,8 +202,8 @@ bool init()
(*r_width) = width;
(*r_height) = height;
} else {
- (*r_windowwidth) = width;
- (*r_windowwidth) = height;
+ (*r_windowwidth) = (float) width;
+ (*r_windowheight) = (float) height;
}
// resize user interface
ui::root()->set_size((float) width, (float) height);
@@ -234,11 +232,18 @@ bool init()
return true;
}
-void resize(int w, int h)
+void resize(const Uint32 sdlwindow_id, int w, int h)
{
if (fullscreen)
+ {
return;
+ }
+ if (SDL_GetWindowID(sdlwindow) != sdlwindow_id)
+ {
+ return;
+ }
+
if (w < 320) w = 320;
if (h < 200) h = 200;
@@ -246,8 +251,8 @@ void resize(int w, int h)
ui::root()->set_size(w, h);
ui::root()->event_resize();
- (*r_windowwidth) = w;
- (*r_windowwidth) = h;
+ (*r_windowwidth) = (float) w;
+ (*r_windowheight) = (float) h;
}
void restart()
@@ -377,7 +382,11 @@ void shutdown()
SDL_SetRelativeMouseMode(SDL_FALSE);
+ SDL_GL_DeleteContext(glcontext);
+ glcontext = 0;
+
SDL_DestroyWindow(sdlwindow);
+ sdlwindow = 0;
SDL_QuitSubSystem(SDL_INIT_VIDEO);