Switch the refresher to vertex arrays

This is based on work submitted by Scott "pickle" Smith. It's said that
vertex arrays are somewhat faster and more compatible than the old way.
This may remove support of some very, very old GPUs like the Riva128.
This commit is contained in:
Yamagi Burmeister 2014-06-14 10:07:33 +02:00
parent 4dcdb0dc17
commit a70cc2d923
9 changed files with 639 additions and 308 deletions

View file

@ -59,6 +59,7 @@
#endif #endif
#ifndef GL_VERSION_1_3 #ifndef GL_VERSION_1_3
#define GL_TEXTURE0 0x84C0
#define GL_TEXTURE1 0x84C1 #define GL_TEXTURE1 0x84C1
#endif #endif

View file

@ -90,16 +90,29 @@ Draw_CharScaled(int x, int y, int num, float scale)
R_Bind(draw_chars->texnum); R_Bind(draw_chars->texnum);
glBegin(GL_QUADS); GLfloat vtx[] = {
glTexCoord2f(fcol, frow); x, y,
glVertex2f(x, y); x + scaledSize, y,
glTexCoord2f(fcol + size, frow); x + scaledSize, y + scaledSize,
glVertex2f(x + scaledSize, y); x, y + scaledSize
glTexCoord2f(fcol + size, frow + size); };
glVertex2f(x + scaledSize, y + scaledSize);
glTexCoord2f(fcol, frow + size); GLfloat tex[] = {
glVertex2f(x, y + scaledSize); fcol, frow,
glEnd(); fcol + size, frow,
fcol + size, frow + size,
fcol, frow + size
};
glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glVertexPointer( 2, GL_FLOAT, 0, vtx );
glTexCoordPointer( 2, GL_FLOAT, 0, tex );
glDrawArrays( GL_TRIANGLE_FAN, 0, 4 );
glDisableClientState( GL_VERTEX_ARRAY );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
} }
image_t * image_t *
@ -157,16 +170,30 @@ Draw_StretchPic(int x, int y, int w, int h, char *pic)
} }
R_Bind(gl->texnum); R_Bind(gl->texnum);
glBegin(GL_QUADS);
glTexCoord2f(gl->sl, gl->tl); GLfloat vtx[] = {
glVertex2f(x, y); x, y,
glTexCoord2f(gl->sh, gl->tl); x + w, y,
glVertex2f(x + w, y); x + w, y + h,
glTexCoord2f(gl->sh, gl->th); x, y + h
glVertex2f(x + w, y + h); };
glTexCoord2f(gl->sl, gl->th);
glVertex2f(x, y + h); GLfloat tex[] = {
glEnd(); gl->sl, gl->tl,
gl->sh, gl->tl,
gl->sh, gl->th,
gl->sl, gl->th
};
glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glVertexPointer( 2, GL_FLOAT, 0, vtx );
glTexCoordPointer( 2, GL_FLOAT, 0, tex );
glDrawArrays( GL_TRIANGLE_FAN, 0, 4 );
glDisableClientState( GL_VERTEX_ARRAY );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
} }
void void
@ -193,20 +220,31 @@ Draw_PicScaled(int x, int y, char *pic, float factor)
Scrap_Upload(); Scrap_Upload();
} }
GLfloat w = gl->width*factor;
GLfloat h = gl->height*factor;
R_Bind(gl->texnum); R_Bind(gl->texnum);
glBegin(GL_QUADS);
glTexCoord2f(gl->sl, gl->tl); GLfloat vtx[] = {
glVertex2f(x, y); x, y,
glTexCoord2f(gl->sh, gl->tl); x + gl->width * factor, y,
glVertex2f(x + w, y); x + gl->width * factor, y + gl->height * factor,
glTexCoord2f(gl->sh, gl->th); x, y + gl->height * factor
glVertex2f(x + w, y + h); };
glTexCoord2f(gl->sl, gl->th);
glVertex2f(x, y + h); GLfloat tex[] = {
glEnd(); gl->sl, gl->tl,
gl->sh, gl->tl,
gl->sh, gl->th,
gl->sl, gl->th
};
glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glVertexPointer( 2, GL_FLOAT, 0, vtx );
glTexCoordPointer( 2, GL_FLOAT, 0, tex );
glDrawArrays( GL_TRIANGLE_FAN, 0, 4 );
glDisableClientState( GL_VERTEX_ARRAY );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
} }
/* /*
@ -228,16 +266,30 @@ Draw_TileClear(int x, int y, int w, int h, char *pic)
} }
R_Bind(image->texnum); R_Bind(image->texnum);
glBegin(GL_QUADS);
glTexCoord2f(x / 64.0, y / 64.0); GLfloat vtx[] = {
glVertex2f(x, y); x, y,
glTexCoord2f((x + w) / 64.0, y / 64.0); x + w, y,
glVertex2f(x + w, y); x + w, y + h,
glTexCoord2f((x + w) / 64.0, (y + h) / 64.0); x, y + h
glVertex2f(x + w, y + h); };
glTexCoord2f(x / 64.0, (y + h) / 64.0);
glVertex2f(x, y + h); GLfloat tex[] = {
glEnd(); x / 64.0, y / 64.0,
( x + w ) / 64.0, y / 64.0,
( x + w ) / 64.0, ( y + h ) / 64.0,
x / 64.0, ( y + h ) / 64.0
};
glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glVertexPointer( 2, GL_FLOAT, 0, vtx );
glTexCoordPointer( 2, GL_FLOAT, 0, tex );
glDrawArrays( GL_TRIANGLE_FAN, 0, 4 );
glDisableClientState( GL_VERTEX_ARRAY );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
} }
/* /*
@ -260,17 +312,24 @@ Draw_Fill(int x, int y, int w, int h, int c)
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
color.c = d_8to24table[c]; color.c = d_8to24table[c];
glColor4f(color.v[0] / 255.0, color.v[1] / 255.0, color.v[2] / 255.0, 1); glColor4f(color.v [ 0 ] / 255.0, color.v [ 1 ] / 255.0,
color.v [ 2 ] / 255.0, 1);
glBegin(GL_QUADS); GLfloat vtx[] = {
x, y,
x + w, y,
x + w, y + h,
x, y + h
};
glVertex2f(x, y); glEnableClientState( GL_VERTEX_ARRAY );
glVertex2f(x + w, y);
glVertex2f(x + w, y + h);
glVertex2f(x, y + h);
glEnd(); glVertexPointer( 2, GL_FLOAT, 0, vtx );
glColor4f(1, 1, 1, 1); glDrawArrays( GL_TRIANGLE_FAN, 0, 4 );
glDisableClientState( GL_VERTEX_ARRAY );
glColor4f( 1, 1, 1, 1 );
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
} }
@ -280,14 +339,21 @@ Draw_FadeScreen(void)
glEnable(GL_BLEND); glEnable(GL_BLEND);
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
glColor4f(0, 0, 0, 0.8); glColor4f(0, 0, 0, 0.8);
glBegin(GL_QUADS);
glVertex2f(0, 0); GLfloat vtx[] = {
glVertex2f(vid.width, 0); 0, 0,
glVertex2f(vid.width, vid.height); vid.width, 0,
glVertex2f(0, vid.height); vid.width, vid.height,
0, vid.height
};
glEnableClientState( GL_VERTEX_ARRAY );
glVertexPointer( 2, GL_FLOAT, 0, vtx );
glDrawArrays( GL_TRIANGLE_FAN, 0, 4 );
glDisableClientState( GL_VERTEX_ARRAY );
glEnd();
glColor4f(1, 1, 1, 1); glColor4f(1, 1, 1, 1);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glDisable(GL_BLEND); glDisable(GL_BLEND);
@ -374,29 +440,36 @@ Draw_StretchRaw(int x, int y, int w, int h, int cols, int rows, byte *data)
} }
} }
glTexImage2D(GL_TEXTURE_2D, glTexImage2D(GL_TEXTURE_2D, 0, GL_COLOR_INDEX8_EXT, 256, 256,
0, 0, GL_COLOR_INDEX, GL_UNSIGNED_BYTE, image8);
GL_COLOR_INDEX8_EXT,
256, 256,
0,
GL_COLOR_INDEX,
GL_UNSIGNED_BYTE,
image8);
} }
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glBegin(GL_QUADS); GLfloat vtx[] = {
glTexCoord2f(1.0 / 512.0, 1.0 / 512.0); x, y,
glVertex2f(x, y); x + w, y,
glTexCoord2f(511.0 / 512.0, 1.0 / 512.0); x + w, y + h,
glVertex2f(x + w, y); x, y + h
glTexCoord2f(511.0 / 512.0, t); };
glVertex2f(x + w, y + h);
glTexCoord2f(1.0 / 512.0, t); GLfloat tex[] = {
glVertex2f(x, y + h); 1.0 / 512.0, 1.0 / 512.0,
glEnd(); 511.0 / 512.0, 1.0 / 512.0,
511.0 / 512.0, t,
1.0 / 512.0, t
};
glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glVertexPointer( 2, GL_FLOAT, 0, vtx );
glTexCoordPointer( 2, GL_FLOAT, 0, tex );
glDrawArrays( GL_TRIANGLE_FAN, 0, 4 );
glDisableClientState( GL_VERTEX_ARRAY );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
} }
int int

View file

@ -95,9 +95,6 @@ gltmode_t gl_solid_modes[] = {
{"GL_RGB5", GL_RGB5}, {"GL_RGB5", GL_RGB5},
{"GL_RGB4", GL_RGB4}, {"GL_RGB4", GL_RGB4},
{"GL_R3_G3_B2", GL_R3_G3_B2}, {"GL_R3_G3_B2", GL_R3_G3_B2},
#ifdef GL_RGB2_EXT
{"GL_RGB2", GL_RGB2_EXT},
#endif
}; };
#define NUM_GL_SOLID_MODES (sizeof(gl_solid_modes) / sizeof(gltmode_t)) #define NUM_GL_SOLID_MODES (sizeof(gl_solid_modes) / sizeof(gltmode_t))

View file

@ -39,39 +39,51 @@ R_RenderDlight(dlight_t *light)
{ {
int i, j; int i, j;
float a; float a;
vec3_t v;
float rad; float rad;
rad = light->intensity * 0.35; rad = light->intensity * 0.35;
VectorSubtract(light->origin, r_origin, v); GLfloat vtx[3*18];
GLfloat clr[4*18];
glBegin(GL_TRIANGLE_FAN); unsigned int index_vtx = 4;
glColor4f(light->color[0] * 0.2, light->color[1] * 0.2, unsigned int index_clr = 0;
light->color[2] * 0.2, 1);
for (i = 0; i < 3; i++) glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_COLOR_ARRAY );
clr[index_clr++] = light->color [ 0 ] * 0.2;
clr[index_clr++] = light->color [ 1 ] * 0.2;
clr[index_clr++] = light->color [ 2 ] * 0.2;
clr[index_clr++] = 1;
for ( i = 0; i < 3; i++ )
{ {
v[i] = light->origin[i] - vpn[i] * rad; vtx [ i ] = light->origin [ i ] - vpn [ i ] * rad;
} }
glVertex3fv(v); for ( i = 16; i >= 0; i-- )
glColor4f(0, 0, 0, 1);
for (i = 16; i >= 0; i--)
{ {
clr[index_clr++] = 0;
clr[index_clr++] = 0;
clr[index_clr++] = 0;
clr[index_clr++] = 1;
a = i / 16.0 * M_PI * 2; a = i / 16.0 * M_PI * 2;
for (j = 0; j < 3; j++) for ( j = 0; j < 3; j++ )
{ {
v[j] = light->origin[j] + vright[j] * cos(a) * rad vtx[index_vtx++] = light->origin [ j ] + vright [ j ] * cos( a ) * rad
+ vup[j] * sin(a) * rad; + vup [ j ] * sin( a ) * rad;
} }
glVertex3fv(v);
} }
glEnd(); glVertexPointer( 3, GL_FLOAT, 0, vtx );
glColorPointer( 4, GL_FLOAT, 0, clr );
glDrawArrays( GL_TRIANGLE_FAN, 0, 18 );
glDisableClientState( GL_VERTEX_ARRAY );
glDisableClientState( GL_COLOR_ARRAY );
} }
void void

View file

@ -185,7 +185,7 @@ void
R_DrawSpriteModel(entity_t *e) R_DrawSpriteModel(entity_t *e)
{ {
float alpha = 1.0F; float alpha = 1.0F;
vec3_t point; vec3_t point[4];
dsprframe_t *frame; dsprframe_t *frame;
float *up, *right; float *up, *right;
dsprite_t *psprite; dsprite_t *psprite;
@ -226,29 +226,34 @@ R_DrawSpriteModel(entity_t *e)
glDisable(GL_ALPHA_TEST); glDisable(GL_ALPHA_TEST);
} }
glBegin(GL_QUADS); GLfloat tex[] = {
0, 1,
0, 0,
1, 0,
1, 1
};
glTexCoord2f(0, 1); VectorMA( e->origin, -frame->origin_y, up, point[0] );
VectorMA(e->origin, -frame->origin_y, up, point); VectorMA( point[0], -frame->origin_x, right, point[0] );
VectorMA(point, -frame->origin_x, right, point);
glVertex3fv(point);
glTexCoord2f(0, 0); VectorMA( e->origin, frame->height - frame->origin_y, up, point[1] );
VectorMA(e->origin, frame->height - frame->origin_y, up, point); VectorMA( point[1], -frame->origin_x, right, point[1] );
VectorMA(point, -frame->origin_x, right, point);
glVertex3fv(point);
glTexCoord2f(1, 0); VectorMA( e->origin, frame->height - frame->origin_y, up, point[2] );
VectorMA(e->origin, frame->height - frame->origin_y, up, point); VectorMA( point[2], frame->width - frame->origin_x, right, point[2] );
VectorMA(point, frame->width - frame->origin_x, right, point);
glVertex3fv(point);
glTexCoord2f(1, 1); VectorMA( e->origin, -frame->origin_y, up, point[3] );
VectorMA(e->origin, -frame->origin_y, up, point); VectorMA( point[3], frame->width - frame->origin_x, right, point[3] );
VectorMA(point, frame->width - frame->origin_x, right, point);
glVertex3fv(point);
glEnd(); glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glVertexPointer( 3, GL_FLOAT, 0, point );
glTexCoordPointer( 2, GL_FLOAT, 0, tex );
glDrawArrays( GL_TRIANGLE_FAN, 0, 4 );
glDisableClientState( GL_VERTEX_ARRAY );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
glDisable(GL_ALPHA_TEST); glDisable(GL_ALPHA_TEST);
R_TexEnv(GL_REPLACE); R_TexEnv(GL_REPLACE);
@ -265,7 +270,6 @@ void
R_DrawNullModel(void) R_DrawNullModel(void)
{ {
vec3_t shadelight; vec3_t shadelight;
int i;
if (currententity->flags & RF_FULLBRIGHT) if (currententity->flags & RF_FULLBRIGHT)
{ {
@ -282,25 +286,37 @@ R_DrawNullModel(void)
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
glColor4f( shadelight[0], shadelight[1], shadelight[2], 1 ); glColor4f( shadelight[0], shadelight[1], shadelight[2], 1 );
glBegin(GL_TRIANGLE_FAN); GLfloat vtxA[] = {
glVertex3f(0, 0, -16); 0, 0, -16,
16 * cos( 0 * M_PI / 2 ), 16 * sin( 0 * M_PI / 2 ), 0,
16 * cos( 1 * M_PI / 2 ), 16 * sin( 1 * M_PI / 2 ), 0,
16 * cos( 2 * M_PI / 2 ), 16 * sin( 2 * M_PI / 2 ), 0,
16 * cos( 3 * M_PI / 2 ), 16 * sin( 3 * M_PI / 2 ), 0,
16 * cos( 4 * M_PI / 2 ), 16 * sin( 4 * M_PI / 2 ), 0
};
for (i = 0; i <= 4; i++) glEnableClientState( GL_VERTEX_ARRAY );
{
glVertex3f(16 * cos(i * M_PI / 2), 16 * sin(i * M_PI / 2), 0);
}
glEnd(); glVertexPointer( 3, GL_FLOAT, 0, vtxA );
glDrawArrays( GL_TRIANGLE_FAN, 0, 6 );
glBegin(GL_TRIANGLE_FAN); glDisableClientState( GL_VERTEX_ARRAY );
glVertex3f(0, 0, 16);
for (i = 4; i >= 0; i--) GLfloat vtxB[] = {
{ 0, 0, 16,
glVertex3f(16 * cos(i * M_PI / 2), 16 * sin(i * M_PI / 2), 0); 16 * cos( 4 * M_PI / 2 ), 16 * sin( 4 * M_PI / 2 ), 0,
} 16 * cos( 3 * M_PI / 2 ), 16 * sin( 3 * M_PI / 2 ), 0,
16 * cos( 2 * M_PI / 2 ), 16 * sin( 2 * M_PI / 2 ), 0,
16 * cos( 1 * M_PI / 2 ), 16 * sin( 1 * M_PI / 2 ), 0,
16 * cos( 0 * M_PI / 2 ), 16 * sin( 0 * M_PI / 2 ), 0
};
glEnd(); glEnableClientState( GL_VERTEX_ARRAY );
glVertexPointer( 3, GL_FLOAT, 0, vtxB );
glDrawArrays( GL_TRIANGLE_FAN, 0, 6 );
glDisableClientState( GL_VERTEX_ARRAY );
glColor4f(1, 1, 1, 1); glColor4f(1, 1, 1, 1);
glPopMatrix(); glPopMatrix();
@ -417,24 +433,31 @@ R_DrawParticles2(int num_particles, const particle_t particles[],
vec3_t up, right; vec3_t up, right;
float scale; float scale;
byte color[4]; byte color[4];
GLfloat vtx[3*num_particles*3];
GLfloat tex[2*num_particles*3];
GLfloat clr[4*num_particles*3];
unsigned int index_vtx = 0;
unsigned int index_tex = 0;
unsigned int index_clr = 0;
unsigned int j;
R_Bind(r_particletexture->texnum); R_Bind(r_particletexture->texnum);
glDepthMask(GL_FALSE); /* no z buffering */ glDepthMask(GL_FALSE); /* no z buffering */
glEnable(GL_BLEND); glEnable(GL_BLEND);
R_TexEnv(GL_MODULATE); R_TexEnv(GL_MODULATE);
glBegin(GL_TRIANGLES);
VectorScale(vup, 1.5, up); VectorScale( vup, 1.5, up );
VectorScale(vright, 1.5, right); VectorScale( vright, 1.5, right );
for (p = particles, i = 0; i < num_particles; i++, p++) for ( p = particles, i = 0; i < num_particles; i++, p++ )
{ {
/* hack a scale up to keep particles from disapearing */ /* hack a scale up to keep particles from disapearing */
scale = (p->origin[0] - r_origin[0]) * vpn[0] + scale = ( p->origin [ 0 ] - r_origin [ 0 ] ) * vpn [ 0 ] +
(p->origin[1] - r_origin[1]) * vpn[1] + ( p->origin [ 1 ] - r_origin [ 1 ] ) * vpn [ 1 ] +
(p->origin[2] - r_origin[2]) * vpn[2]; ( p->origin [ 2 ] - r_origin [ 2 ] ) * vpn [ 2 ];
if (scale < 20) if ( scale < 20 )
{ {
scale = 1; scale = 1;
} }
@ -443,26 +466,54 @@ R_DrawParticles2(int num_particles, const particle_t particles[],
scale = 1 + scale * 0.004; scale = 1 + scale * 0.004;
} }
*(int *)color = colortable[p->color]; *(int *) color = colortable [ p->color ];
color[3] = p->alpha * 255;
glColor4ubv(color); for (j=0; j<3; j++) // Copy the color for each point
{
clr[index_clr++] = color[0]/255.0f;
clr[index_clr++] = color[1]/255.0f;
clr[index_clr++] = color[2]/255.0f;
clr[index_clr++] = p->alpha;
}
glTexCoord2f(0.0625, 0.0625); // point 0
glVertex3fv(p->origin); tex[index_tex++] = 0.0625f;
tex[index_tex++] = 0.0625f;
glTexCoord2f(1.0625, 0.0625); vtx[index_vtx++] = p->origin[0];
glVertex3f(p->origin[0] + up[0] * scale, vtx[index_vtx++] = p->origin[1];
p->origin[1] + up[1] * scale, vtx[index_vtx++] = p->origin[2];
p->origin[2] + up[2] * scale);
glTexCoord2f(0.0625, 1.0625); // point 1
glVertex3f(p->origin[0] + right[0] * scale, tex[index_tex++] = 1.0625f;
p->origin[1] + right[1] * scale, tex[index_tex++] = 0.0625f;
p->origin[2] + right[2] * scale);
vtx[index_vtx++] = p->origin [ 0 ] + up [ 0 ] * scale;
vtx[index_vtx++] = p->origin [ 1 ] + up [ 1 ] * scale;
vtx[index_vtx++] = p->origin [ 2 ] + up [ 2 ] * scale;
// point 2
tex[index_tex++] = 0.0625f;
tex[index_tex++] = 1.0625f;
vtx[index_vtx++] = p->origin [ 0 ] + right [ 0 ] * scale;
vtx[index_vtx++] = p->origin [ 1 ] + right [ 1 ] * scale;
vtx[index_vtx++] = p->origin [ 2 ] + right [ 2 ] * scale;
} }
glEnd(); glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glEnableClientState( GL_COLOR_ARRAY );
glVertexPointer( 3, GL_FLOAT, 0, vtx );
glTexCoordPointer( 2, GL_FLOAT, 0, tex );
glColorPointer( 4, GL_FLOAT, 0, clr );
glDrawArrays( GL_TRIANGLES, 0, num_particles*3 );
glDisableClientState( GL_VERTEX_ARRAY );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
glDisableClientState( GL_COLOR_ARRAY );
glDisable(GL_BLEND); glDisable(GL_BLEND);
glColor4f(1, 1, 1, 1); glColor4f(1, 1, 1, 1);
glDepthMask(1); /* back to normal Z buffering */ glDepthMask(1); /* back to normal Z buffering */
@ -480,29 +531,43 @@ R_DrawParticles(void)
int i; int i;
unsigned char color[4]; unsigned char color[4];
const particle_t *p; const particle_t *p;
GLfloat vtx[3*r_newrefdef.num_particles];
GLfloat clr[4*r_newrefdef.num_particles];
unsigned int index_vtx = 0;
unsigned int index_clr = 0;
glDepthMask(GL_FALSE); glDepthMask(GL_FALSE);
glEnable(GL_BLEND); glEnable(GL_BLEND);
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
glPointSize(LittleFloat(gl_particle_size->value)); glPointSize(LittleFloat(gl_particle_size->value));
glBegin(GL_POINTS); for ( i = 0, p = r_newrefdef.particles; i < r_newrefdef.num_particles; i++, p++ )
for (i = 0, p = r_newrefdef.particles;
i < r_newrefdef.num_particles;
i++, p++)
{ {
*(int *)color = d_8to24table[p->color & 0xFF]; *(int *) color = d_8to24table [ p->color & 0xFF ];
color[3] = p->alpha * 255; clr[index_clr++] = color[0]/255.0f;
glColor4ubv(color); clr[index_clr++] = color[1]/255.0f;
glVertex3fv(p->origin); clr[index_clr++] = color[2]/255.0f;
clr[index_clr++] = p->alpha;
vtx[index_vtx++] = p->origin[0];
vtx[index_vtx++] = p->origin[1];
vtx[index_vtx++] = p->origin[2];
} }
glEnd(); glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_COLOR_ARRAY );
glVertexPointer( 3, GL_FLOAT, 0, vtx );
glColorPointer( 4, GL_FLOAT, 0, clr );
glDrawArrays( GL_POINTS, 0, r_newrefdef.num_particles );
glDisableClientState( GL_VERTEX_ARRAY );
glDisableClientState( GL_COLOR_ARRAY );
glDisable(GL_BLEND); glDisable(GL_BLEND);
glColor4f(1.0F, 1.0F, 1.0F, 1.0F); glColor4f( 1, 1, 1, 1 );
glDepthMask(GL_TRUE); glDepthMask(GL_TRUE);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
} }
@ -536,15 +601,21 @@ R_PolyBlend(void)
glRotatef(-90, 1, 0, 0); /* put Z going up */ glRotatef(-90, 1, 0, 0); /* put Z going up */
glRotatef(90, 0, 0, 1); /* put Z going up */ glRotatef(90, 0, 0, 1); /* put Z going up */
glColor4f(v_blend[0], v_blend[1], v_blend[2], v_blend[3]); glColor4f( v_blend[0], v_blend[1], v_blend[2], v_blend[3] );
glBegin(GL_QUADS); GLfloat vtx[] = {
10, 100, 100,
10, -100, 100,
10, -100, -100,
10, 100, -100
};
glVertex3f(10, 100, 100); glEnableClientState( GL_VERTEX_ARRAY );
glVertex3f(10, -100, 100);
glVertex3f(10, -100, -100); glVertexPointer( 3, GL_FLOAT, 0, vtx );
glVertex3f(10, 100, -100); glDrawArrays( GL_TRIANGLE_FAN, 0, 4 );
glEnd();
glDisableClientState( GL_VERTEX_ARRAY );
glDisable(GL_BLEND); glDisable(GL_BLEND);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
@ -1182,7 +1253,6 @@ R_Register(void)
gl_anisotropic = Cvar_Get("gl_anisotropic", "0", CVAR_ARCHIVE); gl_anisotropic = Cvar_Get("gl_anisotropic", "0", CVAR_ARCHIVE);
gl_anisotropic_avail = Cvar_Get("gl_anisotropic_avail", "0", 0); gl_anisotropic_avail = Cvar_Get("gl_anisotropic_avail", "0", 0);
gl_lockpvs = Cvar_Get("gl_lockpvs", "0", 0); gl_lockpvs = Cvar_Get("gl_lockpvs", "0", 0);
gl_vertex_arrays = Cvar_Get("gl_vertex_arrays", "0", CVAR_ARCHIVE); gl_vertex_arrays = Cvar_Get("gl_vertex_arrays", "0", CVAR_ARCHIVE);
gl_ext_swapinterval = Cvar_Get("gl_ext_swapinterval", "1", CVAR_ARCHIVE); gl_ext_swapinterval = Cvar_Get("gl_ext_swapinterval", "1", CVAR_ARCHIVE);
@ -1686,7 +1756,11 @@ R_DrawBeam(entity_t *e)
vec3_t direction, normalized_direction; vec3_t direction, normalized_direction;
vec3_t start_points[NUM_BEAM_SEGS], end_points[NUM_BEAM_SEGS]; vec3_t start_points[NUM_BEAM_SEGS], end_points[NUM_BEAM_SEGS];
vec3_t oldorigin, origin; vec3_t oldorigin, origin;
GLfloat vtx[3*NUM_BEAM_SEGS*4];
unsigned int index_vtx = 0;
unsigned int pointb;
oldorigin[0] = e->oldorigin[0]; oldorigin[0] = e->oldorigin[0];
oldorigin[1] = e->oldorigin[1]; oldorigin[1] = e->oldorigin[1];
oldorigin[2] = e->oldorigin[2]; oldorigin[2] = e->oldorigin[2];
@ -1729,27 +1803,35 @@ R_DrawBeam(entity_t *e)
glColor4f(r, g, b, e->alpha); glColor4f(r, g, b, e->alpha);
glBegin(GL_TRIANGLE_STRIP); for ( i = 0; i < NUM_BEAM_SEGS; i++ )
for (i = 0; i < NUM_BEAM_SEGS; i++)
{ {
glVertex3fv(start_points[i]); vtx[index_vtx++] = start_points [ i ][ 0 ];
glVertex3fv(end_points[i]); vtx[index_vtx++] = start_points [ i ][ 1 ];
glVertex3fv(start_points[(i + 1) % NUM_BEAM_SEGS]); vtx[index_vtx++] = start_points [ i ][ 2 ];
glVertex3fv(end_points[(i + 1) % NUM_BEAM_SEGS]);
vtx[index_vtx++] = end_points [ i ][ 0 ];
vtx[index_vtx++] = end_points [ i ][ 1 ];
vtx[index_vtx++] = end_points [ i ][ 2 ];
pointb = ( i + 1 ) % NUM_BEAM_SEGS;
vtx[index_vtx++] = start_points [ pointb ][ 0 ];
vtx[index_vtx++] = start_points [ pointb ][ 1 ];
vtx[index_vtx++] = start_points [ pointb ][ 2 ];
vtx[index_vtx++] = end_points [ pointb ][ 0 ];
vtx[index_vtx++] = end_points [ pointb ][ 1 ];
vtx[index_vtx++] = end_points [ pointb ][ 2 ];
} }
glEnd(); glEnableClientState( GL_VERTEX_ARRAY );
glVertexPointer( 3, GL_FLOAT, 0, vtx );
glDrawArrays( GL_TRIANGLE_STRIP, 0, NUM_BEAM_SEGS*4 );
glDisableClientState( GL_VERTEX_ARRAY );
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glDisable(GL_BLEND); glDisable(GL_BLEND);
glDepthMask(GL_TRUE); glDepthMask(GL_TRUE);
} }
/*void
R_GetRefAPI(void)
{
Swap_Init();
}*/

View file

@ -87,6 +87,8 @@ R_LerpVerts(int nverts, dtrivertx_t *v, dtrivertx_t *ov,
void void
R_DrawAliasFrameLerp(dmdl_t *paliashdr, float backlerp) R_DrawAliasFrameLerp(dmdl_t *paliashdr, float backlerp)
{ {
unsigned short total;
GLenum type;
float l; float l;
daliasframe_t *frame, *oldframe; daliasframe_t *frame, *oldframe;
dtrivertx_t *v, *ov, *verts; dtrivertx_t *v, *ov, *verts;
@ -182,11 +184,6 @@ R_DrawAliasFrameLerp(dmdl_t *paliashdr, float backlerp)
} }
} }
if (qglLockArraysEXT != 0)
{
qglLockArraysEXT(0, paliashdr->num_xyz);
}
while (1) while (1)
{ {
/* get the vertex count and primitive type */ /* get the vertex count and primitive type */
@ -200,13 +197,20 @@ R_DrawAliasFrameLerp(dmdl_t *paliashdr, float backlerp)
if (count < 0) if (count < 0)
{ {
count = -count; count = -count;
glBegin(GL_TRIANGLE_FAN);
type = GL_TRIANGLE_FAN;
} }
else else
{ {
glBegin(GL_TRIANGLE_STRIP); type = GL_TRIANGLE_STRIP;
} }
total = count;
GLfloat vtx[3*total];
GLfloat tex[2*total];
unsigned int index_vtx = 0;
unsigned int index_tex = 0;
if (currententity->flags & if (currententity->flags &
(RF_SHELL_RED | RF_SHELL_GREEN | RF_SHELL_BLUE | (RF_SHELL_RED | RF_SHELL_GREEN | RF_SHELL_BLUE |
RF_SHELL_DOUBLE | RF_SHELL_DOUBLE |
@ -217,7 +221,9 @@ R_DrawAliasFrameLerp(dmdl_t *paliashdr, float backlerp)
index_xyz = order[2]; index_xyz = order[2];
order += 3; order += 3;
glVertex3fv(s_lerped[index_xyz]); vtx[index_vtx++] = s_lerped [ index_xyz ][0];
vtx[index_vtx++] = s_lerped [ index_xyz ][1];
vtx[index_vtx++] = s_lerped [ index_xyz ][2];
} }
while (--count); while (--count);
} }
@ -225,23 +231,21 @@ R_DrawAliasFrameLerp(dmdl_t *paliashdr, float backlerp)
{ {
do do
{ {
/* texture coordinates come from the draw list */ tex[index_tex++] = ( (float *) order ) [ 0 ];
glTexCoord2f(((float *)order)[0], ((float *)order)[1]); tex[index_tex++] = ( (float *) order ) [ 1 ];
index_xyz = order[2]; index_xyz = order [ 2 ];
order += 3; order += 3;
glArrayElement(index_xyz);
} }
while (--count); while (--count);
} }
glEnd(); glEnableClientState( GL_VERTEX_ARRAY );
}
if (qglUnlockArraysEXT != 0) glVertexPointer( 3, GL_FLOAT, 0, vtx );
{ glDrawArrays( type, 0, total );
qglUnlockArraysEXT();
glDisableClientState( GL_VERTEX_ARRAY );
} }
} }
else else
@ -259,13 +263,22 @@ R_DrawAliasFrameLerp(dmdl_t *paliashdr, float backlerp)
if (count < 0) if (count < 0)
{ {
count = -count; count = -count;
glBegin(GL_TRIANGLE_FAN);
type = GL_TRIANGLE_FAN;
} }
else else
{ {
glBegin(GL_TRIANGLE_STRIP); type = GL_TRIANGLE_STRIP;
} }
total = count;
GLfloat vtx[3*total];
GLfloat tex[2*total];
GLfloat clr[4*total];
unsigned int index_vtx = 0;
unsigned int index_tex = 0;
unsigned int index_clr = 0;
if (currententity->flags & if (currententity->flags &
(RF_SHELL_RED | RF_SHELL_GREEN | RF_SHELL_BLUE)) (RF_SHELL_RED | RF_SHELL_GREEN | RF_SHELL_BLUE))
{ {
@ -274,9 +287,14 @@ R_DrawAliasFrameLerp(dmdl_t *paliashdr, float backlerp)
index_xyz = order[2]; index_xyz = order[2];
order += 3; order += 3;
glColor4f(shadelight[0], shadelight[1], clr[index_clr++] = shadelight [ 0 ];
shadelight[2], alpha); clr[index_clr++] = shadelight [ 1 ];
glVertex3fv(s_lerped[index_xyz]); clr[index_clr++] = shadelight [ 2 ];
clr[index_clr++] = alpha;
vtx[index_vtx++] = s_lerped [ index_xyz ][ 0 ];
vtx[index_vtx++] = s_lerped [ index_xyz ][ 1 ];
vtx[index_vtx++] = s_lerped [ index_xyz ][ 2 ];
} }
while (--count); while (--count);
} }
@ -285,21 +303,39 @@ R_DrawAliasFrameLerp(dmdl_t *paliashdr, float backlerp)
do do
{ {
/* texture coordinates come from the draw list */ /* texture coordinates come from the draw list */
glTexCoord2f(((float *)order)[0], ((float *)order)[1]); tex[index_tex++] = ( (float *) order ) [ 0 ];
tex[index_tex++] = ( (float *) order ) [ 1 ];
index_xyz = order[2]; index_xyz = order[2];
order += 3; order += 3;
/* normals and vertexes come from the frame list */ /* normals and vertexes come from the frame list */
l = shadedots[verts[index_xyz].lightnormalindex]; l = shadedots[verts[index_xyz].lightnormalindex];
glColor4f(l * shadelight[0], l * shadelight[1], clr[index_clr++] = l * shadelight [ 0 ];
l * shadelight[2], alpha); clr[index_clr++] = l * shadelight [ 1 ];
glVertex3fv(s_lerped[index_xyz]); clr[index_clr++] = l * shadelight [ 2 ];
clr[index_clr++] = alpha;
vtx[index_vtx++] = s_lerped [ index_xyz ][ 0 ];
vtx[index_vtx++] = s_lerped [ index_xyz ][ 1 ];
vtx[index_vtx++] = s_lerped [ index_xyz ][ 2 ];
} }
while (--count); while (--count);
} }
glEnd(); glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glEnableClientState( GL_COLOR_ARRAY );
glVertexPointer( 3, GL_FLOAT, 0, vtx );
glTexCoordPointer( 2, GL_FLOAT, 0, tex );
glColorPointer( 4, GL_FLOAT, 0, clr );
glDrawArrays( type, 0, total );
glDisableClientState( GL_VERTEX_ARRAY );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
glDisableClientState( GL_COLOR_ARRAY );
} }
} }
@ -314,6 +350,8 @@ R_DrawAliasFrameLerp(dmdl_t *paliashdr, float backlerp)
void void
R_DrawAliasShadow(dmdl_t *paliashdr, int posenum) R_DrawAliasShadow(dmdl_t *paliashdr, int posenum)
{ {
unsigned short total;
GLenum type;
int *order; int *order;
vec3_t point; vec3_t point;
float height = 0, lheight; float height = 0, lheight;
@ -344,13 +382,18 @@ R_DrawAliasShadow(dmdl_t *paliashdr, int posenum)
if (count < 0) if (count < 0)
{ {
count = -count; count = -count;
glBegin(GL_TRIANGLE_FAN);
type = GL_TRIANGLE_FAN;
} }
else else
{ {
glBegin(GL_TRIANGLE_STRIP); type = GL_TRIANGLE_STRIP;
} }
total = count;
GLfloat vtx[3*total];
unsigned int index_vtx = 0;
do do
{ {
/* normals and vertexes come from the frame list */ /* normals and vertexes come from the frame list */
@ -359,13 +402,21 @@ R_DrawAliasShadow(dmdl_t *paliashdr, int posenum)
point[0] -= shadevector[0] * (point[2] + lheight); point[0] -= shadevector[0] * (point[2] + lheight);
point[1] -= shadevector[1] * (point[2] + lheight); point[1] -= shadevector[1] * (point[2] + lheight);
point[2] = height; point[2] = height;
glVertex3fv(point);
vtx[index_vtx++] = point [ 0 ];
vtx[index_vtx++] = point [ 1 ];
vtx[index_vtx++] = point [ 2 ];
order += 3; order += 3;
} }
while (--count); while (--count);
glEnd(); glEnableClientState( GL_VERTEX_ARRAY );
glVertexPointer( 3, GL_FLOAT, 0, vtx );
glDrawArrays( type, 0, total );
glDisableClientState( GL_VERTEX_ARRAY );
} }
/* stencilbuffer shadows */ /* stencilbuffer shadows */
@ -831,7 +882,7 @@ R_DrawAliasModel(entity_t *e)
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
glEnable(GL_BLEND); glEnable(GL_BLEND);
glColor4f(0, 0, 0, 0.5); glColor4f(0, 0, 0, 0.5f);
R_DrawAliasShadow(paliashdr, currententity->frame); R_DrawAliasShadow(paliashdr, currententity->frame);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glDisable(GL_BLEND); glDisable(GL_BLEND);

View file

@ -198,7 +198,6 @@ R_SetDefaultState(void)
glDisable(GL_BLEND); glDisable(GL_BLEND);
glColor4f(1, 1, 1, 1); glColor4f(1, 1, 1, 1);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glShadeModel(GL_FLAT); glShadeModel(GL_FLAT);

View file

@ -68,19 +68,19 @@ R_TextureAnimation(mtexinfo_t *tex)
void void
R_DrawGLPoly(glpoly_t *p) R_DrawGLPoly(glpoly_t *p)
{ {
int i;
float *v; float *v;
glBegin(GL_POLYGON);
v = p->verts[0]; v = p->verts[0];
for (i = 0; i < p->numverts; i++, v += VERTEXSIZE) glEnableClientState( GL_VERTEX_ARRAY );
{ glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glTexCoord2f(v[3], v[4]);
glVertex3fv(v);
}
glEnd(); glVertexPointer( 3, GL_FLOAT, VERTEXSIZE*sizeof(GLfloat), v );
glTexCoordPointer( 2, GL_FLOAT, VERTEXSIZE*sizeof(GLfloat), v+3 );
glDrawArrays( GL_TRIANGLE_FAN, 0, p->numverts );
glDisableClientState( GL_VERTEX_ARRAY );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
} }
void void
@ -100,16 +100,27 @@ R_DrawGLFlowingPoly(msurface_t *fa)
scroll = -64.0; scroll = -64.0;
} }
glBegin(GL_POLYGON); GLfloat tex[2*p->numverts];
v = p->verts[0]; unsigned int index_tex = 0;
for (i = 0; i < p->numverts; i++, v += VERTEXSIZE) v = p->verts [ 0 ];
{
glTexCoord2f((v[3] + scroll), v[4]);
glVertex3fv(v);
}
glEnd(); for ( i = 0; i < p->numverts; i++, v += VERTEXSIZE )
{
tex[index_tex++] = v [ 3 ] + scroll;
tex[index_tex++] = v [ 4 ];
}
v = p->verts [ 0 ];
glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glVertexPointer( 3, GL_FLOAT, VERTEXSIZE*sizeof(GLfloat), v );
glTexCoordPointer( 2, GL_FLOAT, 0, tex );
glDrawArrays( GL_TRIANGLE_FAN, 0, p->numverts );
glDisableClientState( GL_VERTEX_ARRAY );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
} }
void void
@ -141,12 +152,23 @@ R_DrawTriangleOutlines(void)
{ {
for (j = 2; j < p->numverts; j++) for (j = 2; j < p->numverts; j++)
{ {
glBegin(GL_LINE_STRIP); GLfloat vtx[12];
glVertex3fv(p->verts[0]); unsigned int k;
glVertex3fv(p->verts[j - 1]);
glVertex3fv(p->verts[j]); for (k=0; k<3; k++)
glVertex3fv(p->verts[0]); {
glEnd(); vtx[0+k] = p->verts [ 0 ][ k ];
vtx[3+k] = p->verts [ j - 1 ][ k ];
vtx[6+k] = p->verts [ j ][ k ];
vtx[9+k] = p->verts [ 0 ][ k ];
}
glEnableClientState( GL_VERTEX_ARRAY );
glVertexPointer( 3, GL_FLOAT, 0, vtx );
glDrawArrays( GL_LINE_STRIP, 0, 4 );
glDisableClientState( GL_VERTEX_ARRAY );
} }
} }
} }
@ -164,7 +186,6 @@ R_DrawGLPolyChain(glpoly_t *p, float soffset, float toffset)
for ( ; p != 0; p = p->chain) for ( ; p != 0; p = p->chain)
{ {
float *v; float *v;
int j;
v = p->verts[0]; v = p->verts[0];
@ -174,15 +195,15 @@ R_DrawGLPolyChain(glpoly_t *p, float soffset, float toffset)
return; return;
} }
glBegin(GL_POLYGON); glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
for (j = 0; j < p->numverts; j++, v += VERTEXSIZE) glVertexPointer( 3, GL_FLOAT, VERTEXSIZE*sizeof(GLfloat), v );
{ glTexCoordPointer( 2, GL_FLOAT, VERTEXSIZE*sizeof(GLfloat), v+5 );
glTexCoord2f(v[5], v[6]); glDrawArrays( GL_TRIANGLE_FAN, 0, p->numverts );
glVertex3fv(v);
}
glEnd(); glDisableClientState( GL_VERTEX_ARRAY );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
} }
} }
else else
@ -192,16 +213,28 @@ R_DrawGLPolyChain(glpoly_t *p, float soffset, float toffset)
float *v; float *v;
int j; int j;
glBegin(GL_POLYGON);
v = p->verts[0]; v = p->verts[0];
for (j = 0; j < p->numverts; j++, v += VERTEXSIZE) GLfloat tex[2*p->numverts];
unsigned int index_tex = 0;
for ( j = 0; j < p->numverts; j++, v += VERTEXSIZE )
{ {
glTexCoord2f(v[5] - soffset, v[6] - toffset); tex[index_tex++] = v [ 5 ] - soffset;
glVertex3fv(v); tex[index_tex++] = v [ 6 ] - toffset;
} }
glEnd(); v = p->verts [ 0 ];
glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glVertexPointer( 3, GL_FLOAT, VERTEXSIZE*sizeof(GLfloat), v );
glTexCoordPointer( 2, GL_FLOAT, 0, tex );
glDrawArrays( GL_TRIANGLE_FAN, 0, p->numverts );
glDisableClientState( GL_VERTEX_ARRAY );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
} }
} }
} }
@ -389,7 +422,7 @@ R_RenderBrushPoly(msurface_t *fa)
/* warp texture, no lightmaps */ /* warp texture, no lightmaps */
R_TexEnv(GL_MODULATE); R_TexEnv(GL_MODULATE);
glColor4f(gl_state.inverse_intensity, gl_state.inverse_intensity, glColor4f(gl_state.inverse_intensity, gl_state.inverse_intensity,
gl_state.inverse_intensity, 1.0F); gl_state.inverse_intensity, 1.0f);
R_EmitWaterPolys(fa); R_EmitWaterPolys(fa);
R_TexEnv(GL_REPLACE); R_TexEnv(GL_REPLACE);
@ -624,7 +657,7 @@ R_DrawTextureChains(void)
R_TexEnv(GL_REPLACE); R_TexEnv(GL_REPLACE);
} }
static void void
R_RenderLightmappedPoly(msurface_t *surf) R_RenderLightmappedPoly(msurface_t *surf)
{ {
int i, nv = surf->polys->numverts; int i, nv = surf->polys->numverts;
@ -715,16 +748,35 @@ R_RenderLightmappedPoly(msurface_t *surf)
for (p = surf->polys; p; p = p->chain) for (p = surf->polys; p; p = p->chain)
{ {
v = p->verts[0]; v = p->verts[0];
glBegin(GL_POLYGON);
for (i = 0; i < nv; i++, v += VERTEXSIZE) GLfloat tex[2*nv];
unsigned int index_tex = 0;
for ( i = 0; i < nv; i++, v += VERTEXSIZE )
{ {
qglMultiTexCoord2fARB(GL_TEXTURE0_ARB, (v[3] + scroll), v[4]); tex[index_tex++] = v [ 3 ] + scroll;
qglMultiTexCoord2fARB(GL_TEXTURE1_ARB, v[5], v[6]); tex[index_tex++] = v [ 4 ];
glVertex3fv(v);
} }
glEnd(); v = p->verts [ 0 ];
R_SelectTexture( GL_TEXTURE0 );
glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glVertexPointer( 3, GL_FLOAT, VERTEXSIZE*sizeof(GLfloat), v );
glTexCoordPointer( 2, GL_FLOAT, 0, tex );
R_SelectTexture( GL_TEXTURE1 );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glTexCoordPointer( 2, GL_FLOAT, VERTEXSIZE*sizeof(GLfloat), v+5 );
glDrawArrays( GL_TRIANGLE_FAN, 0, nv );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
R_SelectTexture( GL_TEXTURE0 );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
glDisableClientState( GL_VERTEX_ARRAY );
} }
} }
else else
@ -732,16 +784,24 @@ R_RenderLightmappedPoly(msurface_t *surf)
for (p = surf->polys; p; p = p->chain) for (p = surf->polys; p; p = p->chain)
{ {
v = p->verts[0]; v = p->verts[0];
glBegin(GL_POLYGON);
for (i = 0; i < nv; i++, v += VERTEXSIZE) R_SelectTexture( GL_TEXTURE0 );
{ glEnableClientState( GL_VERTEX_ARRAY );
qglMultiTexCoord2fARB(GL_TEXTURE0_ARB, v[3], v[4]); glEnableClientState( GL_TEXTURE_COORD_ARRAY );
qglMultiTexCoord2fARB(GL_TEXTURE1_ARB, v[5], v[6]);
glVertex3fv(v);
}
glEnd(); glVertexPointer( 3, GL_FLOAT, VERTEXSIZE*sizeof(GLfloat), v );
glTexCoordPointer( 2, GL_FLOAT, VERTEXSIZE*sizeof(GLfloat), v+3 );
R_SelectTexture( GL_TEXTURE1 );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glTexCoordPointer( 2, GL_FLOAT, VERTEXSIZE*sizeof(GLfloat), v+5 );
glDrawArrays( GL_TRIANGLE_FAN, 0, nv );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
R_SelectTexture( GL_TEXTURE0 );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
glDisableClientState( GL_VERTEX_ARRAY );
} }
} }
} }
@ -766,16 +826,35 @@ R_RenderLightmappedPoly(msurface_t *surf)
for (p = surf->polys; p; p = p->chain) for (p = surf->polys; p; p = p->chain)
{ {
v = p->verts[0]; v = p->verts[0];
glBegin(GL_POLYGON);
for (i = 0; i < nv; i++, v += VERTEXSIZE) GLfloat tex[2*nv];
unsigned int index_tex = 0;
for ( i = 0; i < nv; i++, v += VERTEXSIZE )
{ {
qglMultiTexCoord2fARB(GL_TEXTURE0_ARB, (v[3] + scroll), v[4]); tex[index_tex++] = v [ 3 ] + scroll;
qglMultiTexCoord2fARB(GL_TEXTURE1_ARB, v[5], v[6]); tex[index_tex++] = v [ 4 ];
glVertex3fv(v);
} }
glEnd(); v = p->verts [ 0 ];
R_SelectTexture( GL_TEXTURE0 );
glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glVertexPointer( 3, GL_FLOAT, VERTEXSIZE*sizeof(GLfloat), v );
glTexCoordPointer( 2, GL_FLOAT, 0, tex );
R_SelectTexture( GL_TEXTURE1 );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glTexCoordPointer( 2, GL_FLOAT, VERTEXSIZE*sizeof(GLfloat), v+5 );
glDrawArrays( GL_TRIANGLE_FAN, 0, nv );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
R_SelectTexture( GL_TEXTURE0 );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
glDisableClientState( GL_VERTEX_ARRAY );
} }
} }
else else
@ -783,16 +862,23 @@ R_RenderLightmappedPoly(msurface_t *surf)
for (p = surf->polys; p; p = p->chain) for (p = surf->polys; p; p = p->chain)
{ {
v = p->verts[0]; v = p->verts[0];
glBegin(GL_POLYGON);
for (i = 0; i < nv; i++, v += VERTEXSIZE) R_SelectTexture( GL_TEXTURE0 );
{ glEnableClientState( GL_VERTEX_ARRAY );
qglMultiTexCoord2fARB(GL_TEXTURE0_ARB, v[3], v[4]); glEnableClientState( GL_TEXTURE_COORD_ARRAY );
qglMultiTexCoord2fARB(GL_TEXTURE1_ARB, v[5], v[6]);
glVertex3fv(v);
}
glEnd(); glVertexPointer( 3, GL_FLOAT, VERTEXSIZE*sizeof(GLfloat), v );
glTexCoordPointer( 2, GL_FLOAT, VERTEXSIZE*sizeof(GLfloat), v+3 );
R_SelectTexture( GL_TEXTURE1 );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glTexCoordPointer( 2, GL_FLOAT, VERTEXSIZE*sizeof(GLfloat), v+5 );
glDrawArrays( GL_TRIANGLE_FAN, 0, nv );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
R_SelectTexture( GL_TEXTURE0 );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
glDisableClientState( GL_VERTEX_ARRAY );
} }
} }
} }

View file

@ -38,7 +38,12 @@ vec3_t skyaxis;
image_t *sky_images[6]; image_t *sky_images[6];
msurface_t *warpface; msurface_t *warpface;
int skytexorder[6] = {0, 2, 1, 3, 4, 5}; int skytexorder[6] = {0, 2, 1, 3, 4, 5};
GLfloat vtx_sky[12];
GLfloat tex_sky[8];
unsigned int index_vtx = 0;
unsigned int index_tex = 0;
/* 3dstudio environment map names */ /* 3dstudio environment map names */
char *suf[6] = {"rt", "bk", "lf", "ft", "up", "dn"}; char *suf[6] = {"rt", "bk", "lf", "ft", "up", "dn"};
@ -297,25 +302,33 @@ R_EmitWaterPolys(msurface_t *fa)
{ {
p = bp; p = bp;
glBegin(GL_TRIANGLE_FAN); GLfloat tex[2*p->numverts];
unsigned int index_tex = 0;
for (i = 0, v = p->verts[0]; i < p->numverts; i++, v += VERTEXSIZE) for ( i = 0, v = p->verts [ 0 ]; i < p->numverts; i++, v += VERTEXSIZE )
{ {
os = v[3]; os = v [ 3 ];
ot = v[4]; ot = v [ 4 ];
s = os + r_turbsin[(int)((ot * 0.125 + r_newrefdef.time) * TURBSCALE) & 255]; s = os + r_turbsin [ (int) ( ( ot * 0.125 + r_newrefdef.time ) * TURBSCALE ) & 255 ];
s += scroll; s += scroll;
s *= (1.0 / 64); tex[index_tex++] = s * ( 1.0 / 64 );
t = ot + r_turbsin[(int)((os * 0.125 + rdt) * TURBSCALE) & 255]; t = ot + r_turbsin [ (int) ( ( os * 0.125 + rdt ) * TURBSCALE ) & 255 ];
t *= (1.0 / 64); tex[index_tex++] = t * ( 1.0 / 64 );
glTexCoord2f(s, t);
glVertex3fv(v);
} }
glEnd(); v = p->verts [ 0 ];
glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glVertexPointer( 3, GL_FLOAT, VERTEXSIZE*sizeof(GLfloat), v );
glTexCoordPointer( 2, GL_FLOAT, 0, tex );
glDrawArrays( GL_TRIANGLE_FAN, 0, p->numverts );
glDisableClientState( GL_VERTEX_ARRAY );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
} }
} }
@ -634,8 +647,13 @@ R_MakeSkyVec(float s, float t, int axis)
} }
t = 1.0 - t; t = 1.0 - t;
glTexCoord2f(s, t);
glVertex3fv(v); tex_sky[index_tex++] = s;
tex_sky[index_tex++] = t;
vtx_sky[index_vtx++] = v[ 0 ];
vtx_sky[index_vtx++] = v[ 1 ];
vtx_sky[index_vtx++] = v[ 2 ];
} }
void void
@ -682,12 +700,24 @@ R_DrawSkyBox(void)
R_Bind(sky_images[skytexorder[i]]->texnum); R_Bind(sky_images[skytexorder[i]]->texnum);
glBegin(GL_QUADS); glEnableClientState( GL_VERTEX_ARRAY );
R_MakeSkyVec(skymins[0][i], skymins[1][i], i); glEnableClientState( GL_TEXTURE_COORD_ARRAY );
R_MakeSkyVec(skymins[0][i], skymaxs[1][i], i);
R_MakeSkyVec(skymaxs[0][i], skymaxs[1][i], i);
R_MakeSkyVec(skymaxs[0][i], skymins[1][i], i); index_vtx = 0;
glEnd(); index_tex = 0;
R_MakeSkyVec( skymins [ 0 ] [ i ], skymins [ 1 ] [ i ], i );
R_MakeSkyVec( skymins [ 0 ] [ i ], skymaxs [ 1 ] [ i ], i );
R_MakeSkyVec( skymaxs [ 0 ] [ i ], skymaxs [ 1 ] [ i ], i );
R_MakeSkyVec( skymaxs [ 0 ] [ i ], skymins [ 1 ] [ i ], i );
glVertexPointer( 3, GL_FLOAT, 0, vtx_sky );
glTexCoordPointer( 2, GL_FLOAT, 0, tex_sky );
glDrawArrays( GL_TRIANGLE_FAN, 0, 4 );
glDisableClientState( GL_VERTEX_ARRAY );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
} }
glPopMatrix(); glPopMatrix();