Graphics.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. /**
  2. * Copyright (c) 2006-2016 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. #include "math/MathModule.h"
  22. #include "Polyline.h"
  23. namespace love
  24. {
  25. namespace graphics
  26. {
  27. static bool gammaCorrect = false;
  28. void setGammaCorrect(bool gammacorrect)
  29. {
  30. gammaCorrect = gammacorrect;
  31. }
  32. bool isGammaCorrect()
  33. {
  34. return gammaCorrect;
  35. }
  36. void gammaCorrectColor(Colorf &c)
  37. {
  38. if (isGammaCorrect())
  39. {
  40. c.r = math::gammaToLinear(c.r);
  41. c.g = math::gammaToLinear(c.g);
  42. c.b = math::gammaToLinear(c.b);
  43. }
  44. }
  45. void unGammaCorrectColor(Colorf &c)
  46. {
  47. if (isGammaCorrect())
  48. {
  49. c.r = math::linearToGamma(c.r);
  50. c.g = math::linearToGamma(c.g);
  51. c.b = math::linearToGamma(c.b);
  52. }
  53. }
  54. love::Type Graphics::type("graphics", &Module::type);
  55. Graphics::Graphics()
  56. : streamBufferState()
  57. , projectionMatrix()
  58. {
  59. transformStack.reserve(16);
  60. transformStack.push_back(Matrix4());
  61. }
  62. Graphics::~Graphics()
  63. {
  64. delete streamBufferState.vb[0];
  65. delete streamBufferState.vb[1];
  66. delete streamBufferState.indexBuffer;
  67. }
  68. Graphics::StreamVertexData Graphics::requestStreamDraw(const StreamDrawRequest &req)
  69. {
  70. using namespace vertex;
  71. StreamBufferState &state = streamBufferState;
  72. bool shouldflush = false;
  73. bool shouldresize = false;
  74. if (req.primitiveMode != state.primitiveMode
  75. || req.formats[0] != state.formats[0] || req.formats[1] != state.formats[1]
  76. || ((req.indexMode != TriangleIndexMode::NONE) != (state.indexCount > 0))
  77. || req.texture != state.texture)
  78. {
  79. shouldflush = true;
  80. }
  81. int totalvertices = state.vertexCount + req.vertexCount;
  82. if (totalvertices > LOVE_UINT16_MAX && req.indexMode != TriangleIndexMode::NONE)
  83. shouldflush = true;
  84. int reqIndexCount = getIndexCount(req.indexMode, req.vertexCount);
  85. size_t reqIndexSize = reqIndexCount * sizeof(uint16);
  86. size_t newdatasizes[2] = {0, 0};
  87. size_t buffersizes[3] = {0, 0, 0};
  88. for (int i = 0; i < 2; i++)
  89. {
  90. if (req.formats[i] != CommonFormat::NONE)
  91. {
  92. size_t stride = getFormatStride(req.formats[i]);
  93. size_t datasize = stride * totalvertices;
  94. size_t cursize = state.vb[i]->getSize();
  95. if (datasize > cursize)
  96. {
  97. shouldflush = true;
  98. if (stride * req.vertexCount > cursize)
  99. {
  100. buffersizes[i] = std::max(datasize, cursize * 2);
  101. shouldresize = true;
  102. }
  103. }
  104. newdatasizes[i] = stride * req.vertexCount;
  105. }
  106. }
  107. {
  108. size_t datasize = (state.indexCount + reqIndexCount) * sizeof(uint16);
  109. size_t cursize = state.indexBuffer->getSize();
  110. if (datasize > cursize)
  111. {
  112. shouldflush = true;
  113. if (reqIndexSize > cursize)
  114. {
  115. buffersizes[2] = std::max(datasize, cursize * 2);
  116. shouldresize = true;
  117. }
  118. }
  119. }
  120. if (shouldflush)
  121. {
  122. flushStreamDraws();
  123. state.primitiveMode = req.primitiveMode;
  124. state.formats[0] = req.formats[0];
  125. state.formats[1] = req.formats[1];
  126. state.texture = req.texture;
  127. }
  128. if (shouldresize)
  129. {
  130. for (int i = 0; i < 2; i++)
  131. {
  132. if (state.vb[i]->getSize() < buffersizes[i])
  133. state.vb[i]->setSize(buffersizes[i]);
  134. }
  135. if (state.indexBuffer->getSize() < buffersizes[2])
  136. state.indexBuffer->setSize(buffersizes[2]);
  137. }
  138. if (req.indexMode != TriangleIndexMode::NONE)
  139. {
  140. uint16 *indices = (uint16 *) state.indexBuffer->getOffsetData();
  141. fillIndices(req.indexMode, state.vertexCount, req.vertexCount, indices);
  142. state.indexBuffer->incrementOffset(reqIndexSize);
  143. }
  144. StreamVertexData d;
  145. d.stream[0] = state.vb[0]->getOffsetData();
  146. d.stream[1] = state.vb[1]->getOffsetData();
  147. state.vertexCount += req.vertexCount;
  148. state.indexCount += reqIndexCount;
  149. state.vb[0]->incrementOffset(newdatasizes[0]);
  150. state.vb[1]->incrementOffset(newdatasizes[1]);
  151. return d;
  152. }
  153. int Graphics::calculateEllipsePoints(float rx, float ry) const
  154. {
  155. int points = (int) sqrtf(((rx + ry) / 2.0f) * 20.0f * (float) pixelScaleStack.back());
  156. return std::max(points, 8);
  157. }
  158. void Graphics::polyline(const float *coords, size_t count)
  159. {
  160. float halfwidth = getLineWidth() * 0.5f;
  161. LineJoin linejoin = getLineJoin();
  162. LineStyle linestyle = getLineStyle();
  163. float pixelsize = 1.0f / std::max((float) pixelScaleStack.back(), 0.000001f);
  164. if (linejoin == LINE_JOIN_NONE)
  165. {
  166. NoneJoinPolyline line;
  167. line.render(coords, count, halfwidth, pixelsize, linestyle == LINE_SMOOTH);
  168. line.draw(this);
  169. }
  170. else if (linejoin == LINE_JOIN_BEVEL)
  171. {
  172. BevelJoinPolyline line;
  173. line.render(coords, count, halfwidth, pixelsize, linestyle == LINE_SMOOTH);
  174. line.draw(this);
  175. }
  176. else if (linejoin == LINE_JOIN_MITER)
  177. {
  178. MiterJoinPolyline line;
  179. line.render(coords, count, halfwidth, pixelsize, linestyle == LINE_SMOOTH);
  180. line.draw(this);
  181. }
  182. }
  183. void Graphics::rectangle(DrawMode mode, float x, float y, float w, float h)
  184. {
  185. float coords[] = {x,y, x,y+h, x+w,y+h, x+w,y, x,y};
  186. polygon(mode, coords, 5 * 2);
  187. }
  188. void Graphics::rectangle(DrawMode mode, float x, float y, float w, float h, float rx, float ry, int points)
  189. {
  190. if (rx == 0 || ry == 0)
  191. {
  192. rectangle(mode, x, y, w, h);
  193. return;
  194. }
  195. // Radius values that are more than half the rectangle's size aren't handled
  196. // correctly (for now)...
  197. if (w >= 0.02f)
  198. rx = std::min(rx, w / 2.0f - 0.01f);
  199. if (h >= 0.02f)
  200. ry = std::min(ry, h / 2.0f - 0.01f);
  201. points = std::max(points / 4, 1);
  202. const float half_pi = static_cast<float>(LOVE_M_PI / 2);
  203. float angle_shift = half_pi / ((float) points + 1.0f);
  204. int num_coords = (points + 2) * 8;
  205. float *coords = getScratchBuffer<float>(num_coords + 2);
  206. float phi = .0f;
  207. for (int i = 0; i <= points + 2; ++i, phi += angle_shift)
  208. {
  209. coords[2 * i + 0] = x + rx * (1 - cosf(phi));
  210. coords[2 * i + 1] = y + ry * (1 - sinf(phi));
  211. }
  212. phi = half_pi;
  213. for (int i = points + 2; i <= 2 * (points + 2); ++i, phi += angle_shift)
  214. {
  215. coords[2 * i + 0] = x + w - rx * (1 + cosf(phi));
  216. coords[2 * i + 1] = y + ry * (1 - sinf(phi));
  217. }
  218. phi = 2 * half_pi;
  219. for (int i = 2 * (points + 2); i <= 3 * (points + 2); ++i, phi += angle_shift)
  220. {
  221. coords[2 * i + 0] = x + w - rx * (1 + cosf(phi));
  222. coords[2 * i + 1] = y + h - ry * (1 + sinf(phi));
  223. }
  224. phi = 3 * half_pi;
  225. for (int i = 3 * (points + 2); i <= 4 * (points + 2); ++i, phi += angle_shift)
  226. {
  227. coords[2 * i + 0] = x + rx * (1 - cosf(phi));
  228. coords[2 * i + 1] = y + h - ry * (1 + sinf(phi));
  229. }
  230. coords[num_coords + 0] = coords[0];
  231. coords[num_coords + 1] = coords[1];
  232. polygon(mode, coords, num_coords + 2);
  233. }
  234. void Graphics::rectangle(DrawMode mode, float x, float y, float w, float h, float rx, float ry)
  235. {
  236. rectangle(mode, x, y, w, h, rx, ry, calculateEllipsePoints(rx, ry));
  237. }
  238. void Graphics::circle(DrawMode mode, float x, float y, float radius, int points)
  239. {
  240. ellipse(mode, x, y, radius, radius, points);
  241. }
  242. void Graphics::circle(DrawMode mode, float x, float y, float radius)
  243. {
  244. ellipse(mode, x, y, radius, radius);
  245. }
  246. void Graphics::ellipse(DrawMode mode, float x, float y, float a, float b, int points)
  247. {
  248. float two_pi = (float) (LOVE_M_PI * 2);
  249. if (points <= 0) points = 1;
  250. float angle_shift = (two_pi / points);
  251. float phi = .0f;
  252. float *coords = getScratchBuffer<float>(2 * (points + 1));
  253. for (int i = 0; i < points; ++i, phi += angle_shift)
  254. {
  255. coords[2*i+0] = x + a * cosf(phi);
  256. coords[2*i+1] = y + b * sinf(phi);
  257. }
  258. coords[2*points+0] = coords[0];
  259. coords[2*points+1] = coords[1];
  260. polygon(mode, coords, (points + 1) * 2);
  261. }
  262. void Graphics::ellipse(DrawMode mode, float x, float y, float a, float b)
  263. {
  264. ellipse(mode, x, y, a, b, calculateEllipsePoints(a, b));
  265. }
  266. void Graphics::arc(DrawMode drawmode, ArcMode arcmode, float x, float y, float radius, float angle1, float angle2, int points)
  267. {
  268. // Nothing to display with no points or equal angles. (Or is there with line mode?)
  269. if (points <= 0 || angle1 == angle2)
  270. return;
  271. // Oh, you want to draw a circle?
  272. if (fabs(angle1 - angle2) >= 2.0f * (float) LOVE_M_PI)
  273. {
  274. circle(drawmode, x, y, radius, points);
  275. return;
  276. }
  277. float angle_shift = (angle2 - angle1) / points;
  278. // Bail on precision issues.
  279. if (angle_shift == 0.0)
  280. return;
  281. // Prevent the connecting line from being drawn if a closed line arc has a
  282. // small angle. Avoids some visual issues when connected lines are at sharp
  283. // angles, due to the miter line join drawing code.
  284. if (drawmode == DRAW_LINE && arcmode == ARC_CLOSED && fabsf(angle1 - angle2) < LOVE_TORAD(4))
  285. arcmode = ARC_OPEN;
  286. // Quick fix for the last part of a filled open arc not being drawn (because
  287. // polygon(DRAW_FILL, ...) doesn't work without a closed loop of vertices.)
  288. if (drawmode == DRAW_FILL && arcmode == ARC_OPEN)
  289. arcmode = ARC_CLOSED;
  290. float phi = angle1;
  291. float *coords = nullptr;
  292. int num_coords = 0;
  293. const auto createPoints = [&](float *coordinates)
  294. {
  295. for (int i = 0; i <= points; ++i, phi += angle_shift)
  296. {
  297. coordinates[2 * i + 0] = x + radius * cosf(phi);
  298. coordinates[2 * i + 1] = y + radius * sinf(phi);
  299. }
  300. };
  301. if (arcmode == ARC_PIE)
  302. {
  303. num_coords = (points + 3) * 2;
  304. coords = getScratchBuffer<float>(num_coords);
  305. coords[0] = coords[num_coords - 2] = x;
  306. coords[1] = coords[num_coords - 1] = y;
  307. createPoints(coords + 2);
  308. }
  309. else if (arcmode == ARC_OPEN)
  310. {
  311. num_coords = (points + 1) * 2;
  312. coords = getScratchBuffer<float>(num_coords);
  313. createPoints(coords);
  314. }
  315. else // ARC_CLOSED
  316. {
  317. num_coords = (points + 2) * 2;
  318. coords = getScratchBuffer<float>(num_coords);
  319. createPoints(coords);
  320. // Connect the ends of the arc.
  321. coords[num_coords - 2] = coords[0];
  322. coords[num_coords - 1] = coords[1];
  323. }
  324. polygon(drawmode, coords, num_coords);
  325. }
  326. void Graphics::arc(DrawMode drawmode, ArcMode arcmode, float x, float y, float radius, float angle1, float angle2)
  327. {
  328. float points = (float) calculateEllipsePoints(radius, radius);
  329. // The amount of points is based on the fraction of the circle created by the arc.
  330. float angle = fabsf(angle1 - angle2);
  331. if (angle < 2.0f * (float) LOVE_M_PI)
  332. points *= angle / (2.0f * (float) LOVE_M_PI);
  333. arc(drawmode, arcmode, x, y, radius, angle1, angle2, (int) (points + 0.5f));
  334. }
  335. /// @param mode the draw mode
  336. /// @param coords the coordinate array
  337. /// @param count the number of coordinates/size of the array
  338. void Graphics::polygon(DrawMode mode, const float *coords, size_t count)
  339. {
  340. // coords is an array of a closed loop of vertices, i.e.
  341. // coords[count-2] = coords[0], coords[count-1] = coords[1]
  342. if (mode == DRAW_LINE)
  343. {
  344. polyline(coords, count);
  345. }
  346. else
  347. {
  348. StreamDrawRequest req;
  349. req.formats[0] = vertex::CommonFormat::XYf;
  350. req.formats[1] = vertex::CommonFormat::RGBAub;
  351. req.indexMode = vertex::TriangleIndexMode::FAN;
  352. req.vertexCount = (int)count/2 - 1;
  353. StreamVertexData data = requestStreamDraw(req);
  354. const Matrix4 &t = getTransform();
  355. t.transform((Vector *) data.stream[0], (const Vector *) coords, req.vertexCount);
  356. Color c = toColor(getColor());
  357. Color *colordata = (Color *) data.stream[1];
  358. for (int i = 0; i < req.vertexCount; i++)
  359. colordata[i] = c;
  360. }
  361. }
  362. const Matrix4 &Graphics::getTransform() const
  363. {
  364. return transformStack.back();
  365. }
  366. const Matrix4 &Graphics::getProjection() const
  367. {
  368. return projectionMatrix;
  369. }
  370. void Graphics::pushTransform()
  371. {
  372. transformStack.push_back(transformStack.back());
  373. }
  374. void Graphics::pushIdentityTransform()
  375. {
  376. transformStack.push_back(Matrix4());
  377. }
  378. void Graphics::popTransform()
  379. {
  380. transformStack.pop_back();
  381. }
  382. bool Graphics::getConstant(const char *in, DrawMode &out)
  383. {
  384. return drawModes.find(in, out);
  385. }
  386. bool Graphics::getConstant(DrawMode in, const char *&out)
  387. {
  388. return drawModes.find(in, out);
  389. }
  390. bool Graphics::getConstant(const char *in, ArcMode &out)
  391. {
  392. return arcModes.find(in, out);
  393. }
  394. bool Graphics::getConstant(ArcMode in, const char *&out)
  395. {
  396. return arcModes.find(in, out);
  397. }
  398. bool Graphics::getConstant(const char *in, BlendMode &out)
  399. {
  400. return blendModes.find(in, out);
  401. }
  402. bool Graphics::getConstant(BlendMode in, const char *&out)
  403. {
  404. return blendModes.find(in, out);
  405. }
  406. bool Graphics::getConstant(const char *in, BlendAlpha &out)
  407. {
  408. return blendAlphaModes.find(in, out);
  409. }
  410. bool Graphics::getConstant(BlendAlpha in, const char *&out)
  411. {
  412. return blendAlphaModes.find(in, out);
  413. }
  414. bool Graphics::getConstant(const char *in, LineStyle &out)
  415. {
  416. return lineStyles.find(in, out);
  417. }
  418. bool Graphics::getConstant(LineStyle in, const char *&out)
  419. {
  420. return lineStyles.find(in, out);
  421. }
  422. bool Graphics::getConstant(const char *in, LineJoin &out)
  423. {
  424. return lineJoins.find(in, out);
  425. }
  426. bool Graphics::getConstant(LineJoin in, const char *&out)
  427. {
  428. return lineJoins.find(in, out);
  429. }
  430. bool Graphics::getConstant(const char *in, StencilAction &out)
  431. {
  432. return stencilActions.find(in, out);
  433. }
  434. bool Graphics::getConstant(StencilAction in, const char *&out)
  435. {
  436. return stencilActions.find(in, out);
  437. }
  438. bool Graphics::getConstant(const char *in, CompareMode &out)
  439. {
  440. return compareModes.find(in, out);
  441. }
  442. bool Graphics::getConstant(CompareMode in, const char *&out)
  443. {
  444. return compareModes.find(in, out);
  445. }
  446. bool Graphics::getConstant(const char *in, Feature &out)
  447. {
  448. return features.find(in, out);
  449. }
  450. bool Graphics::getConstant(Feature in, const char *&out)
  451. {
  452. return features.find(in, out);
  453. }
  454. bool Graphics::getConstant(const char *in, SystemLimit &out)
  455. {
  456. return systemLimits.find(in, out);
  457. }
  458. bool Graphics::getConstant(SystemLimit in, const char *&out)
  459. {
  460. return systemLimits.find(in, out);
  461. }
  462. bool Graphics::getConstant(const char *in, StackType &out)
  463. {
  464. return stackTypes.find(in, out);
  465. }
  466. bool Graphics::getConstant(StackType in, const char *&out)
  467. {
  468. return stackTypes.find(in, out);
  469. }
  470. StringMap<Graphics::DrawMode, Graphics::DRAW_MAX_ENUM>::Entry Graphics::drawModeEntries[] =
  471. {
  472. { "line", DRAW_LINE },
  473. { "fill", DRAW_FILL },
  474. };
  475. StringMap<Graphics::DrawMode, Graphics::DRAW_MAX_ENUM> Graphics::drawModes(Graphics::drawModeEntries, sizeof(Graphics::drawModeEntries));
  476. StringMap<Graphics::ArcMode, Graphics::ARC_MAX_ENUM>::Entry Graphics::arcModeEntries[] =
  477. {
  478. { "open", ARC_OPEN },
  479. { "closed", ARC_CLOSED },
  480. { "pie", ARC_PIE },
  481. };
  482. StringMap<Graphics::ArcMode, Graphics::ARC_MAX_ENUM> Graphics::arcModes(Graphics::arcModeEntries, sizeof(Graphics::arcModeEntries));
  483. StringMap<Graphics::BlendMode, Graphics::BLEND_MAX_ENUM>::Entry Graphics::blendModeEntries[] =
  484. {
  485. { "alpha", BLEND_ALPHA },
  486. { "add", BLEND_ADD },
  487. { "subtract", BLEND_SUBTRACT },
  488. { "multiply", BLEND_MULTIPLY },
  489. { "lighten", BLEND_LIGHTEN },
  490. { "darken", BLEND_DARKEN },
  491. { "screen", BLEND_SCREEN },
  492. { "replace", BLEND_REPLACE },
  493. };
  494. StringMap<Graphics::BlendMode, Graphics::BLEND_MAX_ENUM> Graphics::blendModes(Graphics::blendModeEntries, sizeof(Graphics::blendModeEntries));
  495. StringMap<Graphics::BlendAlpha, Graphics::BLENDALPHA_MAX_ENUM>::Entry Graphics::blendAlphaEntries[] =
  496. {
  497. { "alphamultiply", BLENDALPHA_MULTIPLY },
  498. { "premultiplied", BLENDALPHA_PREMULTIPLIED },
  499. };
  500. StringMap<Graphics::BlendAlpha, Graphics::BLENDALPHA_MAX_ENUM> Graphics::blendAlphaModes(Graphics::blendAlphaEntries, sizeof(Graphics::blendAlphaEntries));
  501. StringMap<Graphics::LineStyle, Graphics::LINE_MAX_ENUM>::Entry Graphics::lineStyleEntries[] =
  502. {
  503. { "smooth", LINE_SMOOTH },
  504. { "rough", LINE_ROUGH }
  505. };
  506. StringMap<Graphics::LineStyle, Graphics::LINE_MAX_ENUM> Graphics::lineStyles(Graphics::lineStyleEntries, sizeof(Graphics::lineStyleEntries));
  507. StringMap<Graphics::LineJoin, Graphics::LINE_JOIN_MAX_ENUM>::Entry Graphics::lineJoinEntries[] =
  508. {
  509. { "none", LINE_JOIN_NONE },
  510. { "miter", LINE_JOIN_MITER },
  511. { "bevel", LINE_JOIN_BEVEL }
  512. };
  513. StringMap<Graphics::LineJoin, Graphics::LINE_JOIN_MAX_ENUM> Graphics::lineJoins(Graphics::lineJoinEntries, sizeof(Graphics::lineJoinEntries));
  514. StringMap<Graphics::StencilAction, Graphics::STENCIL_MAX_ENUM>::Entry Graphics::stencilActionEntries[] =
  515. {
  516. { "replace", STENCIL_REPLACE },
  517. { "increment", STENCIL_INCREMENT },
  518. { "decrement", STENCIL_DECREMENT },
  519. { "incrementwrap", STENCIL_INCREMENT_WRAP },
  520. { "decrementwrap", STENCIL_DECREMENT_WRAP },
  521. { "invert", STENCIL_INVERT },
  522. };
  523. StringMap<Graphics::StencilAction, Graphics::STENCIL_MAX_ENUM> Graphics::stencilActions(Graphics::stencilActionEntries, sizeof(Graphics::stencilActionEntries));
  524. StringMap<Graphics::CompareMode, Graphics::COMPARE_MAX_ENUM>::Entry Graphics::compareModeEntries[] =
  525. {
  526. { "less", COMPARE_LESS },
  527. { "lequal", COMPARE_LEQUAL },
  528. { "equal", COMPARE_EQUAL },
  529. { "gequal", COMPARE_GEQUAL },
  530. { "greater", COMPARE_GREATER },
  531. { "notequal", COMPARE_NOTEQUAL },
  532. { "always", COMPARE_ALWAYS },
  533. };
  534. StringMap<Graphics::CompareMode, Graphics::COMPARE_MAX_ENUM> Graphics::compareModes(Graphics::compareModeEntries, sizeof(Graphics::compareModeEntries));
  535. StringMap<Graphics::Feature, Graphics::FEATURE_MAX_ENUM>::Entry Graphics::featureEntries[] =
  536. {
  537. { "multicanvasformats", FEATURE_MULTI_CANVAS_FORMATS },
  538. { "clampzero", FEATURE_CLAMP_ZERO },
  539. { "lighten", FEATURE_LIGHTEN },
  540. { "fullnpot", FEATURE_FULL_NPOT },
  541. { "pixelshaderhighp", FEATURE_PIXEL_SHADER_HIGHP },
  542. };
  543. StringMap<Graphics::Feature, Graphics::FEATURE_MAX_ENUM> Graphics::features(Graphics::featureEntries, sizeof(Graphics::featureEntries));
  544. StringMap<Graphics::SystemLimit, Graphics::LIMIT_MAX_ENUM>::Entry Graphics::systemLimitEntries[] =
  545. {
  546. { "pointsize", LIMIT_POINT_SIZE },
  547. { "texturesize", LIMIT_TEXTURE_SIZE },
  548. { "multicanvas", LIMIT_MULTI_CANVAS },
  549. { "canvasmsaa", LIMIT_CANVAS_MSAA },
  550. { "anisotropy", LIMIT_ANISOTROPY },
  551. };
  552. StringMap<Graphics::SystemLimit, Graphics::LIMIT_MAX_ENUM> Graphics::systemLimits(Graphics::systemLimitEntries, sizeof(Graphics::systemLimitEntries));
  553. StringMap<Graphics::StackType, Graphics::STACK_MAX_ENUM>::Entry Graphics::stackTypeEntries[] =
  554. {
  555. { "all", STACK_ALL },
  556. { "transform", STACK_TRANSFORM },
  557. };
  558. StringMap<Graphics::StackType, Graphics::STACK_MAX_ENUM> Graphics::stackTypes(Graphics::stackTypeEntries, sizeof(Graphics::stackTypeEntries));
  559. } // graphics
  560. } // love