-
Notifications
You must be signed in to change notification settings - Fork 128
/
Copy pathes
455 lines (410 loc) · 14.3 KB
/
es
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
Index: code/renderer/tr_local.h
===================================================================
--- code/renderer/tr_local.h (revision 1305)
+++ code/renderer/tr_local.h (working copy)
@@ -30,8 +30,8 @@
#include "tr_public.h"
#include "qgl.h"
-#define GL_INDEX_TYPE GL_UNSIGNED_INT
-typedef unsigned int glIndex_t;
+#define GL_INDEX_TYPE GL_UNSIGNED_SHORT
+typedef unsigned short glIndex_t;
// fast float to int conversion
#if id386 && !defined(__GNUC__)
Index: code/renderer/tr_shadows.c
===================================================================
--- code/renderer/tr_shadows.c (revision 1305)
+++ code/renderer/tr_shadows.c (working copy)
@@ -124,12 +124,14 @@
// if it doesn't share the edge with another front facing
// triangle, it is a sil edge
if ( hit[ 1 ] == 0 ) {
- qglBegin( GL_TRIANGLE_STRIP );
- qglVertex3fv( tess.xyz[ i ] );
- qglVertex3fv( tess.xyz[ i + tess.numVertexes ] );
- qglVertex3fv( tess.xyz[ i2 ] );
- qglVertex3fv( tess.xyz[ i2 + tess.numVertexes ] );
- qglEnd();
+ glIndex_t indicies[4];
+ indicies[0] = i;
+ indicies[1] = i+tess.numVertexes;
+ indicies[2] = i2;
+ indicies[3] = i2+tess.numVertexes;
+
+ qglVertexPointer( 3, GL_FLOAT, 16, tess.xyz );
+ qglDrawElements( GL_TRIANGLE_STRIP, 4, GL_INDEX_TYPE, indicies );
c_edges++;
} else {
c_rejected++;
@@ -212,7 +214,7 @@
GL_Bind( tr.whiteImage );
qglEnable( GL_CULL_FACE );
GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO );
- qglColor3f( 0.2f, 0.2f, 0.2f );
+ qglColor4f( 0.2f, 0.2f, 0.2f, 1.0f );
// don't write to the color buffer
qglColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );
@@ -260,6 +262,14 @@
=================
*/
void RB_ShadowFinish( void ) {
+ vec3_t quad[4] = {
+ {-100.0f, 100.0f, -10.0},
+ {100.0f, 100.0f, -10.0f},
+ {100.0f, -100.0f, -10.0f},
+ {-100.0f, -100.0f, -10.0f}
+ };
+ glIndex_t indicies[6] = { 0, 1, 2, 0, 3, 2};
+
if ( r_shadows->integer != 2 ) {
return;
}
@@ -276,18 +286,14 @@
qglLoadIdentity ();
- qglColor3f( 0.6f, 0.6f, 0.6f );
+ qglColor4f( 0.6f, 0.6f, 0.6f, 1.0f );
GL_State( GLS_DEPTHMASK_TRUE | GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO );
// qglColor3f( 1, 0, 0 );
// GL_State( GLS_DEPTHMASK_TRUE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO );
- qglBegin( GL_QUADS );
- qglVertex3f( -100, 100, -10 );
- qglVertex3f( 100, 100, -10 );
- qglVertex3f( 100, -100, -10 );
- qglVertex3f( -100, -100, -10 );
- qglEnd ();
+ qglVertexPointer ( 3, GL_FLOAT, 0, quad );
+ qglDrawElements ( GL_TRIANGLE_STRIP, 6, GL_INDEX_TYPE, indicies );
qglColor4f(1,1,1,1);
qglDisable( GL_STENCIL_TEST );
Index: code/renderer/tr_surface.c
===================================================================
--- code/renderer/tr_surface.c (revision 1305)
+++ code/renderer/tr_surface.c (working copy)
@@ -291,8 +291,8 @@
int i;
vec3_t perpvec;
vec3_t direction, normalized_direction;
- vec3_t start_points[NUM_BEAM_SEGS], end_points[NUM_BEAM_SEGS];
vec3_t oldorigin, origin;
+ vec3_t points[NUM_BEAM_SEGS*2];
e = &backEnd.currentEntity->e;
@@ -317,23 +317,19 @@
for ( i = 0; i < NUM_BEAM_SEGS ; i++ )
{
- RotatePointAroundVector( start_points[i], normalized_direction, perpvec, (360.0/NUM_BEAM_SEGS)*i );
+ RotatePointAroundVector( points[i*2], normalized_direction, perpvec, (360.0/NUM_BEAM_SEGS)*i );
// VectorAdd( start_points[i], origin, start_points[i] );
- VectorAdd( start_points[i], direction, end_points[i] );
+ VectorAdd( points[i*2], direction, points[i*2+1] );
}
GL_Bind( tr.whiteImage );
GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE );
- qglColor3f( 1, 0, 0 );
+ qglColor4f( 1.0f, 0.0f, 0.0f, 1.0f );
- qglBegin( GL_TRIANGLE_STRIP );
- for ( i = 0; i <= NUM_BEAM_SEGS; i++ ) {
- qglVertex3fv( start_points[ i % NUM_BEAM_SEGS] );
- qglVertex3fv( end_points[ i % NUM_BEAM_SEGS] );
- }
- qglEnd();
+ qglVertexPointer( 3, GL_FLOAT, 0, points );
+ qglDrawArrays( GL_TRIANGLE_STRIP, 0, NUM_BEAM_SEGS*2);
}
//================================================================================
@@ -905,7 +901,8 @@
*/
void RB_SurfaceFace( srfSurfaceFace_t *surf ) {
int i;
- unsigned *indices, *tessIndexes;
+ unsigned int *indices;
+ glIndex_t *tessIndexes;
float *v;
float *normal;
int ndx;
@@ -1161,19 +1158,21 @@
===================
*/
void RB_SurfaceAxis( void ) {
+ byte colors[3][4] = { {255,0,0,255},{0,255,0,255},{0,0,255,255}};
+ vec3_t verts[6] = {
+ {0.0f, 0.0f, 0.0f}, {16.0f, 0.0f, 0.0f},
+ {0.0f, 0.0f, 0.0f}, {0.0f, 16.0f, 0.0f},
+ {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 16.0f}
+ };
+ glIndex_t indicies[6] = {0, 1, 0, 2, 0, 3};
+
GL_Bind( tr.whiteImage );
qglLineWidth( 3 );
- qglBegin( GL_LINES );
- qglColor3f( 1,0,0 );
- qglVertex3f( 0,0,0 );
- qglVertex3f( 16,0,0 );
- qglColor3f( 0,1,0 );
- qglVertex3f( 0,0,0 );
- qglVertex3f( 0,16,0 );
- qglColor3f( 0,0,1 );
- qglVertex3f( 0,0,0 );
- qglVertex3f( 0,0,16 );
- qglEnd();
+ qglEnableClientState( GL_COLOR_ARRAY );
+ qglColorPointer( 4, GL_UNSIGNED_BYTE, 0, colors );
+ qglVertexPointer( 3, GL_FLOAT, 0, verts );
+
+ qglDrawElements( GL_LINES, 6, GL_INDEX_TYPE, indicies );
qglLineWidth( 1 );
}
Index: code/renderer/tr_sky.c
===================================================================
--- code/renderer/tr_sky.c (revision 1305)
+++ code/renderer/tr_sky.c (working copy)
@@ -363,25 +363,30 @@
static void DrawSkySide( struct image_s *image, const int mins[2], const int maxs[2] )
{
- int s, t;
+ int s, t, i=0;
+ int size;
+ glIndex_t *indicies;
+
+ size = (maxs[1]-mins[1]) * (maxs[0] - mins[0] + 1);
+ indicies = ri.Hunk_AllocateTempMemory( sizeof(glIndex_t) * size );
GL_Bind( image );
for ( t = mins[1]+HALF_SKY_SUBDIVISIONS; t < maxs[1]+HALF_SKY_SUBDIVISIONS; t++ )
{
- qglBegin( GL_TRIANGLE_STRIP );
-
for ( s = mins[0]+HALF_SKY_SUBDIVISIONS; s <= maxs[0]+HALF_SKY_SUBDIVISIONS; s++ )
{
- qglTexCoord2fv( s_skyTexCoords[t][s] );
- qglVertex3fv( s_skyPoints[t][s] );
-
- qglTexCoord2fv( s_skyTexCoords[t+1][s] );
- qglVertex3fv( s_skyPoints[t+1][s] );
+ indicies[i++] = t*(SKY_SUBDIVISIONS+1) + s;
+ indicies[i++] = (t+1)*(SKY_SUBDIVISIONS+1) + s;
}
-
- qglEnd();
}
+
+ qglDisableClientState( GL_COLOR_ARRAY);
+ qglEnableClientState( GL_TEXTURE_COORD_ARRAY);
+ qglTexCoordPointer( 2, GL_FLOAT, 0, s_skyTexCoords );
+ qglVertexPointer ( 3, GL_FLOAT, 0, s_skyPoints );
+ qglDrawElements( GL_TRIANGLE_STRIP, i, GL_INDEX_TYPE, indicies );
+ Hunk_FreeTempMemory(indicies);
}
static void DrawSkyBox( shader_t *shader )
@@ -816,7 +821,7 @@
// draw the outer skybox
if ( tess.shader->sky.outerbox[0] && tess.shader->sky.outerbox[0] != tr.defaultImage ) {
- qglColor3f( tr.identityLight, tr.identityLight, tr.identityLight );
+ qglColor4f( tr.identityLight, tr.identityLight, tr.identityLight, 1.0f );
qglPushMatrix ();
GL_State( 0 );
Index: code/renderer/tr_shade.c
===================================================================
--- code/renderer/tr_shade.c (revision 1305)
+++ code/renderer/tr_shade.c (working copy)
@@ -253,7 +253,7 @@
*/
static void DrawTris (shaderCommands_t *input) {
GL_Bind( tr.whiteImage );
- qglColor3f (1,1,1);
+ qglColor4f (1.0f,1.0f,1.0f,1.0f);
GL_State( GLS_POLYMODE_LINE | GLS_DEPTHMASK_TRUE );
qglDepthRange( 0, 0 );
@@ -288,19 +288,24 @@
static void DrawNormals (shaderCommands_t *input) {
int i;
vec3_t temp;
+ vec3_t verts[2*SHADER_MAX_VERTEXES];
+ glIndex_t indicies[2*SHADER_MAX_VERTEXES];
+ for (i = 0 ; i < input->numVertexes ; i++) {
+ VectorCopy(input->xyz[i], verts[i*2]);
+ VectorMA (input->xyz[i], 2, input->normal[i], temp);
+ VectorCopy(temp, verts[(i*2)+1]);
+ indicies[(i*2)] = i*2;
+ indicies[(i*2)+1] = (i*2)+1;
+ }
+
GL_Bind( tr.whiteImage );
- qglColor3f (1,1,1);
+ qglColor4f (1.0f,1.0f,1.0f,1.0f);
qglDepthRange( 0, 0 ); // never occluded
GL_State( GLS_POLYMODE_LINE | GLS_DEPTHMASK_TRUE );
- qglBegin (GL_LINES);
- for (i = 0 ; i < input->numVertexes ; i++) {
- qglVertex3fv (input->xyz[i]);
- VectorMA (input->xyz[i], 2, input->normal[i], temp);
- qglVertex3fv (temp);
- }
- qglEnd ();
+ qglVertexPointer(3, GL_FLOAT, 0, verts);
+ qglDrawElements( GL_LINES, i, GL_INDEX_TYPE, indicies );
qglDepthRange( 0, 1 );
}
@@ -421,7 +426,7 @@
byte clipBits[SHADER_MAX_VERTEXES];
float texCoordsArray[SHADER_MAX_VERTEXES][2];
byte colorArray[SHADER_MAX_VERTEXES][4];
- unsigned hitIndexes[SHADER_MAX_INDEXES];
+ glInext_t hitIndexes[SHADER_MAX_INDEXES];
int numIndexes;
float scale;
float radius;
@@ -574,7 +579,7 @@
byte clipBits[SHADER_MAX_VERTEXES];
float texCoordsArray[SHADER_MAX_VERTEXES][2];
byte colorArray[SHADER_MAX_VERTEXES][4];
- unsigned hitIndexes[SHADER_MAX_INDEXES];
+ glIndex_t hitIndexes[SHADER_MAX_INDEXES];
int numIndexes;
float scale;
float radius;
@@ -1114,6 +1119,10 @@
shaderCommands_t *input;
input = &tess;
+
+ // if ignoreglerrors is off, qglLockArraysEXT generates a GL error when you
+ // pass it 0 verts
+ if (input->numVertexes == 0 ) return;
RB_DeformTessGeometry();
Index: code/renderer/tr_backend.c
===================================================================
--- code/renderer/tr_backend.c (revision 1305)
+++ code/renderer/tr_backend.c (working copy)
@@ -488,7 +488,7 @@
// clip to the plane of the portal
if ( backEnd.viewParms.isPortal ) {
float plane[4];
- double plane2[4];
+ float plane2[4];
plane[0] = backEnd.viewParms.portalPlane.normal[0];
plane[1] = backEnd.viewParms.portalPlane.normal[1];
@@ -611,9 +611,9 @@
//
if ( oldDepthRange != depthRange ) {
if ( depthRange ) {
- qglDepthRange (0, 0.3);
+ qglDepthRange (0, 0.3f);
} else {
- qglDepthRange (0, 1);
+ qglDepthRange (0, 1.0f);
}
oldDepthRange = depthRange;
}
@@ -635,7 +635,7 @@
// go back to the world modelview matrix
qglLoadMatrixf( backEnd.viewParms.world.modelMatrix );
if ( depthRange ) {
- qglDepthRange (0, 1);
+ qglDepthRange (0, 1.0f);
}
#if 0
@@ -671,7 +671,7 @@
qglScissor( 0, 0, glConfig.vidWidth, glConfig.vidHeight );
qglMatrixMode(GL_PROJECTION);
qglLoadIdentity ();
- qglOrtho (0, glConfig.vidWidth, glConfig.vidHeight, 0, 0, 1);
+ qglOrtho (0.0f, glConfig.vidWidth, glConfig.vidHeight, 0.0f, 0.0f, 1.0f);
qglMatrixMode(GL_MODELVIEW);
qglLoadIdentity ();
@@ -700,6 +700,9 @@
void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty) {
int i, j;
int start, end;
+ vec2_t texcoords[4];
+ vec2_t verts[4];
+ glIndex_t indicies[6] = {0, 1, 2, 0, 3, 2};
if ( !tr.registered ) {
return;
@@ -729,7 +732,7 @@
if ( cols != tr.scratchImage[client]->width || rows != tr.scratchImage[client]->height ) {
tr.scratchImage[client]->width = tr.scratchImage[client]->uploadWidth = cols;
tr.scratchImage[client]->height = tr.scratchImage[client]->uploadHeight = rows;
- qglTexImage2D( GL_TEXTURE_2D, 0, GL_RGB8, cols, rows, 0, GL_RGBA, GL_UNSIGNED_BYTE, data );
+ qglTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, cols, rows, 0, GL_RGBA, GL_UNSIGNED_BYTE, data );
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
@@ -749,18 +752,23 @@
RB_SetGL2D();
- qglColor3f( tr.identityLight, tr.identityLight, tr.identityLight );
+ qglColor4f( tr.identityLight, tr.identityLight, tr.identityLight, 1.0f );
- qglBegin (GL_QUADS);
- qglTexCoord2f ( 0.5f / cols, 0.5f / rows );
- qglVertex2f (x, y);
- qglTexCoord2f ( ( cols - 0.5f ) / cols , 0.5f / rows );
- qglVertex2f (x+w, y);
- qglTexCoord2f ( ( cols - 0.5f ) / cols, ( rows - 0.5f ) / rows );
- qglVertex2f (x+w, y+h);
- qglTexCoord2f ( 0.5f / cols, ( rows - 0.5f ) / rows );
- qglVertex2f (x, y+h);
- qglEnd ();
+ verts[0][0] = x; verts[0][1] = y;
+ verts[1][0] = x+w; verts[1][1] = y;
+ verts[2][0] = x+w; verts[2][1] = y+h;
+ verts[3][0] = x; verts[3][1] = y+h;
+
+ texcoords[0][0] = 0.5f/cols; texcoords[0][1] = 0.5f/rows;
+ texcoords[1][0] = (cols-0.5f)/cols; texcoords[1][1] = 0.5f/rows;
+ texcoords[2][0] = (cols-0.5f)/cols; texcoords[2][1] = (rows-0.5f)/rows;
+ texcoords[3][0] = 0.5f/cols; texcoords[3][1] = (rows-0.5f)/rows;
+
+ qglEnableClientState( GL_TEXTURE_COORD_ARRAY );
+ qglTexCoordPointer( 2, GL_FLOAT, 0, texcoords );
+ qglVertexPointer ( 2, GL_FLOAT, 0, verts );
+ qglDrawElements( GL_TRIANGLE_STRIP, 6, GL_INDEX_TYPE, indicies );
+ qglDisableClientState( GL_TEXTURE_COORD_ARRAY );
}
void RE_UploadCinematic (int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty) {
@@ -771,7 +779,7 @@
if ( cols != tr.scratchImage[client]->width || rows != tr.scratchImage[client]->height ) {
tr.scratchImage[client]->width = tr.scratchImage[client]->uploadWidth = cols;
tr.scratchImage[client]->height = tr.scratchImage[client]->uploadHeight = rows;
- qglTexImage2D( GL_TEXTURE_2D, 0, GL_RGB8, cols, rows, 0, GL_RGBA, GL_UNSIGNED_BYTE, data );
+ qglTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, cols, rows, 0, GL_RGBA, GL_UNSIGNED_BYTE, data );
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
@@ -943,6 +951,9 @@
image_t *image;
float x, y, w, h;
int start, end;
+ vec2_t texcoords[4] = { {0.0f, 0.0f}, {1.0f, 0.0f}, {1.0f, 1.0f}, {0.0f, 1.0f} };
+ vec2_t verts[4];
+ glIndex_t indicies[6] = { 0, 1, 2, 0, 3, 2};
if ( !backEnd.projection2D ) {
RB_SetGL2D();
@@ -954,6 +965,8 @@
start = ri.Milliseconds();
+ qglEnableClientState( GL_TEXTURE_COORD_ARRAY );
+
for ( i=0 ; i<tr.numImages ; i++ ) {
image = tr.images[i];
@@ -968,19 +981,17 @@
h *= image->uploadHeight / 512.0f;
}
- GL_Bind( image );
- qglBegin (GL_QUADS);
- qglTexCoord2f( 0, 0 );
- qglVertex2f( x, y );
- qglTexCoord2f( 1, 0 );
- qglVertex2f( x + w, y );
- qglTexCoord2f( 1, 1 );
- qglVertex2f( x + w, y + h );
- qglTexCoord2f( 0, 1 );
- qglVertex2f( x, y + h );
- qglEnd();
+ verts[0][0] = x; verts[0][1] = y;
+ verts[1][0] = x+w; verts[1][1] = y;
+ verts[2][0] = x+w; verts[2][1] = y+h;
+ verts[3][0] = x; verts[3][1] = y+h;
+
+ qglTexCoordPointer( 2, GL_FLOAT, 0, texcoords );
+ qglVertexPointer ( 2, GL_FLOAT, 0, verts );
+ qglDrawElements( GL_TRIANGLE_STRIP, 6, GL_INDEX_TYPE, indicies );
}
+ qglDisableClientState( GL_TEXTURE_COORD_ARRAY );
qglFinish();
end = ri.Milliseconds();