Skip to content
This repository was archived by the owner on Mar 19, 2025. It is now read-only.

Commit a4934da

Browse files
committed
test.pl replace GL_QUADS with GL_TRIANGLES
1 parent 532a612 commit a4934da

File tree

1 file changed

+63
-17
lines changed

1 file changed

+63
-17
lines changed

test.pl

+63-17
Original file line numberDiff line numberDiff line change
@@ -129,44 +129,62 @@
129129
-1.0, -1.3, -1.0,
130130
1.0, -1.3, -1.0,
131131
1.0, -1.3, 1.0,
132+
1.0, -1.3, 1.0,
132133
-1.0, -1.3, 1.0,
134+
-1.0, -1.3, -1.0,
133135

134136
-1.0, 1.3, -1.0,
135137
-1.0, 1.3, 1.0,
136138
1.0, 1.3, 1.0,
139+
1.0, 1.3, 1.0,
137140
1.0, 1.3, -1.0,
141+
-1.0, 1.3, -1.0,
138142

139143
-1.0, -1.0, -1.3,
140144
-1.0, 1.0, -1.3,
141145
1.0, 1.0, -1.3,
146+
1.0, 1.0, -1.3,
142147
1.0, -1.0, -1.3,
148+
-1.0, -1.0, -1.3,
143149

144150
1.3, -1.0, -1.0,
145151
1.3, 1.0, -1.0,
146152
1.3, 1.0, 1.0,
153+
1.3, 1.0, 1.0,
147154
1.3, -1.0, 1.0,
155+
1.3, -1.0, -1.0,
148156

149157
-1.0, -1.0, 1.3,
150158
1.0, -1.0, 1.3,
151159
1.0, 1.0, 1.3,
160+
1.0, 1.0, 1.3,
152161
-1.0, 1.0, 1.3,
162+
-1.0, -1.0, 1.3,
153163

154164
-1.3, -1.0, -1.0,
155165
-1.3, -1.0, 1.0,
156166
-1.3, 1.0, 1.0,
157-
-1.3, 1.0, -1.0
167+
-1.3, 1.0, 1.0,
168+
-1.3, 1.0, -1.0,
169+
-1.3, -1.0, -1.0,
158170
);
159171
my $verts = OpenGL::Array->new_list(GL_FLOAT,@verts);
160172

161173
# Could calc norms on the fly
162174
my @norms =
163175
(
176+
0.0, -1.0, 0.0,
164177
0.0, -1.0, 0.0,
165178
0.0, 1.0, 0.0,
179+
0.0, 1.0, 0.0,
180+
0.0, 0.0,-1.0,
166181
0.0, 0.0,-1.0,
167182
1.0, 0.0, 0.0,
183+
1.0, 0.0, 0.0,
168184
0.0, 0.0, 1.0,
169-
-1.0, 0.0, 0.0
185+
0.0, 0.0, 1.0,
186+
-1.0, 0.0, 0.0,
187+
-1.0, 0.0, 0.0,
170188
);
171189
my $norms = OpenGL::Array->new_list(GL_FLOAT,@norms);
172190

@@ -176,31 +194,43 @@
176194
0.9,0.2,0.2,.75,
177195
0.9,0.2,0.2,.75,
178196
0.9,0.2,0.2,.75,
197+
0.9,0.2,0.2,.75,
198+
0.9,0.2,0.2,.75,
179199

180200
0.5,0.5,0.5,.5,
181201
0.5,0.5,0.5,.5,
182202
0.5,0.5,0.5,.5,
183203
0.5,0.5,0.5,.5,
204+
0.5,0.5,0.5,.5,
205+
0.5,0.5,0.5,.5,
184206

185207
0.2,0.9,0.2,.5,
186208
0.2,0.9,0.2,.5,
187209
0.2,0.9,0.2,.5,
188210
0.2,0.9,0.2,.5,
211+
0.2,0.9,0.2,.5,
212+
0.2,0.9,0.2,.5,
189213

190214
0.2,0.2,0.9,.25,
191215
0.2,0.2,0.9,.25,
192216
0.2,0.2,0.9,.25,
193217
0.2,0.2,0.9,.25,
218+
0.2,0.2,0.9,.25,
219+
0.2,0.2,0.9,.25,
194220

195221
0.9, 0.2, 0.2, 0.5,
196222
0.2, 0.9, 0.2, 0.5,
197223
0.2, 0.2, 0.9, 0.5,
224+
0.2, 0.2, 0.9, 0.5,
198225
0.1, 0.1, 0.1, 0.5,
226+
0.9, 0.2, 0.2, 0.5,
199227

200228
0.9,0.9,0.2,0.0,
201229
0.9,0.9,0.2,0.66,
202230
0.9,0.9,0.2,1.0,
203-
0.9,0.9,0.2,0.33
231+
0.9,0.9,0.2,1.0,
232+
0.9,0.9,0.2,0.33,
233+
0.9,0.9,0.2,0.0,
204234
);
205235
my $colors = OpenGL::Array->new_list(GL_FLOAT,@colors);
206236

@@ -209,64 +239,79 @@
209239
0.9, 0.2, 0.2, 0.5,
210240
0.2, 0.9, 0.2, 0.5,
211241
0.2, 0.2, 0.9, 0.5,
212-
0.1, 0.1, 0.1, 0.5
242+
0.2, 0.2, 0.9, 0.5,
243+
0.1, 0.1, 0.1, 0.5,
244+
0.9, 0.2, 0.2, 0.5,
213245
);
214-
215246
my $rainbow = OpenGL::Array->new_list(GL_FLOAT,@rainbow);
216-
my $rainbow_offset = 64;
247+
my $rainbow_offset = 96;
217248
my @rainbow_inc;
218249

219250
my @texcoords =
220251
(
221252
0.800, 0.800,
222253
0.200, 0.800,
223254
0.200, 0.200,
255+
0.200, 0.200,
224256
0.800, 0.200,
257+
0.800, 0.800,
225258

226259
0.005, 1.995,
227260
0.005, 0.005,
228261
1.995, 0.005,
262+
1.995, 0.005,
229263
1.995, 1.995,
264+
0.005, 1.995,
230265

231266
0.995, 0.005,
232267
2.995, 2.995,
233268
0.005, 0.995,
269+
0.005, 0.995,
234270
-1.995, -1.995,
271+
0.995, 0.005,
235272

236273
0.995, 0.005,
237274
0.995, 0.995,
238275
0.005, 0.995,
276+
0.005, 0.995,
239277
0.005, 0.005,
278+
0.995, 0.005,
240279

241280
-0.5, -0.5,
242281
1.5, -0.5,
243282
1.5, 1.5,
283+
1.5, 1.5,
244284
-0.5, 1.5,
285+
-0.5, -0.5,
245286

246287
0.005, 0.005,
247288
0.995, 0.005,
248289
0.995, 0.995,
249-
0.005, 0.995
290+
0.995, 0.995,
291+
0.005, 0.995,
292+
0.005, 0.005,
250293
);
251294
my $texcoords = OpenGL::Array->new_list(GL_FLOAT,@texcoords);
252295

253-
my @indices = (0..23);
296+
my @indices = (0..35);
254297
my $indices = OpenGL::Array->new_list(GL_UNSIGNED_INT,@indices);
255298

256299
my @xform =
257300
(
258301
1.0, 0.0, 0.0, 0.0,
259302
0.0, 1.0, 0.0, 0.0,
260303
0.0, 0.0, 1.0, 0.0,
261-
0.0, 0.0, 0.0, 1.0
304+
0.0, 0.0, 0.0, 1.0,
262305
);
263306
my $xform = OpenGL::Array->new_list(GL_FLOAT,@xform);
264307

265308
my @fpsbox_coords = (
266309
0.0, -2.0, 0.0,
267310
0.0, 12.0, 0.0,
268311
140.0, 12.0, 0.0,
312+
140.0, 12.0, 0.0,
269313
140.0, -2.0, 0.0,
314+
0.0, -2.0, 0.0,
270315
);
271316

272317
# ------
@@ -314,11 +359,12 @@ sub ourPrintString
314359
sub ourInitVertexBuffers
315360
{
316361
# Set initial colors for rainbow face
317-
for (my $i=0; $i<16; $i++)
318-
{
319-
$rainbow[$i] = rand(1.0);
320-
$rainbow_inc[$i] = 0.01 - rand(0.02);
321-
}
362+
@rainbow = map [map rand(1.0), 0..3], 0..3;
363+
@rainbow = @rainbow[0,1,2,2,3,0];
364+
@rainbow = map @$_, @rainbow;
365+
@rainbow_inc = map [map 0.01 - rand(0.02), 0..3], 0..3;
366+
@rainbow_inc = @rainbow_inc[0,1,2,2,3,0];
367+
@rainbow_inc = map @$_, @rainbow_inc;
322368

323369
# Initialize VBOs if supported
324370
if ($hasVBO)
@@ -860,9 +906,9 @@ sub cbRenderScene
860906
glEnableClientState(GL_COLOR_ARRAY);
861907
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
862908

863-
for (my $i=0; $i<scalar(@indices); $i+=4)
909+
for (my $i=0; $i<scalar(@indices); $i+=3)
864910
{
865-
glDrawArrays(GL_QUADS, $i, 4);
911+
glDrawArrays(GL_TRIANGLES, $i, 3);
866912
}
867913

868914
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
@@ -928,7 +974,7 @@ sub cbRenderScene
928974
# Make sure we can read the FPS section by first placing a
929975
# dark, mostly opaque backdrop rectangle.
930976
glColor4f(0.2,0.2,0.2,0.75);
931-
glBegin(GL_QUADS);
977+
glBegin(GL_TRIANGLES);
932978
for (my $i=0; $i<scalar(@fpsbox_coords); $i+=3) {
933979
glVertex3f(@fpsbox_coords[$i..$i+2]);
934980
}

0 commit comments

Comments
 (0)