X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Finit.cpp;h=4772898fb364119cb53f469b32984c445bf0e722;hb=ea1ce7b0fb7709ae56977480821ac96a231a0686;hp=9010e00ba6b26c50d71514a96d48332f78d94d3c;hpb=918b4955c28fad1836a57ab3e9e033448144996c;p=blank.git diff --git a/src/init.cpp b/src/init.cpp index 9010e00..4772898 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -34,6 +35,17 @@ InitSDL::~InitSDL() { } +InitIMG::InitIMG() { + if (IMG_Init(IMG_INIT_PNG) == 0) { + sdl_error("IMG_Init(IMG_INIT_PNG)"); + } +} + +InitIMG::~InitIMG() { + IMG_Quit(); +} + + InitGL::InitGL() { if (SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3) != 0) { sdl_error("SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3)"); @@ -71,6 +83,26 @@ Window::~Window() { SDL_DestroyWindow(handle); } +void Window::GrabInput() { + SDL_SetWindowGrab(handle, SDL_TRUE); +} + +void Window::ReleaseInput() { + SDL_SetWindowGrab(handle, SDL_FALSE); +} + +void Window::GrabMouse() { + if (SDL_SetRelativeMouseMode(SDL_TRUE) != 0) { + sdl_error("SDL_SetRelativeMouseMode"); + } +} + +void Window::ReleaseMouse() { + if (SDL_SetRelativeMouseMode(SDL_FALSE) != 0) { + sdl_error("SDL_SetRelativeMouseMode"); + } +} + GLContext Window::CreateContext() { return GLContext(handle); }