Open Source Tomb Raider Engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Window.h 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*!
  2. * \file include/Window.h
  3. * \brief Windowing interface
  4. *
  5. * \author xythobuz
  6. */
  7. #ifndef _WINDOW_H_
  8. #define _WINDOW_H_
  9. #include <vector>
  10. #include <glm/mat4x4.hpp>
  11. #include <glm/vec2.hpp>
  12. #include <glm/vec3.hpp>
  13. #include <glm/vec4.hpp>
  14. class Shader {
  15. public:
  16. Shader() : programID(-1) { }
  17. ~Shader();
  18. int compile(const char* vertex, const char* fragment);
  19. void use();
  20. int addUniform(const char* name);
  21. unsigned int getUniform(int n);
  22. void addBuffer(int n = 1);
  23. unsigned int getBuffer(int n);
  24. private:
  25. int programID;
  26. std::vector<unsigned int> uniforms;
  27. std::vector<unsigned int> buffers;
  28. };
  29. class Window {
  30. public:
  31. virtual ~Window() {}
  32. virtual void setSize(unsigned int width, unsigned int height) = 0;
  33. virtual unsigned int getWidth();
  34. virtual unsigned int getHeight();
  35. virtual void setFullscreen(bool fullscreen) = 0;
  36. virtual bool getFullscreen();
  37. virtual void setMousegrab(bool grab) = 0;
  38. virtual bool getMousegrab();
  39. virtual int initialize() = 0;
  40. virtual void eventHandling() = 0;
  41. virtual void setTextInput(bool on) = 0;
  42. virtual bool getTextInput();
  43. virtual void swapBuffersGL() = 0;
  44. static int initializeGL();
  45. static void shutdownGL();
  46. static void resizeGL();
  47. static void drawTextGL(std::vector<glm::vec2>& vertices, std::vector<glm::vec2>& uvs,
  48. glm::vec4 color, unsigned int texture);
  49. static void drawGL(std::vector<glm::vec3>& vertices, std::vector<glm::vec2>& uvs,
  50. std::vector<unsigned short>& indices, glm::mat4 MVP, unsigned int texture);
  51. protected:
  52. bool mInit;
  53. bool mFullscreen;
  54. bool mMousegrab;
  55. bool mTextInput;
  56. unsigned int mWidth;
  57. unsigned int mHeight;
  58. private:
  59. static Shader textShader;
  60. static const char* textShaderVertex;
  61. static const char* textShaderFragment;
  62. static Shader imguiShader;
  63. static const char* imguiShaderVertex;
  64. static const char* imguiShaderFragment;
  65. static Shader textureShader;
  66. static const char* textureShaderVertex;
  67. static const char* textureShaderFragment;
  68. static unsigned int vertexArrayID;
  69. friend class UI;
  70. };
  71. Window& getWindow();
  72. #endif