Window.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /**
  2. * Copyright (c) 2006-2014 LOVE Development Team
  3. *
  4. * This software is provided 'as-is', without any express or implied
  5. * warranty. In no event will the authors be held liable for any damages
  6. * arising from the use of this software.
  7. *
  8. * Permission is granted to anyone to use this software for any purpose,
  9. * including commercial applications, and to alter it and redistribute it
  10. * freely, subject to the following restrictions:
  11. *
  12. * 1. The origin of this software must not be misrepresented; you must not
  13. * claim that you wrote the original software. If you use this software
  14. * in a product, an acknowledgment in the product documentation would be
  15. * appreciated but is not required.
  16. * 2. Altered source versions must be plainly marked as such, and must not be
  17. * misrepresented as being the original software.
  18. * 3. This notice may not be removed or altered from any source distribution.
  19. **/
  20. #ifndef LOVE_WINDOW_SDL_WINDOW_H
  21. #define LOVE_WINDOW_SDL_WINDOW_H
  22. // LOVE
  23. #include "window/Window.h"
  24. // SDL
  25. #include <SDL.h>
  26. namespace love
  27. {
  28. namespace window
  29. {
  30. namespace sdl
  31. {
  32. class Window : public love::window::Window
  33. {
  34. public:
  35. Window();
  36. ~Window();
  37. bool setWindow(int width = 800, int height = 600, WindowSettings *settings = nullptr);
  38. void getWindow(int &width, int &height, WindowSettings &settings);
  39. bool setFullscreen(bool fullscreen, FullscreenType fstype);
  40. bool setFullscreen(bool fullscreen);
  41. bool onWindowResize(int width, int height);
  42. int getDisplayCount() const;
  43. const char *getDisplayName(int displayindex) const;
  44. std::vector<WindowSize> getFullscreenSizes(int displayindex) const;
  45. int getWidth() const;
  46. int getHeight() const;
  47. void getDesktopDimensions(int displayindex, int &width, int &height) const;
  48. bool isCreated() const;
  49. void setWindowTitle(const std::string &title);
  50. const std::string &getWindowTitle() const;
  51. bool setIcon(love::image::ImageData *imgd);
  52. love::image::ImageData *getIcon();
  53. void minimize();
  54. void swapBuffers();
  55. bool hasFocus() const;
  56. bool hasMouseFocus() const;
  57. bool isVisible() const;
  58. void setMouseVisible(bool visible);
  59. bool getMouseVisible() const;
  60. void setMouseGrab(bool grab);
  61. bool isMouseGrabbed() const;
  62. double getPixelScale() const;
  63. const void *getHandle() const;
  64. static love::window::Window *createSingleton();
  65. static love::window::Window *getSingleton();
  66. const char *getName() const;
  67. private:
  68. bool setContext(int msaa, bool vsync, bool sRGB);
  69. void setWindowGLAttributes(int msaa, bool sRGB) const;
  70. // Update the saved window settings based on the window's actual state.
  71. void updateSettings(const WindowSettings &newsettings);
  72. std::string windowTitle;
  73. struct _currentMode
  74. {
  75. _currentMode();
  76. int width;
  77. int height;
  78. WindowSettings settings;
  79. love::image::ImageData *icon;
  80. } curMode;
  81. bool created;
  82. bool mouseGrabbed;
  83. SDL_Window *window;
  84. SDL_GLContext context;
  85. }; // Window
  86. } // sdl
  87. } // window
  88. } // love
  89. #endif // LOVE_WINDOW_WINDOW_H