Graphics.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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_GRAPHICS_GRAPHICS_H
  21. #define LOVE_GRAPHICS_GRAPHICS_H
  22. // LOVE
  23. #include "common/Module.h"
  24. #include "common/StringMap.h"
  25. // C++
  26. #include <string>
  27. namespace love
  28. {
  29. namespace graphics
  30. {
  31. class Graphics : public Module
  32. {
  33. public:
  34. enum DrawMode
  35. {
  36. DRAW_LINE,
  37. DRAW_FILL,
  38. DRAW_MAX_ENUM
  39. };
  40. enum AlignMode
  41. {
  42. ALIGN_LEFT,
  43. ALIGN_CENTER,
  44. ALIGN_RIGHT,
  45. ALIGN_JUSTIFY,
  46. ALIGN_MAX_ENUM
  47. };
  48. enum BlendMode
  49. {
  50. BLEND_ALPHA,
  51. BLEND_ADDITIVE,
  52. BLEND_SUBTRACTIVE,
  53. BLEND_MULTIPLICATIVE,
  54. BLEND_PREMULTIPLIED,
  55. BLEND_SCREEN,
  56. BLEND_REPLACE,
  57. BLEND_MAX_ENUM
  58. };
  59. enum LineStyle
  60. {
  61. LINE_ROUGH,
  62. LINE_SMOOTH,
  63. LINE_MAX_ENUM
  64. };
  65. enum LineJoin
  66. {
  67. LINE_JOIN_NONE,
  68. LINE_JOIN_MITER,
  69. LINE_JOIN_BEVEL,
  70. LINE_JOIN_MAX_ENUM
  71. };
  72. enum PointStyle
  73. {
  74. POINT_ROUGH,
  75. POINT_SMOOTH,
  76. POINT_MAX_ENUM
  77. };
  78. enum Support
  79. {
  80. SUPPORT_CANVAS,
  81. SUPPORT_HDR_CANVAS,
  82. SUPPORT_MULTI_CANVAS,
  83. SUPPORT_SHADER,
  84. SUPPORT_NPOT,
  85. SUPPORT_SUBTRACTIVE,
  86. SUPPORT_MIPMAP,
  87. SUPPORT_DXT,
  88. SUPPORT_BC5,
  89. SUPPORT_INSTANCING,
  90. SUPPORT_SRGB,
  91. SUPPORT_MAX_ENUM
  92. };
  93. enum SystemLimit
  94. {
  95. LIMIT_POINT_SIZE,
  96. LIMIT_TEXTURE_SIZE,
  97. LIMIT_MULTI_CANVAS,
  98. LIMIT_CANVAS_FSAA, // For backward-compatibility. TODO: remove!
  99. LIMIT_CANVAS_MSAA,
  100. LIMIT_MAX_ENUM
  101. };
  102. struct RendererInfo
  103. {
  104. std::string name;
  105. std::string version;
  106. std::string vendor;
  107. std::string device;
  108. };
  109. virtual ~Graphics();
  110. /**
  111. * Sets the current graphics display viewport dimensions.
  112. **/
  113. virtual void setViewportSize(int width, int height) = 0;
  114. /**
  115. * Sets the current graphics display viewport and initializes the renderer.
  116. * @param width The viewport width.
  117. * @param height The viewport height.
  118. **/
  119. virtual bool setMode(int width, int height, bool &sRGB) = 0;
  120. /**
  121. * Un-sets the current graphics display mode (uninitializing objects if
  122. * necessary.)
  123. **/
  124. virtual void unSetMode() = 0;
  125. static bool getConstant(const char *in, DrawMode &out);
  126. static bool getConstant(DrawMode in, const char *&out);
  127. static bool getConstant(const char *in, AlignMode &out);
  128. static bool getConstant(AlignMode in, const char *&out);
  129. static bool getConstant(const char *in, BlendMode &out);
  130. static bool getConstant(BlendMode in, const char *&out);
  131. static bool getConstant(const char *in, LineStyle &out);
  132. static bool getConstant(LineStyle in, const char *&out);
  133. static bool getConstant(const char *in, LineJoin &out);
  134. static bool getConstant(LineJoin in, const char *&out);
  135. static bool getConstant(const char *in, PointStyle &out);
  136. static bool getConstant(PointStyle in, const char *&out);
  137. static bool getConstant(const char *in, Support &out);
  138. static bool getConstant(Support in, const char *&out);
  139. static bool getConstant(const char *in, SystemLimit &out);
  140. static bool getConstant(SystemLimit in, const char *&out);
  141. private:
  142. static StringMap<DrawMode, DRAW_MAX_ENUM>::Entry drawModeEntries[];
  143. static StringMap<DrawMode, DRAW_MAX_ENUM> drawModes;
  144. static StringMap<AlignMode, ALIGN_MAX_ENUM>::Entry alignModeEntries[];
  145. static StringMap<AlignMode, ALIGN_MAX_ENUM> alignModes;
  146. static StringMap<BlendMode, BLEND_MAX_ENUM>::Entry blendModeEntries[];
  147. static StringMap<BlendMode, BLEND_MAX_ENUM> blendModes;
  148. static StringMap<LineStyle, LINE_MAX_ENUM>::Entry lineStyleEntries[];
  149. static StringMap<LineStyle, LINE_MAX_ENUM> lineStyles;
  150. static StringMap<LineJoin, LINE_JOIN_MAX_ENUM>::Entry lineJoinEntries[];
  151. static StringMap<LineJoin, LINE_JOIN_MAX_ENUM> lineJoins;
  152. static StringMap<PointStyle, POINT_MAX_ENUM>::Entry pointStyleEntries[];
  153. static StringMap<PointStyle, POINT_MAX_ENUM> pointStyles;
  154. static StringMap<Support, SUPPORT_MAX_ENUM>::Entry supportEntries[];
  155. static StringMap<Support, SUPPORT_MAX_ENUM> support;
  156. static StringMap<SystemLimit, LIMIT_MAX_ENUM>::Entry systemLimitEntries[];
  157. static StringMap<SystemLimit, LIMIT_MAX_ENUM> systemLimits;
  158. }; // Graphics
  159. } // graphics
  160. } // love
  161. #endif // LOVE_GRAPHICS_GRAPHICS_H