Graphics.h 4.8 KB

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