Graphics.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /**
  2. * Copyright (c) 2006-2013 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_REPLACE,
  54. BLEND_MAX_ENUM
  55. };
  56. enum LineStyle
  57. {
  58. LINE_ROUGH = 1,
  59. LINE_SMOOTH,
  60. LINE_MAX_ENUM
  61. };
  62. enum LineJoin
  63. {
  64. LINE_JOIN_NONE = 1,
  65. LINE_JOIN_MITER,
  66. LINE_JOIN_BEVEL,
  67. LINE_JOIN_MAX_ENUM
  68. };
  69. enum PointStyle
  70. {
  71. POINT_ROUGH = 1,
  72. POINT_SMOOTH,
  73. POINT_MAX_ENUM
  74. };
  75. enum Support
  76. {
  77. SUPPORT_CANVAS = 1,
  78. SUPPORT_HDR_CANVAS,
  79. SUPPORT_MULTI_CANVAS,
  80. SUPPORT_SHADER,
  81. SUPPORT_NPOT,
  82. SUPPORT_SUBTRACTIVE,
  83. SUPPORT_MIPMAP,
  84. SUPPORT_DXT,
  85. SUPPORT_BC5,
  86. SUPPORT_MAX_ENUM
  87. };
  88. enum RendererInfo
  89. {
  90. RENDERER_INFO_NAME = 1,
  91. RENDERER_INFO_VERSION,
  92. RENDERER_INFO_VENDOR,
  93. RENDERER_INFO_DEVICE,
  94. RENDERER_INFO_MAX_ENUM
  95. };
  96. virtual ~Graphics();
  97. /**
  98. * Sets the current graphics display viewport and initializes the renderer.
  99. * @param width The viewport width.
  100. * @param height The viewport height.
  101. **/
  102. virtual bool setMode(int width, int height) = 0;
  103. /**
  104. * Un-sets the current graphics display mode (uninitializing objects if
  105. * necessary.)
  106. **/
  107. virtual void unSetMode() = 0;
  108. static bool getConstant(const char *in, DrawMode &out);
  109. static bool getConstant(DrawMode in, const char *&out);
  110. static bool getConstant(const char *in, AlignMode &out);
  111. static bool getConstant(AlignMode in, const char *&out);
  112. static bool getConstant(const char *in, BlendMode &out);
  113. static bool getConstant(BlendMode in, const char *&out);
  114. static bool getConstant(const char *in, LineStyle &out);
  115. static bool getConstant(LineStyle in, const char *&out);
  116. static bool getConstant(const char *in, LineJoin &out);
  117. static bool getConstant(LineJoin in, const char *&out);
  118. static bool getConstant(const char *in, PointStyle &out);
  119. static bool getConstant(PointStyle in, const char *&out);
  120. static bool getConstant(const char *in, Support &out);
  121. static bool getConstant(Support in, const char *&out);
  122. static bool getConstant(const char *in, RendererInfo &out);
  123. static bool getConstant(RendererInfo in, const char *&out);
  124. private:
  125. static StringMap<DrawMode, DRAW_MAX_ENUM>::Entry drawModeEntries[];
  126. static StringMap<DrawMode, DRAW_MAX_ENUM> drawModes;
  127. static StringMap<AlignMode, ALIGN_MAX_ENUM>::Entry alignModeEntries[];
  128. static StringMap<AlignMode, ALIGN_MAX_ENUM> alignModes;
  129. static StringMap<BlendMode, BLEND_MAX_ENUM>::Entry blendModeEntries[];
  130. static StringMap<BlendMode, BLEND_MAX_ENUM> blendModes;
  131. static StringMap<LineStyle, LINE_MAX_ENUM>::Entry lineStyleEntries[];
  132. static StringMap<LineStyle, LINE_MAX_ENUM> lineStyles;
  133. static StringMap<LineJoin, LINE_JOIN_MAX_ENUM>::Entry lineJoinEntries[];
  134. static StringMap<LineJoin, LINE_JOIN_MAX_ENUM> lineJoins;
  135. static StringMap<PointStyle, POINT_MAX_ENUM>::Entry pointStyleEntries[];
  136. static StringMap<PointStyle, POINT_MAX_ENUM> pointStyles;
  137. static StringMap<Support, SUPPORT_MAX_ENUM>::Entry supportEntries[];
  138. static StringMap<Support, SUPPORT_MAX_ENUM> support;
  139. static StringMap<RendererInfo, RENDERER_INFO_MAX_ENUM>::Entry rendererInfoEntries[];
  140. static StringMap<RendererInfo, RENDERER_INFO_MAX_ENUM> rendererInfo;
  141. }; // Graphics
  142. } // graphics
  143. } // love
  144. #endif // LOVE_GRAPHICS_GRAPHICS_H