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.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. static void drawGL(std::vector<glm::vec3>& vertices, std::vector<glm::vec3>& colors,
  52. std::vector<unsigned short>& indices, glm::mat4 MVP);
  53. protected:
  54. bool mInit;
  55. bool mFullscreen;
  56. bool mMousegrab;
  57. bool mTextInput;
  58. unsigned int mWidth;
  59. unsigned int mHeight;
  60. private:
  61. static Shader textShader;
  62. static const char* textShaderVertex;
  63. static const char* textShaderFragment;
  64. static Shader imguiShader;
  65. static const char* imguiShaderVertex;
  66. static const char* imguiShaderFragment;
  67. static Shader textureShader;
  68. static const char* textureShaderVertex;
  69. static const char* textureShaderFragment;
  70. static Shader colorShader;
  71. static const char* colorShaderVertex;
  72. static const char* colorShaderFragment;
  73. static unsigned int vertexArrayID;
  74. friend class UI;
  75. };
  76. Window& getWindow();
  77. #endif