🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
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.

129 lines
2.9 KiB

  1. #ifndef B3G_WINDOW_INTERFACE_H
  2. #define B3G_WINDOW_INTERFACE_H
  3. typedef void (*b3WheelCallback)(float deltax, float deltay);
  4. typedef void (*b3ResizeCallback)( float width, float height);
  5. typedef void (*b3MouseMoveCallback)( float x, float y);
  6. typedef void (*b3MouseButtonCallback)(int button, int state, float x, float y);
  7. typedef void (*b3KeyboardCallback)(int keycode, int state);
  8. typedef void (*b3RenderCallback) ();
  9. enum {
  10. B3G_ESCAPE = 27,
  11. B3G_F1 = 0xff00,
  12. B3G_F2,
  13. B3G_F3,
  14. B3G_F4,
  15. B3G_F5,
  16. B3G_F6,
  17. B3G_F7,
  18. B3G_F8,
  19. B3G_F9,
  20. B3G_F10,
  21. B3G_F11,
  22. B3G_F12,
  23. B3G_F13,
  24. B3G_F14,
  25. B3G_F15,
  26. B3G_LEFT_ARROW,
  27. B3G_RIGHT_ARROW,
  28. B3G_UP_ARROW,
  29. B3G_DOWN_ARROW,
  30. B3G_PAGE_UP,
  31. B3G_PAGE_DOWN,
  32. B3G_END,
  33. B3G_HOME,
  34. B3G_INSERT,
  35. B3G_DELETE,
  36. B3G_BACKSPACE,
  37. B3G_SHIFT,
  38. B3G_CONTROL,
  39. B3G_ALT,
  40. B3G_RETURN
  41. };
  42. struct b3gWindowConstructionInfo
  43. {
  44. int m_width;
  45. int m_height;
  46. bool m_fullscreen;
  47. int m_colorBitsPerPixel;
  48. void* m_windowHandle;
  49. const char* m_title;
  50. int m_openglVersion;
  51. b3gWindowConstructionInfo(int width=1024, int height=768)
  52. :m_width(width),
  53. m_height(height),
  54. m_fullscreen(false),
  55. m_colorBitsPerPixel(32),
  56. m_windowHandle(0),
  57. m_title("title"),
  58. m_openglVersion(3)
  59. {
  60. }
  61. };
  62. class CommonWindowInterface
  63. {
  64. public:
  65. virtual ~CommonWindowInterface()
  66. {
  67. }
  68. virtual void createDefaultWindow(int width, int height, const char* title)
  69. {
  70. b3gWindowConstructionInfo ci(width,height);
  71. ci.m_title = title;
  72. createWindow(ci);
  73. }
  74. virtual void createWindow(const b3gWindowConstructionInfo& ci)=0;
  75. virtual void closeWindow()=0;
  76. virtual void runMainLoop()=0;
  77. virtual float getTimeInSeconds()=0;
  78. virtual bool requestedExit() const = 0;
  79. virtual void setRequestExit() = 0;
  80. virtual void startRendering()=0;
  81. virtual void endRendering()=0;
  82. virtual bool isModifierKeyPressed(int key) = 0;
  83. virtual void setMouseMoveCallback(b3MouseMoveCallback mouseCallback)=0;
  84. virtual b3MouseMoveCallback getMouseMoveCallback()=0;
  85. virtual void setMouseButtonCallback(b3MouseButtonCallback mouseCallback)=0;
  86. virtual b3MouseButtonCallback getMouseButtonCallback()=0;
  87. virtual void setResizeCallback(b3ResizeCallback resizeCallback)=0;
  88. virtual b3ResizeCallback getResizeCallback()=0;
  89. virtual void setWheelCallback(b3WheelCallback wheelCallback)=0;
  90. virtual b3WheelCallback getWheelCallback()=0;
  91. virtual void setKeyboardCallback( b3KeyboardCallback keyboardCallback)=0;
  92. virtual b3KeyboardCallback getKeyboardCallback()=0;
  93. virtual void setRenderCallback( b3RenderCallback renderCallback) = 0;
  94. virtual void setWindowTitle(const char* title)=0;
  95. virtual float getRetinaScale() const =0;
  96. virtual void setAllowRetina(bool allow) =0;
  97. virtual int getWidth() const = 0;
  98. virtual int getHeight() const = 0;
  99. virtual int fileOpenDialog(char* fileName, int maxFileNameLength) = 0;
  100. };
  101. #endif //B3G_WINDOW_INTERFACE_H