Graphics.cpp 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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. #include "Graphics.h"
  21. namespace love
  22. {
  23. namespace graphics
  24. {
  25. Graphics::~Graphics()
  26. {
  27. }
  28. bool Graphics::getConstant(const char *in, DrawMode &out)
  29. {
  30. return drawModes.find(in, out);
  31. }
  32. bool Graphics::getConstant(DrawMode in, const char *&out)
  33. {
  34. return drawModes.find(in, out);
  35. }
  36. bool Graphics::getConstant(const char *in, AlignMode &out)
  37. {
  38. return alignModes.find(in, out);
  39. }
  40. bool Graphics::getConstant(AlignMode in, const char *&out)
  41. {
  42. return alignModes.find(in, out);
  43. }
  44. bool Graphics::getConstant(const char *in, BlendMode &out)
  45. {
  46. return blendModes.find(in, out);
  47. }
  48. bool Graphics::getConstant(BlendMode in, const char *&out)
  49. {
  50. return blendModes.find(in, out);
  51. }
  52. bool Graphics::getConstant(const char *in, LineStyle &out)
  53. {
  54. return lineStyles.find(in, out);
  55. }
  56. bool Graphics::getConstant(LineStyle in, const char *&out)
  57. {
  58. return lineStyles.find(in, out);
  59. }
  60. bool Graphics::getConstant(const char *in, LineJoin &out)
  61. {
  62. return lineJoins.find(in, out);
  63. }
  64. bool Graphics::getConstant(LineJoin in, const char *&out)
  65. {
  66. return lineJoins.find(in, out);
  67. }
  68. bool Graphics::getConstant(const char *in, PointStyle &out)
  69. {
  70. return pointStyles.find(in, out);
  71. }
  72. bool Graphics::getConstant(PointStyle in, const char *&out)
  73. {
  74. return pointStyles.find(in, out);
  75. }
  76. bool Graphics::getConstant(const char *in, Support &out)
  77. {
  78. return support.find(in, out);
  79. }
  80. bool Graphics::getConstant(Support in, const char *&out)
  81. {
  82. return support.find(in, out);
  83. }
  84. bool Graphics::getConstant(const char *in, SystemLimit &out)
  85. {
  86. return systemLimits.find(in, out);
  87. }
  88. bool Graphics::getConstant(SystemLimit in, const char *&out)
  89. {
  90. return systemLimits.find(in, out);
  91. }
  92. bool Graphics::getConstant(const char *in, StackType &out)
  93. {
  94. return stackTypes.find(in, out);
  95. }
  96. bool Graphics::getConstant(StackType in, const char *&out)
  97. {
  98. return stackTypes.find(in, out);
  99. }
  100. bool Graphics::getConstant(const char *in, StatType &out)
  101. {
  102. return statTypes.find(in, out);
  103. }
  104. bool Graphics::getConstant(StatType in, const char *&out)
  105. {
  106. return statTypes.find(in, out);
  107. }
  108. StringMap<Graphics::DrawMode, Graphics::DRAW_MAX_ENUM>::Entry Graphics::drawModeEntries[] =
  109. {
  110. { "line", Graphics::DRAW_LINE },
  111. { "fill", Graphics::DRAW_FILL },
  112. };
  113. StringMap<Graphics::DrawMode, Graphics::DRAW_MAX_ENUM> Graphics::drawModes(Graphics::drawModeEntries, sizeof(Graphics::drawModeEntries));
  114. StringMap<Graphics::AlignMode, Graphics::ALIGN_MAX_ENUM>::Entry Graphics::alignModeEntries[] =
  115. {
  116. { "left", Graphics::ALIGN_LEFT },
  117. { "right", Graphics::ALIGN_RIGHT },
  118. { "center", Graphics::ALIGN_CENTER },
  119. { "justify", Graphics::ALIGN_JUSTIFY },
  120. };
  121. StringMap<Graphics::AlignMode, Graphics::ALIGN_MAX_ENUM> Graphics::alignModes(Graphics::alignModeEntries, sizeof(Graphics::alignModeEntries));
  122. StringMap<Graphics::BlendMode, Graphics::BLEND_MAX_ENUM>::Entry Graphics::blendModeEntries[] =
  123. {
  124. { "alpha", Graphics::BLEND_ALPHA },
  125. { "additive", Graphics::BLEND_ADDITIVE },
  126. { "subtractive", Graphics::BLEND_SUBTRACTIVE },
  127. { "multiplicative", Graphics::BLEND_MULTIPLICATIVE },
  128. { "premultiplied", Graphics::BLEND_PREMULTIPLIED },
  129. { "screen", Graphics::BLEND_SCREEN },
  130. { "replace", Graphics::BLEND_REPLACE },
  131. };
  132. StringMap<Graphics::BlendMode, Graphics::BLEND_MAX_ENUM> Graphics::blendModes(Graphics::blendModeEntries, sizeof(Graphics::blendModeEntries));
  133. StringMap<Graphics::LineStyle, Graphics::LINE_MAX_ENUM>::Entry Graphics::lineStyleEntries[] =
  134. {
  135. { "smooth", Graphics::LINE_SMOOTH },
  136. { "rough", Graphics::LINE_ROUGH }
  137. };
  138. StringMap<Graphics::LineStyle, Graphics::LINE_MAX_ENUM> Graphics::lineStyles(Graphics::lineStyleEntries, sizeof(Graphics::lineStyleEntries));
  139. StringMap<Graphics::LineJoin, Graphics::LINE_JOIN_MAX_ENUM>::Entry Graphics::lineJoinEntries[] =
  140. {
  141. { "none", Graphics::LINE_JOIN_NONE },
  142. { "miter", Graphics::LINE_JOIN_MITER },
  143. { "bevel", Graphics::LINE_JOIN_BEVEL }
  144. };
  145. StringMap<Graphics::LineJoin, Graphics::LINE_JOIN_MAX_ENUM> Graphics::lineJoins(Graphics::lineJoinEntries, sizeof(Graphics::lineJoinEntries));
  146. StringMap<Graphics::PointStyle, Graphics::POINT_MAX_ENUM>::Entry Graphics::pointStyleEntries[] =
  147. {
  148. { "smooth", Graphics::POINT_SMOOTH },
  149. { "rough", Graphics::POINT_ROUGH }
  150. };
  151. StringMap<Graphics::PointStyle, Graphics::POINT_MAX_ENUM> Graphics::pointStyles(Graphics::pointStyleEntries, sizeof(Graphics::pointStyleEntries));
  152. StringMap<Graphics::Support, Graphics::SUPPORT_MAX_ENUM>::Entry Graphics::supportEntries[] =
  153. {
  154. { "canvas", Graphics::SUPPORT_CANVAS },
  155. { "hdrcanvas", Graphics::SUPPORT_HDR_CANVAS },
  156. { "multicanvas", Graphics::SUPPORT_MULTI_CANVAS },
  157. { "shader", Graphics::SUPPORT_SHADER },
  158. { "npot", Graphics::SUPPORT_NPOT },
  159. { "subtractive", Graphics::SUPPORT_SUBTRACTIVE },
  160. { "mipmap", Graphics::SUPPORT_MIPMAP },
  161. { "dxt", Graphics::SUPPORT_DXT },
  162. { "bc5", Graphics::SUPPORT_BC5 },
  163. { "srgb", Graphics::SUPPORT_SRGB },
  164. };
  165. StringMap<Graphics::Support, Graphics::SUPPORT_MAX_ENUM> Graphics::support(Graphics::supportEntries, sizeof(Graphics::supportEntries));
  166. StringMap<Graphics::SystemLimit, Graphics::LIMIT_MAX_ENUM>::Entry Graphics::systemLimitEntries[] =
  167. {
  168. {"pointsize", Graphics::LIMIT_POINT_SIZE},
  169. {"texturesize", Graphics::LIMIT_TEXTURE_SIZE},
  170. {"multicanvas", Graphics::LIMIT_MULTI_CANVAS},
  171. {"canvasfsaa", Graphics::LIMIT_CANVAS_FSAA},
  172. {"canvasmsaa", Graphics::LIMIT_CANVAS_MSAA},
  173. };
  174. StringMap<Graphics::SystemLimit, Graphics::LIMIT_MAX_ENUM> Graphics::systemLimits(Graphics::systemLimitEntries, sizeof(Graphics::systemLimitEntries));
  175. StringMap<Graphics::StackType, Graphics::STACK_MAX_ENUM>::Entry Graphics::stackTypeEntries[] =
  176. {
  177. {"all", Graphics::STACK_ALL},
  178. {"transform", Graphics::STACK_TRANSFORM},
  179. };
  180. StringMap<Graphics::StackType, Graphics::STACK_MAX_ENUM> Graphics::stackTypes(Graphics::stackTypeEntries, sizeof(Graphics::stackTypeEntries));
  181. StringMap<Graphics::StatType, Graphics::STAT_MAX_ENUM>::Entry Graphics::statTypeEntries[] =
  182. {
  183. {"drawcalls", Graphics::STAT_DRAW_CALLS},
  184. {"canvasswitches", Graphics::STAT_CANVAS_SWITCHES},
  185. {"canvases", Graphics::STAT_CANVASES},
  186. {"images", Graphics::STAT_IMAGES},
  187. {"fonts", Graphics::STAT_FONTS},
  188. {"texturememory", Graphics::STAT_TEXTURE_MEMORY},
  189. };
  190. StringMap<Graphics::StatType, Graphics::STAT_MAX_ENUM> Graphics::statTypes(Graphics::statTypeEntries, sizeof(Graphics::statTypeEntries));
  191. } // graphics
  192. } // love