123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- /*!
- * \file src/system/Window.cpp
- * \brief Windowing Interface
- *
- * \author xythobuz
- */
-
- #include "global.h"
- #include "Camera.h"
- #include "UI.h"
- #include "system/Window.h"
-
- #ifdef USING_SDL
- #include "system/WindowSDL.h"
- #elif defined(USING_GLFW)
- #include "system/WindowGLFW.h"
- #else
- #error "No windowing library selected!"
- #endif
-
- #include <glbinding/gl/gl.h>
-
- int Window::initialize() {
- int res;
-
- #ifdef USING_SDL
- res = WindowSDL::initialize();
- #elif defined(USING_GLFW)
- res = WindowGLFW::initialize();
- #else
- res = -1;
- #endif
-
- return res;
- }
-
- void Window::eventHandling() {
- #ifdef USING_SDL
- WindowSDL::eventHandling();
- #elif defined(USING_GLFW)
- WindowGLFW::eventHandling();
- #endif
- }
-
- void Window::swapBuffers() {
- #ifdef USING_SDL
- WindowSDL::swapBuffers();
- #elif defined(USING_GLFW)
- WindowGLFW::swapBuffers();
- #endif
- }
-
- void Window::shutdown() {
- #ifdef USING_SDL
- WindowSDL::shutdown();
- #elif defined(USING_GLFW)
- WindowGLFW::shutdown();
- #endif
- }
-
- void Window::setSize(glm::i32vec2 s) {
- #ifdef USING_SDL
- WindowSDL::setSize(s);
- #elif defined(USING_GLFW)
- WindowGLFW::setSize(s);
- #endif
-
- UI::setSize(s);
- Camera::setSize(s);
- gl::glViewport(0, 0, s.x, s.y);
- }
-
- glm::i32vec2 Window::getSize() {
- glm::i32vec2 ret(-1, -1);
-
- #ifdef USING_SDL
- ret = WindowSDL::getSize();
- #elif defined(USING_GLFW)
- ret = WindowGLFW::getSize();
- #endif
-
- return ret;
- }
-
- void Window::setFullscreen(bool f) {
- #ifdef USING_SDL
- WindowSDL::setFullscreen(f);
- #elif defined(USING_GLFW)
- WindowGLFW::setFullscreen(f);
- #endif
- }
-
- bool Window::getFullscreen() {
- bool ret;
-
- #ifdef USING_SDL
- ret = WindowSDL::getFullscreen();
- #elif defined(USING_GLFW)
- ret = WindowGLFW::getFullscreen();
- #else
- ret = false;
- #endif
-
- return ret;
- }
-
- void Window::setMousegrab(bool g) {
- #ifdef USING_SDL
- WindowSDL::setMousegrab(g);
- #elif defined(USING_GLFW)
- WindowGLFW::setMousegrab(g);
- #endif
- }
-
- bool Window::getMousegrab() {
- bool ret;
-
- #ifdef USING_SDL
- ret = WindowSDL::getMousegrab();
- #elif defined(USING_GLFW)
- ret = WindowGLFW::getMousegrab();
- #else
- ret = false;
- #endif
-
- return ret;
- }
-
- void Window::setTextInput(bool t) {
- #ifdef USING_SDL
- WindowSDL::setTextInput(t);
- #elif defined(USING_GLFW)
- WindowGLFW::setTextInput(t);
- #endif
- }
-
- bool Window::getTextInput() {
- bool ret;
-
- #ifdef USING_SDL
- ret = WindowSDL::getTextInput();
- #elif defined(USING_GLFW)
- ret = WindowGLFW::getTextInput();
- #else
- ret = false;
- #endif
-
- return ret;
- }
-
- void Window::setClipboard(const char* s) {
- #ifdef USING_SDL
- WindowSDL::setClipboard(s);
- #elif defined(USING_GLFW)
- WindowGLFW::setClipboard(s);
- #endif
- }
-
- const char* Window::getClipboard() {
- const char* ret;
-
- #ifdef USING_SDL
- ret = WindowSDL::getClipboard();
- #elif defined(USING_GLFW)
- ret = WindowGLFW::getClipboard();
- #else
- ret = nullptr;
- #endif
-
- return ret;
- }
-
- void Window::inputPositionCallback(int x, int y) {
- #ifdef USING_SDL
- WindowSDL::inputPositionCallback(x, y);
- #elif defined(USING_GLFW)
- WindowGLFW::inputPositionCallback(x, y);
- #endif
- }
-
- std::string Window::getVersion(bool linked) {
- std::string ret;
-
- #ifdef USING_SDL
- ret = WindowSDL::getVersion(linked);
- #elif defined(USING_GLFW)
- ret = WindowGLFW::getVersion(linked);
- #endif
-
- return ret;
- }
|