Open Source Tomb Raider Engine
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

Window.cpp 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /*!
  2. * \file src/system/Window.cpp
  3. * \brief Windowing Interface
  4. *
  5. * \author xythobuz
  6. */
  7. #include "global.h"
  8. #include "Camera.h"
  9. #include "UI.h"
  10. #include "system/Window.h"
  11. #ifdef USING_SDL
  12. #include "system/WindowSDL.h"
  13. #elif defined(USING_GLFW)
  14. #include "system/WindowGLFW.h"
  15. #else
  16. #error "No windowing library selected!"
  17. #endif
  18. #include <glbinding/gl/gl33.h>
  19. int Window::initialize() {
  20. int res;
  21. #ifdef USING_SDL
  22. res = WindowSDL::initialize();
  23. #elif defined(USING_GLFW)
  24. res = WindowGLFW::initialize();
  25. #else
  26. res = -1;
  27. #endif
  28. return res;
  29. }
  30. void Window::eventHandling() {
  31. #ifdef USING_SDL
  32. WindowSDL::eventHandling();
  33. #elif defined(USING_GLFW)
  34. WindowGLFW::eventHandling();
  35. #endif
  36. }
  37. void Window::swapBuffers() {
  38. #ifdef USING_SDL
  39. WindowSDL::swapBuffers();
  40. #elif defined(USING_GLFW)
  41. WindowGLFW::swapBuffers();
  42. #endif
  43. }
  44. void Window::shutdown() {
  45. #ifdef USING_SDL
  46. WindowSDL::shutdown();
  47. #elif defined(USING_GLFW)
  48. WindowGLFW::shutdown();
  49. #endif
  50. }
  51. void Window::setSize(glm::i32vec2 s) {
  52. #ifdef USING_SDL
  53. WindowSDL::setSize(s);
  54. #elif defined(USING_GLFW)
  55. WindowGLFW::setSize(s);
  56. #endif
  57. UI::setSize(s);
  58. Camera::setSize(s);
  59. gl::glViewport(0, 0, s.x, s.y);
  60. }
  61. glm::i32vec2 Window::getSize() {
  62. glm::i32vec2 ret(-1, -1);
  63. #ifdef USING_SDL
  64. ret = WindowSDL::getSize();
  65. #elif defined(USING_GLFW)
  66. ret = WindowGLFW::getSize();
  67. #endif
  68. return ret;
  69. }
  70. void Window::setFullscreen(bool f) {
  71. #ifdef USING_SDL
  72. WindowSDL::setFullscreen(f);
  73. #elif defined(USING_GLFW)
  74. WindowGLFW::setFullscreen(f);
  75. #endif
  76. }
  77. bool Window::getFullscreen() {
  78. bool ret;
  79. #ifdef USING_SDL
  80. ret = WindowSDL::getFullscreen();
  81. #elif defined(USING_GLFW)
  82. ret = WindowGLFW::getFullscreen();
  83. #else
  84. ret = false;
  85. #endif
  86. return ret;
  87. }
  88. void Window::setMousegrab(bool g) {
  89. #ifdef USING_SDL
  90. WindowSDL::setMousegrab(g);
  91. #elif defined(USING_GLFW)
  92. WindowGLFW::setMousegrab(g);
  93. #endif
  94. }
  95. bool Window::getMousegrab() {
  96. bool ret;
  97. #ifdef USING_SDL
  98. ret = WindowSDL::getMousegrab();
  99. #elif defined(USING_GLFW)
  100. ret = WindowGLFW::getMousegrab();
  101. #else
  102. ret = false;
  103. #endif
  104. return ret;
  105. }
  106. void Window::setTextInput(bool t) {
  107. #ifdef USING_SDL
  108. WindowSDL::setTextInput(t);
  109. #elif defined(USING_GLFW)
  110. WindowGLFW::setTextInput(t);
  111. #endif
  112. }
  113. bool Window::getTextInput() {
  114. bool ret;
  115. #ifdef USING_SDL
  116. ret = WindowSDL::getTextInput();
  117. #elif defined(USING_GLFW)
  118. ret = WindowGLFW::getTextInput();
  119. #else
  120. ret = false;
  121. #endif
  122. return ret;
  123. }
  124. void Window::setClipboard(const char* s) {
  125. #ifdef USING_SDL
  126. WindowSDL::setClipboard(s);
  127. #elif defined(USING_GLFW)
  128. WindowGLFW::setClipboard(s);
  129. #endif
  130. }
  131. const char* Window::getClipboard() {
  132. const char* ret;
  133. #ifdef USING_SDL
  134. ret = WindowSDL::getClipboard();
  135. #elif defined(USING_GLFW)
  136. ret = WindowGLFW::getClipboard();
  137. #else
  138. ret = nullptr;
  139. #endif
  140. return ret;
  141. }
  142. void Window::inputPositionCallback(int x, int y) {
  143. #ifdef USING_SDL
  144. WindowSDL::inputPositionCallback(x, y);
  145. #elif defined(USING_GLFW)
  146. WindowGLFW::inputPositionCallback(x, y);
  147. #endif
  148. }
  149. std::string Window::getVersion(bool linked) {
  150. std::string ret;
  151. #ifdef USING_SDL
  152. ret = WindowSDL::getVersion(linked);
  153. #elif defined(USING_GLFW)
  154. ret = WindowGLFW::getVersion(linked);
  155. #endif
  156. return ret;
  157. }