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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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 <ctime>
  10. typedef enum {
  11. zero = '0', one = '1',
  12. two = '2', three = '3',
  13. four = '4', five = '5',
  14. six = '6', seven = '7',
  15. eight = '8', nine = '9',
  16. a = 'a', b = 'b',
  17. c = 'c', d = 'd',
  18. e = 'e', f = 'f',
  19. g = 'g', h = 'h',
  20. i = 'i', j = 'j',
  21. k = 'k', l = 'l',
  22. m = 'm', n = 'n',
  23. o = 'o', p = 'p',
  24. q = 'q', r = 'r',
  25. s = 's', t = 't',
  26. u = 'u', v = 'v',
  27. w = 'w', x = 'x',
  28. y = 'y', z = 'z',
  29. quote, backslash, backspace, capslock,
  30. comma, del, up, down, left, right,
  31. end, equals, escape, f1, f2, f3, f4, f5,
  32. f6, f7, f8, f9, f10, f11, f12, backquote,
  33. home, insert, leftalt, leftctrl, leftbracket,
  34. leftgui, leftshift, minus, numlock, pagedown,
  35. pageup, pause, dot, rightalt, rightctrl, enter,
  36. rightgui, rightbracket, rightshift, scrolllock,
  37. semicolon, slash, space, tab, unknown
  38. } KeyboardButton;
  39. typedef enum {
  40. leftButton,
  41. rightButton,
  42. middleButton
  43. } MouseButton;
  44. typedef struct {
  45. char *text;
  46. unsigned int x;
  47. unsigned int y;
  48. int w;
  49. int h;
  50. float scale;
  51. unsigned char color[4];
  52. } WindowString;
  53. /*!
  54. * \brief Windowing interface
  55. */
  56. class Window {
  57. public:
  58. /*!
  59. * \brief Deconstructs an object of Window
  60. */
  61. virtual ~Window();
  62. virtual void setDriver(const char *driver) = 0;
  63. virtual void setSize(unsigned int width, unsigned int height) = 0;
  64. virtual void setFullscreen(bool fullscreen) = 0;
  65. virtual void setMousegrab(bool grab) = 0;
  66. virtual int initialize() = 0;
  67. virtual void eventHandling() = 0;
  68. virtual void setTextInput(bool on) = 0;
  69. virtual void delay(clock_t ms) = 0;
  70. virtual void swapBuffersGL() = 0;
  71. virtual int initializeGL();
  72. virtual void resizeGL();
  73. virtual void glEnter2D();
  74. virtual void glExit2D();
  75. virtual void setFont(const char *font) = 0;
  76. virtual int initializeFont() = 0;
  77. virtual void writeString(WindowString *s) = 0;
  78. virtual void drawText(unsigned int x, unsigned int y, float scale, unsigned char *color, const char *s, ...)
  79. __attribute__((format(printf, 6, 0))) = 0;
  80. unsigned int mWidth;
  81. unsigned int mHeight;
  82. protected:
  83. bool mInit;
  84. char *mDriver;
  85. bool mFullscreen;
  86. bool mMousegrab;
  87. bool mFontInit;
  88. char *mFontName;
  89. };
  90. #endif