Nugget
Loading...
Searching...
No Matches
lines.hh
Go to the documentation of this file.
1/*
2
3MIT License
4
5Copyright (c) 2022 PCSX-Redux authors
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software and associated documentation files (the "Software"), to deal
9in the Software without restriction, including without limitation the rights
10to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11copies of the Software, and to permit persons to whom the Software is
12furnished to do so, subject to the following conditions:
13
14The above copyright notice and this permission notice shall be included in all
15copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23SOFTWARE.
24
25*/
26
27#pragma once
28
29#include <EASTL/array.h>
30#include <stdint.h>
31
33
34namespace psyqo {
35
36namespace Prim {
37
44struct Line {
45 Line() : command(0x40000000) {}
46 Line(Color c) : command(0x40000000 | c.packed) {}
48 uint32_t wasSemiTrans = command & 0x02000000;
49 command = 0x40000000 | (c.packed & 0xffffff) | wasSemiTrans;
50 return *this;
51 }
53 command &= ~0x02000000;
54 return *this;
55 }
57 command |= 0x02000000;
58 return *this;
59 }
60
61 private:
62 uint32_t command;
63
64 public:
67};
68static_assert(sizeof(Line) == sizeof(uint32_t) * 3, "Line is not 3 words");
69
80 GouraudLine() : command(0x50000000) {}
81 GouraudLine(Color c) : command(0x50000000 | c.packed) {}
83 uint32_t wasSemiTrans = command & 0x02000000;
84 command = 0x50000000 | (c.packed & 0xffffff) | wasSemiTrans;
85 return *this;
86 }
88 colorB = c;
89 return *this;
90 }
92 command &= ~0x02000000;
93 return *this;
94 }
96 command |= 0x02000000;
97 return *this;
98 }
99
100 private:
101 uint32_t command;
102
103 public:
107};
108static_assert(sizeof(GouraudLine) == sizeof(uint32_t) * 4, "Line is not 4 words");
109
124 PolyLineBegin() : command(0x48000000) {}
125 PolyLineBegin(Color c) : command(0x48000000 | c.packed) {}
127 uint32_t wasSemiTrans = command & 0x02000000;
128 command = 0x48000000 | (c.packed & 0xffffff) | wasSemiTrans;
129 return *this;
130 }
132 command &= ~0x02000000;
133 return *this;
134 }
136 command |= 0x02000000;
137 return *this;
138 }
139
140 private:
141 uint32_t command;
142
143 public:
145};
146static_assert(sizeof(PolyLineBegin) == sizeof(uint32_t) * 2, "PolyLineBegin is not 2 words");
147
149 const uint32_t endMarker = 0x50005000;
150};
151
163template <unsigned N>
164struct PolyLine {
165 PolyLine() : command(0x48000000) {}
166 PolyLine(Color c) : command(0x48000000 | c.packed) {}
168 uint32_t wasSemiTrans = command & 0x02000000;
169 command = 0x48000000 | (c.packed & 0xffffff) | wasSemiTrans;
170 return *this;
171 }
173 command &= ~0x02000000;
174 return *this;
175 }
177 command |= 0x02000000;
178 return *this;
179 }
180
181 private:
182 uint32_t command;
183
184 public:
185 eastl::array<Vertex, N + 1> points;
186
187 private:
188 const uint32_t endMarker = 0x50005000;
189};
190
191} // namespace Prim
192
193} // namespace psyqo
Definition cdrom-loader.hh:39
The Gouraud-shaded Line primitive.
Definition lines.hh:79
GouraudLine & setSemiTrans()
Definition lines.hh:95
GouraudLine & setOpaque()
Definition lines.hh:91
GouraudLine & setColorB(Color c)
Definition lines.hh:87
Vertex pointB
Definition lines.hh:106
GouraudLine(Color c)
Definition lines.hh:81
GouraudLine()
Definition lines.hh:80
Vertex pointA
Definition lines.hh:104
Color colorB
Definition lines.hh:105
GouraudLine & setColorA(Color c)
Definition lines.hh:82
The Line primitive.
Definition lines.hh:44
Vertex pointA
Definition lines.hh:65
Line & setSemiTrans()
Definition lines.hh:56
Vertex pointB
Definition lines.hh:66
Line()
Definition lines.hh:45
Line & setOpaque()
Definition lines.hh:52
Line(Color c)
Definition lines.hh:46
Line & setColor(Color c)
Definition lines.hh:47
The primitive used to begin a polyline.
Definition lines.hh:123
PolyLineBegin & setSemiTrans()
Definition lines.hh:135
PolyLineBegin(Color c)
Definition lines.hh:125
PolyLineBegin()
Definition lines.hh:124
Vertex point
Definition lines.hh:144
PolyLineBegin & setOpaque()
Definition lines.hh:131
PolyLineBegin & setColor(Color c)
Definition lines.hh:126
Definition lines.hh:148
const uint32_t endMarker
Definition lines.hh:149
The primitive used to draw a polyline.
Definition lines.hh:164
PolyLine & setSemiTrans()
Definition lines.hh:176
PolyLine(Color c)
Definition lines.hh:166
PolyLine()
Definition lines.hh:165
PolyLine & setOpaque()
Definition lines.hh:172
PolyLine & setColor(Color c)
Definition lines.hh:167
eastl::array< Vertex, N+1 > points
Definition lines.hh:185
static int c
Definition syscalls.h:121
void uint32_t(classId, spec)
The Color struct.
Definition common.hh:91
The Vertex struct.
Definition common.hh:47