Window.cpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. // LOVE
  21. #include "Window.h"
  22. namespace love
  23. {
  24. namespace window
  25. {
  26. Window *Window::singleton = nullptr;
  27. Window::~Window()
  28. {
  29. if (singleton == this)
  30. singleton = nullptr;
  31. }
  32. void Window::swapBuffers()
  33. {
  34. }
  35. WindowSettings::WindowSettings()
  36. : fullscreen(false)
  37. , fstype(Window::FULLSCREEN_TYPE_NORMAL)
  38. , vsync(true)
  39. , msaa(0)
  40. , resizable(false)
  41. , minwidth(1)
  42. , minheight(1)
  43. , borderless(false)
  44. , centered(true)
  45. , display(0)
  46. , highdpi(false)
  47. , sRGB(false)
  48. {
  49. }
  50. bool Window::getConstant(const char *in, Window::FullscreenType &out)
  51. {
  52. return fullscreenTypes.find(in, out);
  53. }
  54. bool Window::getConstant(Window::FullscreenType in, const char *&out)
  55. {
  56. return fullscreenTypes.find(in, out);
  57. }
  58. bool Window::getConstant(const char *in, Window::Setting &out)
  59. {
  60. return settings.find(in, out);
  61. }
  62. bool Window::getConstant(Window::Setting in, const char *&out)
  63. {
  64. return settings.find(in, out);
  65. }
  66. bool Window::getConstant(const char *in, MessageBoxType &out)
  67. {
  68. return messageBoxTypes.find(in, out);
  69. }
  70. bool Window::getConstant(MessageBoxType in, const char *&out)
  71. {
  72. return messageBoxTypes.find(in, out);
  73. }
  74. StringMap<Window::Setting, Window::SETTING_MAX_ENUM>::Entry Window::settingEntries[] =
  75. {
  76. {"fullscreen", SETTING_FULLSCREEN},
  77. {"fullscreentype", SETTING_FULLSCREEN_TYPE},
  78. {"vsync", SETTING_VSYNC},
  79. {"msaa", SETTING_MSAA},
  80. {"resizable", SETTING_RESIZABLE},
  81. {"minwidth", SETTING_MIN_WIDTH},
  82. {"minheight", SETTING_MIN_HEIGHT},
  83. {"borderless", SETTING_BORDERLESS},
  84. {"centered", SETTING_CENTERED},
  85. {"display", SETTING_DISPLAY},
  86. {"highdpi", SETTING_HIGHDPI},
  87. {"srgb", SETTING_SRGB},
  88. };
  89. StringMap<Window::Setting, Window::SETTING_MAX_ENUM> Window::settings(Window::settingEntries, sizeof(Window::settingEntries));
  90. StringMap<Window::FullscreenType, Window::FULLSCREEN_TYPE_MAX_ENUM>::Entry Window::fullscreenTypeEntries[] =
  91. {
  92. {"normal", Window::FULLSCREEN_TYPE_NORMAL},
  93. {"desktop", Window::FULLSCREEN_TYPE_DESKTOP},
  94. };
  95. StringMap<Window::FullscreenType, Window::FULLSCREEN_TYPE_MAX_ENUM> Window::fullscreenTypes(Window::fullscreenTypeEntries, sizeof(Window::fullscreenTypeEntries));
  96. StringMap<Window::MessageBoxType, Window::MESSAGEBOX_MAX_ENUM>::Entry Window::messageBoxTypeEntries[] =
  97. {
  98. {"error", Window::MESSAGEBOX_ERROR},
  99. {"warning", Window::MESSAGEBOX_WARNING},
  100. {"info", Window::MESSAGEBOX_INFO},
  101. };
  102. StringMap<Window::MessageBoxType, Window::MESSAGEBOX_MAX_ENUM> Window::messageBoxTypes(Window::messageBoxTypeEntries, sizeof(Window::messageBoxTypeEntries));
  103. } // window
  104. } // love