{
case SDL_WINDOWEVENT_FOCUS_GAINED:
window_focus = true;
- Graphix::catchMouse();
+ Graphix::hideMouse(true);
break;
case SDL_WINDOWEVENT_FOCUS_LOST:
window_focus = false;
- Graphix::freeMouse();
+ Graphix::hideMouse(false);
break;
case SDL_WINDOWEVENT_RESIZED:
Graphix::setWindowSize(sdl_event.window.data1, sdl_event.window.data2);
//TRANSPARENCY
break;
case SDLK_F10:
- //???
+ //??? FullScreen
+ if (key_toggle[SDLK_F10])
+ Graphix::FullScreen(false,true);
+ else
+ Graphix::FullScreen(true,true);
break;
case SDLK_SPACE:
jump++;
Message::error((string)"glewInit: " + (char*)glewGetErrorString(err));
}
+ SDL_ShowCursor(SDL_DISABLE);
+
glEnable(GL_DEPTH_TEST);
//SDL_SetWindowGrab(sdl_window, SDL_TRUE);
shader_BBox = new Shader("basic_VS.hlsl", "basic_FS.hlsl");
}
+void Graphix::FullScreen(bool _enable, bool _keepDesktopResolution)
+{
+ if (_enable)
+ {
+ if (_keepDesktopResolution)
+ {
+ width_bkp = width;
+ height_bkp = height;
+
+ SDL_DisplayMode dm;
+ if (SDL_GetDesktopDisplayMode(0, &dm) != 0)
+ Message::error((string)"SDL_GetDesktopDisplayMode failed:" + SDL_GetError());
+
+ width = dm.w;
+ height = dm.h;
+
+ SDL_SetWindowSize(sdl_window, width, height);
+ }
+ SDL_SetWindowFullscreen(sdl_window, SDL_WINDOW_FULLSCREEN);
+ }
+ else
+ {
+ if (_keepDesktopResolution && width_bkp !=0)
+ {
+ width = width_bkp;
+ height = height_bkp;
+
+ SDL_SetWindowSize(sdl_window, width, height);
+ }
+ SDL_SetWindowFullscreen(sdl_window, 0);
+ }
+
+}
+
void Graphix::catchMouse()
{
- SDL_SetWindowGrab(sdl_window, SDL_TRUE);
+ //SDL_SetWindowGrab(sdl_window, SDL_TRUE);
SDL_ShowCursor(SDL_DISABLE); //TODO eventuell nicht nötig
}
void Graphix::freeMouse()
{
- SDL_SetWindowGrab(sdl_window, SDL_FALSE);
+ //SDL_SetWindowGrab(sdl_window, SDL_FALSE);
SDL_ShowCursor(SDL_ENABLE); //TODO eventuell nicht nötig
}
+void Graphix::hideMouse(bool _enable)
+{
+ if (_enable)
+ SDL_ShowCursor(SDL_DISABLE);
+ else
+ SDL_ShowCursor(SDL_ENABLE);
+}
+
void Graphix::clear()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
{
delete shader_BBox;
- SDL_SetWindowGrab(sdl_window, SDL_FALSE);
+ //SDL_SetWindowGrab(sdl_window, SDL_FALSE);
SDL_GL_DeleteContext(sdl_glcontext);
SDL_DestroyWindow(sdl_window);
unsigned int Graphix::width = 1024;
unsigned int Graphix::height = 768;
-unsigned int Graphix::xpos = 200;
-unsigned int Graphix::ypos = 100;
+unsigned int Graphix::xpos = SDL_WINDOWPOS_UNDEFINED;
+unsigned int Graphix::ypos = SDL_WINDOWPOS_UNDEFINED;
+
+unsigned int Graphix::width_bkp = 0;
+unsigned int Graphix::height_bkp = 0;
string Graphix::windowTitle = "Weave";
-Uint32 Graphix::windowFlags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE;
+Uint32 Graphix::windowFlags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_INPUT_GRABBED;
Uint32 Graphix::sdlFlags = SDL_INIT_VIDEO | SDL_INIT_TIMER;
SDL_Window* Graphix::sdl_window;
static unsigned int getWindowHeight();
static unsigned int getWindowWidth();
+ static void FullScreen(bool enable, bool keepDesktopResolution = true);
+
static void catchMouse();
static void freeMouse();
+ static void hideMouse(bool enable = true);
static void enableEffects(Effects eff);
static void disableEffects(Effects eff);
static Shader* shader_BBox;
private:
- static unsigned int width;
- static unsigned int height;
-
- static unsigned int xpos;
- static unsigned int ypos;
+ static unsigned int xpos, ypos, width, height;
+ static unsigned int width_bkp, height_bkp;
static std::string windowTitle;