Open Source Tomb Raider Engine
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

Window.cpp 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /*!
  2. * \file src/system/Window.cpp
  3. * \brief windowing implementation
  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. int Window::initialize() {
  19. int res;
  20. #ifdef USING_SDL
  21. res = WindowSDL::initialize();
  22. #elif defined(USING_GLFW)
  23. res = WindowGLFW::initialize();
  24. #else
  25. res = -1;
  26. #endif
  27. return res;
  28. }
  29. void Window::eventHandling() {
  30. #ifdef USING_SDL
  31. WindowSDL::eventHandling();
  32. #elif defined(USING_GLFW)
  33. WindowGLFW::eventHandling();
  34. #endif
  35. }
  36. void Window::swapBuffers() {
  37. #ifdef USING_SDL
  38. WindowSDL::swapBuffers();
  39. #elif defined(USING_GLFW)
  40. WindowGLFW::swapBuffers();
  41. #endif
  42. }
  43. void Window::shutdown() {
  44. #ifdef USING_SDL
  45. WindowSDL::shutdown();
  46. #elif defined(USING_GLFW)
  47. WindowGLFW::shutdown();
  48. #endif
  49. }
  50. void Window::setSize(glm::i32vec2 s) {
  51. #ifdef USING_SDL
  52. WindowSDL::setSize(s);
  53. #elif defined(USING_GLFW)
  54. WindowGLFW::setSize(s);
  55. #endif
  56. UI::setSize(s);
  57. Camera::setSize(s);
  58. glViewport(0, 0, s.x, s.y);
  59. }
  60. glm::i32vec2 Window::getSize() {
  61. glm::i32vec2 ret(-1, -1);
  62. #ifdef USING_SDL
  63. ret = WindowSDL::getSize();
  64. #elif defined(USING_GLFW)
  65. ret = WindowGLFW::getSize();
  66. #endif
  67. return ret;
  68. }
  69. void Window::setFullscreen(bool f) {
  70. #ifdef USING_SDL
  71. WindowSDL::setFullscreen(f);
  72. #elif defined(USING_GLFW)
  73. WindowGLFW::setFullscreen(f);
  74. #endif
  75. }
  76. bool Window::getFullscreen() {
  77. bool ret;
  78. #ifdef USING_SDL
  79. ret = WindowSDL::getFullscreen();
  80. #elif defined(USING_GLFW)
  81. ret = WindowGLFW::getFullscreen();
  82. #else
  83. ret = false;
  84. #endif
  85. return ret;
  86. }
  87. void Window::setMousegrab(bool g) {
  88. #ifdef USING_SDL
  89. WindowSDL::setMousegrab(g);
  90. #elif defined(USING_GLFW)
  91. WindowGLFW::setMousegrab(g);
  92. #endif
  93. }
  94. bool Window::getMousegrab() {
  95. bool ret;
  96. #ifdef USING_SDL
  97. ret = WindowSDL::getMousegrab();
  98. #elif defined(USING_GLFW)
  99. ret = WindowGLFW::getMousegrab();
  100. #else
  101. ret = false;
  102. #endif
  103. return ret;
  104. }
  105. void Window::setTextInput(bool t) {
  106. #ifdef USING_SDL
  107. WindowSDL::setTextInput(t);
  108. #elif defined(USING_GLFW)
  109. WindowGLFW::setTextInput(t);
  110. #endif
  111. }
  112. bool Window::getTextInput() {
  113. bool ret;
  114. #ifdef USING_SDL
  115. ret = WindowSDL::getTextInput();
  116. #elif defined(USING_GLFW)
  117. ret = WindowGLFW::getTextInput();
  118. #else
  119. ret = false;
  120. #endif
  121. return ret;
  122. }
  123. void Window::setClipboard(const char* s) {
  124. #ifdef USING_SDL
  125. WindowSDL::setClipboard(s);
  126. #elif defined(USING_GLFW)
  127. WindowGLFW::setClipboard(s);
  128. #endif
  129. }
  130. const char* Window::getClipboard() {
  131. const char* ret;
  132. #ifdef USING_SDL
  133. ret = WindowSDL::getClipboard();
  134. #elif defined(USING_GLFW)
  135. ret = WindowGLFW::getClipboard();
  136. #else
  137. ret = nullptr;
  138. #endif
  139. return ret;
  140. }