Optibits
Loading...
Searching...
No Matches
GraphicsImpl.hpp
1#pragma once
2
3#include <Optibits/Bitmap.hpp>
4#include <Optibits/Graphics.hpp>
5#include <Optibits/Platform.hpp>
6#include <algorithm>
7#include <cstdint>
8#include <list>
9#include <vector>
10
11namespace Optibits
12{
13
14 //****************************************
15 // RENDER STATE
16 //****************************************
17 struct RenderState;
18 class RenderStateManager;
19
20
21 enum QueueMode
22 {
23 QM_RENDER_TO_SCREEN,
24 QM_RENDER_TO_TEXTURE,
25 QM_RENDER_TO_MACRO
26 };
27
28 class Texture;
29 class TextChunk;
30 class ClipRectStack;
31
32 //****************************************
33 // Drawing OP
34 //****************************************
35 struct DrawOp;
36 class DrawQueue;
37 typedef std::list<Transform> Transforms;
38 typedef std::list<DrawQueue> DrawOpQueueStack;
39 class Macro;
40
42 {
43 float texCoords[2];
44 std::uint32_t color;
45 float vertices[3];
46 };
47
48 template<typename T>
49 bool ispToTheleftOfab(T xa, T ya, T xb, T yb, T xp, T yp)
50 {
51 return (xb - xa) * (yp - ya) - (xp - xa) * (yb - ya) > 0;
52 }
53
54 template<typename T, typename C>
55 void normalizeCoordinates(T& x1, T& y1, T& x2, T& y2, T& x3, T& y3, C& c3, T& x4, T& y4, C& c4)
56 {
57 if (ispToTheleftOfab(x1, y1, x2, y2, x3, y3) ==
58 ispToTheleftOfab(x2, y2, x3, y3, x4, y4)) {
59 std::swap(x3, x4);
60 std::swap(y3, y4);
61 std::swap(c3, c4);
62 }
63 }
64
65
66 void scheduleDrawOp(const DrawOp& op);
67
68 void registerFrame();
69
70 inline std::string escapeMarkup(const std::string& text) {
71 auto markup = text;
72 for (std::string::size_type pos = 0; pos < markup.length(); ++pos) {
73 if (markup[pos] == '&') {
74 markup.replace(pos, 1, "&amp;");
75 }
76 else if (markup[pos] == '<') {
77 markup.replace(pos, 1, "&lt;");
78 }
79 }
80 return markup;
81 }
82}
Definition GraphicsImpl.hpp:42