Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
glimBatchAttributes.cpp
Go to the documentation of this file.
1/*
2** GLIM - OpenGL Immediate Mode
3** Copyright Jan Krassnigg (Jan@Krassnigg.de)
4** For more details, see the included Readme.txt.
5*/
6
7
8
9#include "glimBatch.h"
10
11namespace NS_GLIM
12{
13
14 void GLIM_BATCH::Attribute1f (GLIM_ATTRIBUTE Data, float a1) noexcept
15 {
16 Data.m_CurrentValue[0].Float = a1;
17
18 const GLIM_ENUM Type = GLIM_ENUM::GLIM_1F;
19
20 // Check that either the batch is just about to be created, or the attribute has already been mentioned before.
21 GLIM_CHECK (m_Data.m_State == GLIM_BATCH_STATE::STATE_BEGINNING_BATCH || Data.m_DataType != GLIM_ENUM::GLIM_NODATA, "GLIM::glimAttribute1f: All to-be-used attributes need to be set to default values, after BeginBatch and before Begin is called.");
22
23 // check that the type matches
24 GLIM_CHECK (Data.m_DataType == Type || Data.m_DataType == GLIM_ENUM::GLIM_NODATA, "GLIM::glimAttribute1f: An attribute was used with different type than previously.");
25 // set the type
26 Data.m_DataType = Type;
27
28 }
29
30 void GLIM_BATCH::Attribute2f (GLIM_ATTRIBUTE Data, float a1, float a2) noexcept
31 {
32 Data.m_CurrentValue[0].Float = a1;
33 Data.m_CurrentValue[1].Float = a2;
34
35 const GLIM_ENUM Type = GLIM_ENUM::GLIM_2F;
36
37 // Check that either the batch is just about to be created, or the attribute has already been mentioned before.
38 GLIM_CHECK (m_Data.m_State == GLIM_BATCH_STATE::STATE_BEGINNING_BATCH || Data.m_DataType != GLIM_ENUM::GLIM_NODATA, "GLIM::Attribute2f: All to-be-used attributes need to be set to default values, after BeginBatch and before Begin is called.");
39
40 // check that the type matches
41 GLIM_CHECK (Data.m_DataType == Type || Data.m_DataType == GLIM_ENUM::GLIM_NODATA, "GLIM::glimAttribute2f: An attribute was used with different type than previously.");
42 // set the type
43 Data.m_DataType = Type;
44 }
45
46 void GLIM_BATCH::Attribute3f (GLIM_ATTRIBUTE Data, float a1, float a2, float a3) noexcept
47 {
48 Data.m_CurrentValue[0].Float = a1;
49 Data.m_CurrentValue[1].Float = a2;
50 Data.m_CurrentValue[2].Float = a3;
51
52 const GLIM_ENUM Type = GLIM_ENUM::GLIM_3F;
53
54 // Check that either the batch is just about to be created, or the attribute has already been mentioned before.
55 GLIM_CHECK (m_Data.m_State == GLIM_BATCH_STATE::STATE_BEGINNING_BATCH || Data.m_DataType != GLIM_ENUM::GLIM_NODATA, "GLIM::Attribute3f: All to-be-used attributes need to be set to default values, after BeginBatch and before Begin is called.");
56
57 // check that the type matches
58 GLIM_CHECK (Data.m_DataType == Type || Data.m_DataType == GLIM_ENUM::GLIM_NODATA, "GLIM::glimAttribute3f: An attribute was used with different type than previously.");
59 // set the type
60 Data.m_DataType = Type;
61 }
62
63 void GLIM_BATCH::Attribute4f (GLIM_ATTRIBUTE Data, float a1, float a2, float a3, float a4) noexcept
64 {
65 Data.m_CurrentValue[0].Float = a1;
66 Data.m_CurrentValue[1].Float = a2;
67 Data.m_CurrentValue[2].Float = a3;
68 Data.m_CurrentValue[3].Float = a4;
69
70 const GLIM_ENUM Type = GLIM_ENUM::GLIM_4F;
71
72 // Check that either the batch is just about to be created, or the attribute has already been mentioned before.
73 GLIM_CHECK (m_Data.m_State == GLIM_BATCH_STATE::STATE_BEGINNING_BATCH || Data.m_DataType != GLIM_ENUM::GLIM_NODATA, "GLIM::Attribute4f: All to-be-used attributes need to be set to default values, after BeginBatch and before Begin is called.");
74
75 // check that the type matches
76 GLIM_CHECK (Data.m_DataType == Type || Data.m_DataType == GLIM_ENUM::GLIM_NODATA, "GLIM::glimAttribute4f: An attribute was used with different type than previously.");
77 // set the type
78 Data.m_DataType = Type;
79 }
80
81
82 void GLIM_BATCH::Attribute1i (GLIM_ATTRIBUTE Data, int a1) noexcept
83 {
84 Data.m_CurrentValue[0].Int = a1;
85
86 const GLIM_ENUM Type = GLIM_ENUM::GLIM_1I;
87
88 // Check that either the batch is just about to be created, or the attribute has already been mentioned before.
89 GLIM_CHECK (m_Data.m_State == GLIM_BATCH_STATE::STATE_BEGINNING_BATCH || Data.m_DataType != GLIM_ENUM::GLIM_NODATA, "GLIM::Attribute1i: All to-be-used attributes need to be set to default values, after BeginBatch and before Begin is called.");
90
91 // check that the type matches
92 GLIM_CHECK (Data.m_DataType == Type || Data.m_DataType == GLIM_ENUM::GLIM_NODATA, "GLIM::glimAttribute1i: An attribute was used with different type than previously.");
93 // set the type
94 Data.m_DataType = Type;
95 }
96
97 void GLIM_BATCH::Attribute2i (GLIM_ATTRIBUTE Data, int a1, int a2) noexcept
98 {
99 Data.m_CurrentValue[0].Int = a1;
100 Data.m_CurrentValue[1].Int = a2;
101
102 const GLIM_ENUM Type = GLIM_ENUM::GLIM_2I;
103
104 // Check that either the batch is just about to be created, or the attribute has already been mentioned before.
105 GLIM_CHECK (m_Data.m_State == GLIM_BATCH_STATE::STATE_BEGINNING_BATCH || Data.m_DataType != GLIM_ENUM::GLIM_NODATA, "GLIM::Attribute2i: All to-be-used attributes need to be set to default values, after BeginBatch and before Begin is called.");
106
107 // check that the type matches
108 GLIM_CHECK (Data.m_DataType == Type || Data.m_DataType == GLIM_ENUM::GLIM_NODATA, "GLIM::glimAttribute2i: An attribute was used with different type than previously.");
109 // set the type
110 Data.m_DataType = Type;
111 }
112
113 void GLIM_BATCH::Attribute3i (GLIM_ATTRIBUTE Data, int a1, int a2, int a3) noexcept
114 {
115 Data.m_CurrentValue[0].Int = a1;
116 Data.m_CurrentValue[1].Int = a2;
117 Data.m_CurrentValue[2].Int = a3;
118
119 const GLIM_ENUM Type = GLIM_ENUM::GLIM_3I;
120
121 // Check that either the batch is just about to be created, or the attribute has already been mentioned before.
122 GLIM_CHECK (m_Data.m_State == GLIM_BATCH_STATE::STATE_BEGINNING_BATCH || Data.m_DataType != GLIM_ENUM::GLIM_NODATA, "GLIM::Attribute3i: All to-be-used attributes need to be set to default values, after BeginBatch and before Begin is called.");
123
124 // check that the type matches
125 GLIM_CHECK (Data.m_DataType == Type || Data.m_DataType == GLIM_ENUM::GLIM_NODATA, "GLIM::glimAttribute3i: An attribute was used with different type than previously.");
126 // set the type
127 Data.m_DataType = Type;
128 }
129
130 void GLIM_BATCH::Attribute4i (GLIM_ATTRIBUTE Data, int a1, int a2, int a3, int a4) noexcept
131 {
132 Data.m_CurrentValue[0].Int = a1;
133 Data.m_CurrentValue[1].Int = a2;
134 Data.m_CurrentValue[2].Int = a3;
135 Data.m_CurrentValue[3].Int = a4;
136
137 const GLIM_ENUM Type = GLIM_ENUM::GLIM_4I;
138
139 // Check that either the batch is just about to be created, or the attribute has already been mentioned before.
140 GLIM_CHECK (m_Data.m_State == GLIM_BATCH_STATE::STATE_BEGINNING_BATCH || Data.m_DataType != GLIM_ENUM::GLIM_NODATA, "GLIM::Attribute4i: All to-be-used attributes need to be set to default values, after BeginBatch and before Begin is called.");
141
142 // check that the type matches
143 GLIM_CHECK (Data.m_DataType == Type || Data.m_DataType == GLIM_ENUM::GLIM_NODATA, "GLIM::glimAttribute4i: An attribute was used with different type than previously.");
144 // set the type
145 Data.m_DataType = Type;
146 }
147
148
149 void GLIM_BATCH::Attribute4ub (GLIM_ATTRIBUTE Data, unsigned char a1, unsigned char a2, unsigned char a3, unsigned char a4) noexcept
150 {
151 Data.m_CurrentValue[0].Bytes[0] = a1;
152 Data.m_CurrentValue[0].Bytes[1] = a2;
153 Data.m_CurrentValue[0].Bytes[2] = a3;
154 Data.m_CurrentValue[0].Bytes[3] = a4;
155
156 const GLIM_ENUM Type = GLIM_ENUM::GLIM_4UB;
157
158 // Check that either the batch is just about to be created, or the attribute has already been mentioned before.
159 GLIM_CHECK (m_Data.m_State == GLIM_BATCH_STATE::STATE_BEGINNING_BATCH || Data.m_DataType != GLIM_ENUM::GLIM_NODATA, "GLIM::Attribute4ub: All to-be-used attributes need to be set to default values, after BeginBatch and before Begin is called.");
160
161 // check that the type matches
162 GLIM_CHECK (Data.m_DataType == Type || Data.m_DataType == GLIM_ENUM::GLIM_NODATA, "GLIM::glimAttribute4ub: An attribute was used with different type than previously.");
163 // set the type
164 Data.m_DataType = Type;
165 }
166
167
168 GLIM_ATTRIBUTE GLIM_BATCH::Attribute1f (unsigned int attribLocation, float a1)
169 {
170 GlimArrayData& Data = m_Data.m_Attributes[attribLocation];
171
172 Attribute1f (Data, a1);
173
174 return Data;
175 }
176
177 GLIM_ATTRIBUTE GLIM_BATCH::Attribute2f (unsigned int attribLocation, float a1, float a2)
178 {
179 GlimArrayData& Data = m_Data.m_Attributes[attribLocation];
180
181 Attribute2f (Data, a1, a2);
182
183 return Data;
184 }
185
186 GLIM_ATTRIBUTE GLIM_BATCH::Attribute3f (unsigned int attribLocation, float a1, float a2, float a3)
187 {
188 GlimArrayData& Data = m_Data.m_Attributes[attribLocation];
189
190 Attribute3f (Data, a1, a2, a3);
191
192 return Data;
193 }
194
195 GLIM_ATTRIBUTE GLIM_BATCH::Attribute4f (unsigned int attribLocation, float a1, float a2, float a3, float a4)
196 {
197 GlimArrayData& Data = m_Data.m_Attributes[attribLocation];
198
199 Attribute4f (Data, a1, a2, a3, a4);
200
201 return Data;
202 }
203
204 GLIM_ATTRIBUTE GLIM_BATCH::Attribute1i (unsigned int attribLocation, int a1)
205 {
206 GlimArrayData& Data = m_Data.m_Attributes[attribLocation];
207
208 Attribute1i (Data, a1);
209
210 return Data;
211 }
212
213 GLIM_ATTRIBUTE GLIM_BATCH::Attribute2i (unsigned int attribLocation, int a1, int a2)
214 {
215 GlimArrayData& Data = m_Data.m_Attributes[attribLocation];
216
217 Attribute2i (Data, a1, a2);
218
219 return Data;
220 }
221
222 GLIM_ATTRIBUTE GLIM_BATCH::Attribute3i (unsigned int attribLocation, int a1, int a2, int a3)
223 {
224 GlimArrayData& Data = m_Data.m_Attributes[attribLocation];
225
226 Attribute3i (Data, a1, a2, a3);
227
228 return Data;
229 }
230
231 GLIM_ATTRIBUTE GLIM_BATCH::Attribute4i (unsigned int attribLocation, int a1, int a2, int a3, int a4)
232 {
233 GlimArrayData& Data = m_Data.m_Attributes[attribLocation];
234
235 Attribute4i (Data, a1, a2, a3, a4);
236
237 return Data;
238 }
239
240 GLIM_ATTRIBUTE GLIM_BATCH::Attribute4ub (unsigned int attribLocation, unsigned char a1, unsigned char a2, unsigned char a3, unsigned char a4)
241 {
242 GlimArrayData& Data = m_Data.m_Attributes[attribLocation];
243
244 Attribute4ub (Data, a1, a2, a3, a4);
245
246 return Data;
247 }
248
249
250}
251
GLIM_ATTRIBUTE Attribute4i(unsigned int attribLocation, int a1, int a2, int a3, int a4)
Specifies a new value for the attribute with the given name.
GLIM_ATTRIBUTE Attribute4ub(unsigned int attribLocation, unsigned char a1, unsigned char a2, unsigned char a3, unsigned char a4=255)
Specifies a new value for the attribute with the given name.
GLIM_ATTRIBUTE Attribute3i(unsigned int attribLocation, int a1, int a2, int a3)
Specifies a new value for the attribute with the given name.
GLIM_ATTRIBUTE Attribute1i(unsigned int attribLocation, int a1)
Specifies a new value for the attribute with the given location.
glimBatchData m_Data
Definition: glimBatch.h:99
GLIM_ATTRIBUTE Attribute2i(unsigned int attribLocation, int a1, int a2)
Specifies a new value for the attribute with the given name.
GLIM_ATTRIBUTE Attribute1f(unsigned int attribLocation, float a1)
Specifies a new value for the attribute with the given name.
GLIM_ATTRIBUTE Attribute2f(unsigned int attribLocation, float a1, float a2)
Specifies a new value for the attribute with the given name.
GLIM_ATTRIBUTE Attribute3f(unsigned int attribLocation, float a1, float a2, float a3)
Specifies a new value for the attribute with the given name.
GLIM_ATTRIBUTE Attribute4f(unsigned int attribLocation, float a1, float a2, float a3, float a4)
Specifies a new value for the attribute with the given name.
void GLIM_CHECK(bool bCondition, const char *szErrorMsg) noexcept
Assert Macro used internally.
Definition: Declarations.h:66
GLIM_ENUM
The enum holding all important GLIM configuration values.
Definition: Declarations.h:17
Glim4ByteData m_CurrentValue[4]
Definition: glimBatchData.h:40
Divide::hashMap< unsigned int, GlimArrayData > m_Attributes
Definition: glimBatchData.h:72
unsigned char Bytes[4]
Definition: glimBatchData.h:26