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.h 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 "glm/vec2.hpp"
  10. #include "glm/vec4.hpp"
  11. #include <vector>
  12. class Shader {
  13. public:
  14. Shader() : programID(-1) { }
  15. ~Shader();
  16. int compile(const char* vertex, const char* fragment);
  17. void use();
  18. int addUniform(const char* name);
  19. unsigned int getUniform(int n);
  20. void addBuffer(int n = 1);
  21. unsigned int getBuffer(int n);
  22. private:
  23. int programID;
  24. std::vector<unsigned int> uniforms;
  25. std::vector<unsigned int> buffers;
  26. };
  27. class Window {
  28. public:
  29. virtual ~Window() {}
  30. virtual void setSize(unsigned int width, unsigned int height) = 0;
  31. virtual unsigned int getWidth();
  32. virtual unsigned int getHeight();
  33. virtual void setFullscreen(bool fullscreen) = 0;
  34. virtual bool getFullscreen();
  35. virtual void setMousegrab(bool grab) = 0;
  36. virtual bool getMousegrab();
  37. virtual int initialize() = 0;
  38. virtual void eventHandling() = 0;
  39. virtual void setTextInput(bool on) = 0;
  40. virtual bool getTextInput();
  41. virtual void swapBuffersGL() = 0;
  42. static int initializeGL();
  43. static void shutdownGL();
  44. static void resizeGL();
  45. static void drawTextGL(std::vector<glm::vec2>& vertices, std::vector<glm::vec2>& uvs,
  46. glm::vec4 color, unsigned int texture);
  47. protected:
  48. bool mInit;
  49. bool mFullscreen;
  50. bool mMousegrab;
  51. bool mTextInput;
  52. unsigned int mWidth;
  53. unsigned int mHeight;
  54. private:
  55. static Shader textShader;
  56. static const char* textShaderVertex;
  57. static const char* textShaderFragment;
  58. static Shader imguiShader;
  59. static const char* imguiShaderVertex;
  60. static const char* imguiShaderFragment;
  61. static unsigned int vertexArrayID;
  62. friend class UI;
  63. };
  64. Window& getWindow();
  65. #endif