cg *= r_colorscale;
cb *= r_colorscale;
- varray_color[ 0] = varray_color[ 4] = varray_color[ 8] = varray_color[12] = cr;
- varray_color[ 1] = varray_color[ 5] = varray_color[ 9] = varray_color[13] = cg;
- varray_color[ 2] = varray_color[ 6] = varray_color[10] = varray_color[14] = cb;
- varray_color[ 3] = varray_color[ 7] = varray_color[11] = varray_color[15] = ca;
varray_texcoord[0][0] = tex->s2;varray_texcoord[0][1] = tex->t1;
varray_texcoord[0][2] = tex->s1;varray_texcoord[0][3] = tex->t1;
varray_texcoord[0][4] = tex->s1;varray_texcoord[0][5] = tex->t2;
glTexCoord2f(tex->s2, tex->t2);glVertex3f(varray_vertex[12], varray_vertex[13], varray_vertex[14]);
glEnd();
#else
+ GL_Color(cr, cg, cb, ca);
R_Mesh_Draw(4, 2, polygonelements);
#endif
}
int clientunit;
int texture[MAX_TEXTUREUNITS];
float texturergbscale[MAX_TEXTUREUNITS];
+ int colorarray;
}
gl_state;
}
}
-int usedarrays;
void GL_Backend_ResetState(void)
{
int i;
gl_state.depthmask = GL_TRUE;
qglDepthMask(gl_state.depthmask);CHECKGLERROR
- usedarrays = false;
- usedarrays = true;
qglVertexPointer(3, GL_FLOAT, sizeof(float[4]), varray_vertex);CHECKGLERROR
qglEnableClientState(GL_VERTEX_ARRAY);CHECKGLERROR
if (gl_mesh_floatcolors.integer)
{
qglColorPointer(4, GL_UNSIGNED_BYTE, sizeof(qbyte[4]), varray_bcolor);CHECKGLERROR
}
- qglEnableClientState(GL_COLOR_ARRAY);CHECKGLERROR
+ // LordHavoc: default to color array off
+ gl_state.colorarray = false;
+ GL_Color(1, 1, 1, 1);
GL_SetupTextureState();
}
+void GL_UseColorArray(void)
+{
+ if (!gl_state.colorarray)
+ {
+ gl_state.colorarray = true;
+ qglEnableClientState(GL_COLOR_ARRAY);CHECKGLERROR
+ }
+}
+
+void GL_Color(float cr, float cg, float cb, float ca)
+{
+ if (gl_state.colorarray)
+ {
+ gl_state.colorarray = false;
+ qglDisableClientState(GL_COLOR_ARRAY);CHECKGLERROR
+ }
+ qglColor4f(cr, cg, cb, ca);
+}
+
// called at beginning of frame
void R_Mesh_Start(void)
{
CHECKGLERROR
- if (!gl_mesh_floatcolors.integer)
+ if (gl_state.colorarray && !gl_mesh_floatcolors.integer)
GL_ConvertColorsFloatToByte(numverts);
//GL_TransformVertices(numverts);
if (!r_render.integer)
}
qglBindTexture(GL_TEXTURE_2D, 0);CHECKGLERROR
- if (usedarrays)
- {
- qglClientActiveTexture(GL_TEXTURE0_ARB + i);CHECKGLERROR
- qglDisableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
- }
+ qglClientActiveTexture(GL_TEXTURE0_ARB + i);CHECKGLERROR
+ qglDisableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
}
}
else
{
qglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);CHECKGLERROR
qglEnable(GL_TEXTURE_2D);CHECKGLERROR
- if (usedarrays)
- {
- qglDisableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
- }
- }
- if (usedarrays)
- {
- qglDisableClientState(GL_COLOR_ARRAY);CHECKGLERROR
- qglDisableClientState(GL_VERTEX_ARRAY);CHECKGLERROR
+ qglDisableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
}
+ qglDisableClientState(GL_COLOR_ARRAY);CHECKGLERROR
+ qglDisableClientState(GL_VERTEX_ARRAY);CHECKGLERROR
qglDisable(GL_BLEND);CHECKGLERROR
qglEnable(GL_DEPTH_TEST);CHECKGLERROR
void GL_SetupView_Orientation_FromEntity (vec3_t origin, vec3_t angles);
void GL_SetupView_Mode_Perspective (double aspect, double fovx, double fovy, double zNear, double zFar);
void GL_SetupView_Mode_Ortho (double x1, double y1, double x2, double y2, double zNear, double zFar);
+void GL_UseColorArray(void);
+void GL_Color(float cr, float cg, float cb, float ca);
void GL_DepthFunc(int value);
void GL_ClearDepth(void);
if (h == 0)
h = pic->height;
}
- varray_color[0] = varray_color[4] = varray_color[ 8] = varray_color[12] = cr;
- varray_color[1] = varray_color[5] = varray_color[ 9] = varray_color[13] = cg;
- varray_color[2] = varray_color[6] = varray_color[10] = varray_color[14] = cb;
- varray_color[3] = varray_color[7] = varray_color[11] = varray_color[15] = ca;
varray_texcoord[0][0] = 0;varray_texcoord[0][1] = 0;
varray_texcoord[0][2] = 1;varray_texcoord[0][3] = 0;
varray_texcoord[0][4] = 1;varray_texcoord[0][5] = 1;
varray_vertex[ 4] = x+w;varray_vertex[ 5] = y ;varray_vertex[ 6] = 10;
varray_vertex[ 8] = x+w;varray_vertex[ 9] = y+h;varray_vertex[10] = 10;
varray_vertex[12] = x ;varray_vertex[13] = y+h;varray_vertex[14] = 10;
+ GL_Color(cr, cg, cb, ca);
R_Mesh_Draw(4, 2, quadelements);
break;
case DRAWQUEUE_STRING:
R_Mesh_TextureState(&m);
}
batchcount = 0;
- ac = varray_color;
at = varray_texcoord[0];
av = varray_vertex;
+ GL_Color(cr, cg, cb, ca);
while ((num = *str++) && x < vid.conwidth)
{
if (num != ' ')
t = (num >> 4)*0.0625f + (0.5f / 256.0f);
u = 0.0625f - (1.0f / 256.0f);
v = 0.0625f - (1.0f / 256.0f);
- ac[0] = ac[4] = ac[ 8] = ac[12] = cr;
- ac[1] = ac[5] = ac[ 9] = ac[13] = cg;
- ac[2] = ac[6] = ac[10] = ac[14] = cb;
- ac[3] = ac[7] = ac[11] = ac[15] = ca;
at[0] = s ;at[1] = t ;
at[2] = s+u;at[3] = t ;
at[4] = s+u;at[5] = t+v;
{
R_Mesh_Draw(batchcount * 4, batchcount * 2, quadelements);
batchcount = 0;
- ac = varray_color;
at = varray_texcoord[0];
av = varray_vertex;
}
memcpy(varray_vertex, mesh->vertices, sizeof(float[4]) * mesh->numvertices);
memcpy(varray_texcoord[0], mesh->texcoords, sizeof(float[2]) * mesh->numvertices);
memcpy(varray_color, mesh->colors, sizeof(float[4]) * mesh->numvertices);
+ GL_UseColorArray();
R_Mesh_Draw(mesh->numvertices, mesh->numtriangles, mesh->indices);
currentpic = "\0";
break;
varray_vertex[0] = -5000;varray_vertex[1] = -5000;varray_vertex[2] = 10;
varray_vertex[4] = 10000;varray_vertex[5] = -5000;varray_vertex[6] = 10;
varray_vertex[8] = -5000;varray_vertex[9] = 10000;varray_vertex[10] = 10;
- // alpha is 1 for all these
- varray_color[3] = varray_color[7] = varray_color[11] = 1;
// all the blends ignore depth
memset(&m, 0, sizeof(m));
m.depthdisable = true;
cr = t - 1.0f;
if (cr > 1.0f)
cr = 1.0f;
- varray_color[0] = varray_color[4] = varray_color[ 8] = cr;
- varray_color[1] = varray_color[5] = varray_color[ 9] = cr;
- varray_color[2] = varray_color[6] = varray_color[10] = cr;
+ GL_Color(cr, cr, cr, 1);
R_Mesh_Draw(3, 1, polygonelements);
t *= 0.5;
}
m.blendfunc1 = GL_ZERO;
m.blendfunc2 = GL_SRC_COLOR;
R_Mesh_State(&m);
- varray_color[0] = varray_color[4] = varray_color[ 8] = varray_color[12] = t;
- varray_color[1] = varray_color[5] = varray_color[ 9] = varray_color[13] = t;
- varray_color[2] = varray_color[6] = varray_color[10] = varray_color[14] = t;
+ GL_Color(t, t, t, 1);
R_Mesh_Draw(3, 1, polygonelements);
}
if (v_brightness.value >= 0.01f)
m.blendfunc1 = GL_ONE;
m.blendfunc2 = GL_ONE;
R_Mesh_State(&m);
- varray_color[0] = varray_color[4] = varray_color[ 8] = varray_color[12] = v_brightness.value;
- varray_color[1] = varray_color[5] = varray_color[ 9] = varray_color[13] = v_brightness.value;
- varray_color[2] = varray_color[6] = varray_color[10] = varray_color[14] = v_brightness.value;
+ GL_Color(v_brightness.value, v_brightness.value, v_brightness.value, 1);
R_Mesh_Draw(3, 1, polygonelements);
}
}
colorscale = r_colorscale;
if (gl_combine.integer)
colorscale *= 0.25f;
-
+
if (!skinframe->base && !skinframe->pants && !skinframe->shirt && !skinframe->glow)
{
// untextured
R_LightModel(ent, model->numverts, colorscale, colorscale, colorscale, false);
aliasvert = aliasvertbuf;
aliasvertcolor = aliasvertcolorbuf;
+ GL_UseColorArray();
R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
return;
}
R_LightModel(ent, model->numverts, colorscale, colorscale, colorscale, false);
aliasvert = aliasvertbuf;
aliasvertcolor = aliasvertcolorbuf;
+ GL_UseColorArray();
R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
return;
}
R_ModulateColors(aliasvertcolor, varray_color, model->numverts, colorscale, colorscale, colorscale);
memcpy(varray_vertex, aliasvert, model->numverts * sizeof(float[4]));
memcpy(varray_texcoord[0], model->mdlmd2data_texcoords, model->numverts * sizeof(float[2]));
+ GL_UseColorArray();
R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
}
blendfunc2 = GL_ONE;
c_alias_polys += model->numtris;
if (pantsfullbright)
- R_FillColors(varray_color, model->numverts, pantscolor[0] * colorscale, pantscolor[1] * colorscale, pantscolor[2] * colorscale, ent->alpha);
+ GL_Color(pantscolor[0] * colorscale, pantscolor[1] * colorscale, pantscolor[2] * colorscale, ent->alpha);
else
+ {
+ GL_UseColorArray();
R_ModulateColors(aliasvertcolor, varray_color, model->numverts, pantscolor[0] * colorscale, pantscolor[1] * colorscale, pantscolor[2] * colorscale);
+ }
memcpy(varray_vertex, aliasvert, model->numverts * sizeof(float[4]));
memcpy(varray_texcoord[0], model->mdlmd2data_texcoords, model->numverts * sizeof(float[2]));
R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
blendfunc2 = GL_ONE;
c_alias_polys += model->numtris;
if (shirtfullbright)
- R_FillColors(varray_color, model->numverts, shirtcolor[0] * colorscale, shirtcolor[1] * colorscale, shirtcolor[2] * colorscale, ent->alpha);
+ GL_Color(shirtcolor[0] * colorscale, shirtcolor[1] * colorscale, shirtcolor[2] * colorscale, ent->alpha);
else
+ {
+ GL_UseColorArray();
R_ModulateColors(aliasvertcolor, varray_color, model->numverts, shirtcolor[0] * colorscale, shirtcolor[1] * colorscale, shirtcolor[2] * colorscale);
+ }
memcpy(varray_vertex, aliasvert, model->numverts * sizeof(float[4]));
memcpy(varray_texcoord[0], model->mdlmd2data_texcoords, model->numverts * sizeof(float[2]));
R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
blendfunc1 = GL_SRC_ALPHA;
blendfunc2 = GL_ONE;
c_alias_polys += model->numtris;
- R_FillColors(varray_color, model->numverts, (1 - fog) * r_colorscale, (1 - fog) * r_colorscale, (1 - fog) * r_colorscale, ent->alpha);
memcpy(varray_vertex, aliasvert, model->numverts * sizeof(float[4]));
memcpy(varray_texcoord[0], model->mdlmd2data_texcoords, model->numverts * sizeof(float[2]));
+ GL_Color((1 - fog) * r_colorscale, (1 - fog) * r_colorscale, (1 - fog) * r_colorscale, ent->alpha);
R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
}
}
R_Mesh_State(&m);
c_alias_polys += model->numtris;
- R_FillColors(varray_color, model->numverts, fogcolor[0] * fog * r_colorscale, fogcolor[1] * fog * r_colorscale, fogcolor[2] * fog * r_colorscale, ent->alpha);
memcpy(varray_vertex, aliasvert, model->numverts * sizeof(float[4]));
memcpy(varray_texcoord[0], model->mdlmd2data_texcoords, model->numverts * sizeof(float[2]));
+ GL_Color(fogcolor[0] * fog * r_colorscale, fogcolor[1] * fog * r_colorscale, fogcolor[2] * fog * r_colorscale, ent->alpha);
R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
}
}
R_Mesh_State(&m);
R_Mesh_Matrix(&ent->matrix);
R_LerpMDLMD2Vertices(ent, varray_vertex, aliasvertnorm);
- R_FillColors(varray_color, model->numverts * 2, 0.1 * r_colorscale, 0.025 * r_colorscale, 0.0125 * r_colorscale, 1);
+ GL_Color(0.1 * r_colorscale, 0.025 * r_colorscale, 0.0125 * r_colorscale, 1);
Matrix4x4_Transform(&ent->inversematrix, r_dlight[i].origin, temp);
- R_ShadowVolume(model->numverts, model->numtris, model->mdlmd2data_indices, model->mdlmd2data_triangleneighbors, temp, r_dlight[i].cullradius + model->radius - sqrt(f));
+ R_ShadowVolume(model->numverts, model->numtris, model->mdlmd2data_indices, model->mdlmd2data_triangleneighbors, temp, r_dlight[i].cullradius + model->radius - sqrt(f), true);
}
}
}
+ return;
}
lightdirection[0] = 0.5;
c_alias_polys += model->numtris;
R_LerpMDLMD2Vertices(ent, varray_vertex, aliasvertnorm);
- R_FillColors(varray_color, model->numverts, 0, 0, 0, 0.5);
// put a light direction in the entity's coordinate space
Matrix4x4_Transform3x3(&ent->inversematrix, lightdirection, projection);
//if (i & 1)
VectorMA(v, dist, projection, v);
}
+ GL_Color(0, 0, 0, 0.5);
R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
}
memcpy(varray_vertex, aliasvert, numverts * sizeof(float[4]));
R_ModulateColors(aliasvertcolor, varray_color, numverts, colorscale, colorscale, colorscale);
memcpy(varray_texcoord[0], (float *)(m->lump_texcoords.start + (int) m), numverts * sizeof(float[2]));
+ GL_UseColorArray();
R_Mesh_Draw(numverts, numtriangles, elements);
if (fog)
c_alias_polys += numtriangles;
memcpy(varray_vertex, aliasvert, numverts * sizeof(float[4]));
- R_FillColors(varray_color, numverts, fogcolor[0] * r_colorscale, fogcolor[1] * r_colorscale, fogcolor[2] * r_colorscale, ent->alpha * fog);
//memcpy(mesh_texcoord[0], (float *)(m->lump_texcoords.start + (int) m), numverts * sizeof(float[2]));
+ GL_Color(fogcolor[0] * r_colorscale, fogcolor[1] * r_colorscale, fogcolor[2] * r_colorscale, ent->alpha * fog);
R_Mesh_Draw(numverts, numtriangles, elements);
}
}
R_Mesh_Matrix(&r_identitymatrix);
R_Mesh_State(&m);
- varray_color[0] = varray_color[4] = varray_color[8] = r_refdef.viewblend[0];
- varray_color[1] = varray_color[5] = varray_color[9] = r_refdef.viewblend[1];
- varray_color[2] = varray_color[6] = varray_color[10] = r_refdef.viewblend[2];
- varray_color[3] = varray_color[7] = varray_color[11] = r_refdef.viewblend[3];
r = 64000;
varray_vertex[0] = r_origin[0] + vpn[0] * 1.5 - vright[0] * r - vup[0] * r;
varray_vertex[1] = r_origin[1] + vpn[1] * 1.5 - vright[1] * r - vup[1] * r;
varray_vertex[8] = varray_vertex[0] + vright[0] * r;
varray_vertex[9] = varray_vertex[1] + vright[1] * r;
varray_vertex[10] = varray_vertex[2] + vright[2] * r;
+ GL_Color(r_refdef.viewblend[0], r_refdef.viewblend[1], r_refdef.viewblend[2], r_refdef.viewblend[3]);
R_Mesh_Draw(3, 1, polygonelements);
}
varray_vertex[20] = maxs[0];varray_vertex[21] = mins[1];varray_vertex[22] = maxs[2];
varray_vertex[24] = mins[0];varray_vertex[25] = maxs[1];varray_vertex[26] = maxs[2];
varray_vertex[28] = maxs[0];varray_vertex[29] = maxs[1];varray_vertex[30] = maxs[2];
- varray_color[ 0] = varray_color[ 4] = varray_color[ 8] = varray_color[12] = varray_color[16] = varray_color[20] = varray_color[24] = varray_color[28] = cr * r_colorscale;
- varray_color[ 1] = varray_color[ 5] = varray_color[ 9] = varray_color[13] = varray_color[17] = varray_color[21] = varray_color[25] = varray_color[29] = cg * r_colorscale;
- varray_color[ 2] = varray_color[ 6] = varray_color[10] = varray_color[14] = varray_color[18] = varray_color[22] = varray_color[26] = varray_color[30] = cb * r_colorscale;
- varray_color[ 3] = varray_color[ 7] = varray_color[11] = varray_color[15] = varray_color[19] = varray_color[23] = varray_color[27] = varray_color[31] = ca;
+ R_FillColors(varray_color, 8, cr * r_colorscale, cg * r_colorscale, cb * r_colorscale, ca);
if (fogenabled)
{
for (i = 0, v = varray_vertex, c = varray_color;i < 8;i++, v += 4, c += 4)
c[2] = c[2] * f1 + fogcolor[2] * f2;
}
}
+ GL_UseColorArray();
R_Mesh_Draw(8, 12);
}
*/
varray_vertex[12] = 0;varray_vertex[13] = 16;varray_vertex[14] = 0;
varray_vertex[16] = 0;varray_vertex[17] = 0;varray_vertex[18] = -16;
varray_vertex[20] = 0;varray_vertex[21] = 0;varray_vertex[22] = 16;
- varray_color[ 0] = 0.00f;varray_color[ 1] = 0.00f;varray_color[ 2] = 0.50f;varray_color[ 3] = ent->alpha;
- varray_color[ 4] = 0.00f;varray_color[ 5] = 0.00f;varray_color[ 6] = 0.50f;varray_color[ 7] = ent->alpha;
- varray_color[ 8] = 0.00f;varray_color[ 9] = 0.50f;varray_color[10] = 0.00f;varray_color[11] = ent->alpha;
- varray_color[12] = 0.00f;varray_color[13] = 0.50f;varray_color[14] = 0.00f;varray_color[15] = ent->alpha;
- varray_color[16] = 0.50f;varray_color[17] = 0.00f;varray_color[18] = 0.00f;varray_color[19] = ent->alpha;
- varray_color[20] = 0.50f;varray_color[21] = 0.00f;varray_color[22] = 0.00f;varray_color[23] = ent->alpha;
+ varray_color[ 0] = 0.00f * r_colorscale;varray_color[ 1] = 0.00f * r_colorscale;varray_color[ 2] = 0.50f * r_colorscale;varray_color[ 3] = ent->alpha;
+ varray_color[ 4] = 0.00f * r_colorscale;varray_color[ 5] = 0.00f * r_colorscale;varray_color[ 6] = 0.50f * r_colorscale;varray_color[ 7] = ent->alpha;
+ varray_color[ 8] = 0.00f * r_colorscale;varray_color[ 9] = 0.50f * r_colorscale;varray_color[10] = 0.00f * r_colorscale;varray_color[11] = ent->alpha;
+ varray_color[12] = 0.00f * r_colorscale;varray_color[13] = 0.50f * r_colorscale;varray_color[14] = 0.00f * r_colorscale;varray_color[15] = ent->alpha;
+ varray_color[16] = 0.50f * r_colorscale;varray_color[17] = 0.00f * r_colorscale;varray_color[18] = 0.00f * r_colorscale;varray_color[19] = ent->alpha;
+ varray_color[20] = 0.50f * r_colorscale;varray_color[21] = 0.00f * r_colorscale;varray_color[22] = 0.00f * r_colorscale;varray_color[23] = ent->alpha;
if (fogenabled)
{
VectorSubtract(ent->origin, r_origin, diff);
c[2] *= r_colorscale;
}
}
+ GL_UseColorArray();
R_Mesh_Draw(6, 8, element);
}
{
R_Mesh_ResizeCheck(mesh->numverts);
memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
- if (skyrendermasked)
- memset(varray_color, 0, mesh->numverts * sizeof(float[4]));
- else
- R_FillColors(varray_color, mesh->numverts, fogcolor[0] * r_colorscale, fogcolor[1] * r_colorscale, fogcolor[2] * r_colorscale, 1);
+ GL_Color(fogcolor[0] * r_colorscale, fogcolor[1] * r_colorscale, fogcolor[2] * r_colorscale, 1);
R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
}
}
colorscale *= 0.25f;
}
R_Mesh_State(&m);
+ GL_UseColorArray();
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
R_Mesh_ResizeCheck(mesh->numverts);
}
base = ent->effects & EF_FULLBRIGHT ? 2.0f : r_ambient.value * (1.0f / 64.0f);
R_Mesh_State(&m);
+ GL_UseColorArray();
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
R_Mesh_ResizeCheck(mesh->numverts);
}
m.tex[0] = R_GetTexture(surf->currenttexture->texture);
R_Mesh_State(&m);
+ GL_UseColorArray();
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
R_Mesh_ResizeCheck(mesh->numverts);
m.blendfunc2 = GL_ONE;
m.tex[0] = R_GetTexture(surf->currenttexture->glowtexture);
R_Mesh_State(&m);
+ GL_UseColorArray();
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
R_Mesh_ResizeCheck(mesh->numverts);
m.blendfunc2 = GL_ONE;
m.tex[0] = R_GetTexture(surf->currenttexture->fogtexture);
R_Mesh_State(&m);
+ GL_UseColorArray();
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
R_Mesh_ResizeCheck(mesh->numverts);
m.texrgbscale[1] = 4;
m.texrgbscale[2] = 2;
R_Mesh_State(&m);
+ cl = (float) (1 << r_lightmapscalebit) * r_colorscale;
+ GL_Color(cl, cl, cl, 1);
for (surf = texture->surfacechain;surf;surf = surf->texturechain)
{
lightmaptexturenum = R_GetTexture(surf->lightmaptexture);
memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
memcpy(varray_texcoord[1], mesh->uv, mesh->numverts * sizeof(float[2]));
memcpy(varray_texcoord[2], mesh->ab, mesh->numverts * sizeof(float[2]));
- cl = (float) (1 << r_lightmapscalebit) * r_colorscale;
- R_FillColors(varray_color, mesh->numverts, cl, cl, cl, 1);
R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
}
}
if (gl_combine.integer)
m.texrgbscale[1] = 4;
R_Mesh_State(&m);
+ GL_Color(r_colorscale, r_colorscale, r_colorscale, 1);
for (surf = texture->surfacechain;surf;surf = surf->texturechain)
{
lightmaptexturenum = R_GetTexture(surf->lightmaptexture);
memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
memcpy(varray_texcoord[1], mesh->uv, mesh->numverts * sizeof(float[2]));
- R_FillColors(varray_color, mesh->numverts, r_colorscale, r_colorscale, r_colorscale, 1);
R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
}
}
m.blendfunc2 = GL_ZERO;
m.tex[0] = R_GetTexture(texture->texture);
R_Mesh_State(&m);
+ GL_Color(1, 1, 1, 1);
for (surf = texture->surfacechain;surf;surf = surf->texturechain)
{
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
R_Mesh_ResizeCheck(mesh->numverts);
memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
- R_FillColors(varray_color, mesh->numverts, 1, 1, 1, 1);
R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
}
}
if (gl_combine.integer)
m.texrgbscale[0] = 4;
R_Mesh_State(&m);
+ GL_Color(r_colorscale, r_colorscale, r_colorscale, 1);
for (surf = texture->surfacechain;surf;surf = surf->texturechain)
{
lightmaptexturenum = R_GetTexture(surf->lightmaptexture);
R_Mesh_ResizeCheck(mesh->numverts);
memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
memcpy(varray_texcoord[0], mesh->uv, mesh->numverts * sizeof(float[2]));
- R_FillColors(varray_color, mesh->numverts, r_colorscale, r_colorscale, r_colorscale, 1);
R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
}
}
colorscale *= 0.25f;
}
R_Mesh_State(&m);
+ GL_UseColorArray();
for (surf = texture->surfacechain;surf;surf = surf->texturechain)
{
if (surf->dlightframe == r_framecount)
m.blendfunc1 = GL_SRC_ALPHA;
m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
R_Mesh_State(&m);
+ GL_UseColorArray();
for (surf = texture->surfacechain;surf;surf = surf->texturechain)
{
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
m.blendfunc2 = GL_SRC_COLOR;
m.tex[0] = R_GetTexture(texture->detailtexture);
R_Mesh_State(&m);
+ GL_Color(1, 1, 1, 1);
for (surf = texture->surfacechain;surf;surf = surf->texturechain)
{
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
R_Mesh_ResizeCheck(mesh->numverts);
memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
memcpy(varray_texcoord[0], mesh->ab, mesh->numverts * sizeof(float[2]));
- R_FillColors(varray_color, mesh->numverts, 1, 1, 1, 1);
R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
}
}
m.blendfunc2 = GL_ONE;
m.tex[0] = R_GetTexture(texture->glowtexture);
R_Mesh_State(&m);
+ GL_Color(r_colorscale, r_colorscale, r_colorscale, 1);
for (surf = texture->surfacechain;surf;surf = surf->texturechain)
{
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
R_Mesh_ResizeCheck(mesh->numverts);
memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
- R_FillColors(varray_color, mesh->numverts, r_colorscale, r_colorscale, r_colorscale, 1);
R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
}
}
R_Mesh_State(&m);
R_Mesh_ResizeCheck(portal->numpoints);
i = portal - ent->model->portals;
- R_FillColors(varray_color, portal->numpoints,
- ((i & 0x0007) >> 0) * (1.0f / 7.0f) * r_colorscale,
- ((i & 0x0038) >> 3) * (1.0f / 7.0f) * r_colorscale,
- ((i & 0x01C0) >> 6) * (1.0f / 7.0f) * r_colorscale,
- 0.125f);
+ GL_Color(((i & 0x0007) >> 0) * (1.0f / 7.0f) * r_colorscale,
+ ((i & 0x0038) >> 3) * (1.0f / 7.0f) * r_colorscale,
+ ((i & 0x01C0) >> 6) * (1.0f / 7.0f) * r_colorscale,
+ 0.125f);
if (PlaneDiff(r_origin, (&portal->plane)) > 0)
{
for (i = portal->numpoints - 1, v = varray_vertex;i >= 0;i--, v += 4)
extern void (GLAPIENTRY *qglTexCoordPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
extern void (GLAPIENTRY *qglArrayElement)(GLint i);
-extern void (GLAPIENTRY *qglColor4ub)(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);
+extern void (GLAPIENTRY *qglColor4f)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
extern void (GLAPIENTRY *qglTexCoord2f)(GLfloat s, GLfloat t);
extern void (GLAPIENTRY *qglVertex2f)(GLfloat x, GLfloat y);
extern void (GLAPIENTRY *qglVertex3f)(GLfloat x, GLfloat y, GLfloat z);
R_Mesh_Matrix(&r_identitymatrix);
R_Mesh_State(&m);
- varray_color[0] = varray_color[4] = varray_color[8] = varray_color[12] = cr * r_colorscale;
- varray_color[1] = varray_color[5] = varray_color[9] = varray_color[13] = cg * r_colorscale;
- varray_color[2] = varray_color[6] = varray_color[10] = varray_color[14] = cb * r_colorscale;
- varray_color[3] = varray_color[7] = varray_color[11] = varray_color[15] = ca;
+ GL_Color(cr * r_colorscale, cg * r_colorscale, cb * r_colorscale, ca);
varray_texcoord[0][0] = 0;
varray_texcoord[0][1] = 0;
varray_texcoord[0][2] = 0;
c[3] = 1;
}
}
+ GL_UseColorArray();
R_Mesh_Draw(numverts, numtriangles, explosiontris[0]);
}
VectorSubtract(rd->origin, r_origin, diff);
scale *= 1 - exp(fogdensity/DotProduct(diff,diff));
}
- varray_color[ 0] = varray_color[ 4] = varray_color[ 8] = varray_color[12] = rd->light[0] * scale;
- varray_color[ 1] = varray_color[ 5] = varray_color[ 9] = varray_color[13] = rd->light[1] * scale;
- varray_color[ 2] = varray_color[ 6] = varray_color[10] = varray_color[14] = rd->light[2] * scale;
- varray_color[ 3] = varray_color[ 7] = varray_color[11] = varray_color[15] = 1;
+ GL_Color(rd->light[0] * scale, rd->light[1] * scale, rd->light[2] * scale, 1);
varray_texcoord[0][0] = 0;
varray_texcoord[0][1] = 0;
varray_texcoord[0][2] = 0;
R_RegisterModule("R_Shadow", r_shadow_start, r_shadow_shutdown, r_shadow_newmap);
}
-void R_ShadowVolume(int numverts, int numtris, int *elements, int *neighbors, vec3_t relativelightorigin, float projectdistance)
+void R_ShadowVolume(int numverts, int numtris, int *elements, int *neighbors, vec3_t relativelightorigin, float projectdistance, int visiblevolume)
{
int i, *e, *n, *out, tris;
float *v0, *v1, *v2, dir0[3], dir1[3], temp[3], f;
}
}
// draw the volume
- R_Mesh_Draw(numverts * 2, tris, shadowelements);
+ if (visiblevolume)
+ {
+ qglDisable(GL_CULL_FACE);
+ R_Mesh_Draw(numverts * 2, tris, shadowelements);
+ qglEnable(GL_CULL_FACE);
+ }
+ else
+ {
+ qglCullFace(GL_FRONT);
+ //qglStencilFunc(
+ }
+}
+
+void R_Shadow_BeginScene(void)
+{
+ rmeshstate_t m;
+ memset(&m, 0, sizeof(m));
+ m.blendfunc1 = GL_ONE;
+ m.blendfunc2 = GL_ZERO;
+ R_Mesh_State(&m);
}
#define R_SHADOW_H
void R_Shadow_Init(void);
-void R_ShadowVolume(int numverts, int numtris, int *elements, int *neighbors, vec3_t relativelightorigin, float projectdistance);
+void R_ShadowVolume(int numverts, int numtris, int *elements, int *neighbors, vec3_t relativelightorigin, float projectdistance, int visiblevolume);
#endif
m.tex[0] = R_GetTexture(skyboxside[3]); // front
R_Mesh_State(&m);
- varray_color[0] = varray_color[4] = varray_color[8] = varray_color[12] = r_colorscale;
- varray_color[1] = varray_color[5] = varray_color[9] = varray_color[13] = r_colorscale;
- varray_color[2] = varray_color[6] = varray_color[10] = varray_color[14] = r_colorscale;
- varray_color[3] = varray_color[7] = varray_color[11] = varray_color[15] = 1;
+ GL_Color(r_colorscale, r_colorscale, r_colorscale, 1);
R_SkyBoxPolyVec(0, 1, 0, 1, -1, 1);
R_SkyBoxPolyVec(1, 1, 1, 1, -1, -1);
}
}
-static void skyspherearrays(float *v, float *t, float *c, float *source, float s, float colorscale)
+static void skyspherearrays(float *v, float *t, float *source, float s)
{
int i;
- for (i = 0;i < (skygridx1*skygridy1);i++, c += 4, t += 2, v += 4, source += 5)
+ for (i = 0;i < (skygridx1*skygridy1);i++, t += 2, v += 4, source += 5)
{
- c[0] = colorscale;
- c[1] = colorscale;
- c[2] = colorscale;
- c[3] = 1;
t[0] = source[0] + s;
t[1] = source[1] + s;
v[0] = source[2];
m.tex[0] = R_GetTexture(solidskytexture);
R_Mesh_State(&m);
- skyspherearrays(varray_vertex, varray_texcoord[0], varray_color, skysphere, speedscale, r_colorscale);
+ GL_Color(r_colorscale, r_colorscale, r_colorscale, 1);
+
+ skyspherearrays(varray_vertex, varray_texcoord[0], skysphere, speedscale);
R_Mesh_Draw(numverts, numtriangles, skysphereindices);
m.blendfunc1 = GL_SRC_ALPHA;
m.tex[0] = R_GetTexture(alphaskytexture);
R_Mesh_State(&m);
- skyspherearrays(varray_vertex, varray_texcoord[0], varray_color, skysphere, speedscale2, r_colorscale);
+ skyspherearrays(varray_vertex, varray_texcoord[0], skysphere, speedscale2);
R_Mesh_Draw(numverts, numtriangles, skysphereindices);
}
m.tex[0] = texture;
R_Mesh_State(&m);
- varray_color[0] = varray_color[4] = varray_color[8] = varray_color[12] = red * r_colorscale;
- varray_color[1] = varray_color[5] = varray_color[9] = varray_color[13] = green * r_colorscale;
- varray_color[2] = varray_color[6] = varray_color[10] = varray_color[14] = blue * r_colorscale;
- varray_color[3] = varray_color[7] = varray_color[11] = varray_color[15] = alpha;
varray_texcoord[0][0] = 0;
varray_texcoord[0][1] = 1;
varray_texcoord[0][2] = 0;
varray_vertex[12] = origin[0] + frame->down * up[0] - frame->right * left[0];
varray_vertex[13] = origin[1] + frame->down * up[1] - frame->right * left[1];
varray_vertex[14] = origin[2] + frame->down * up[2] - frame->right * left[2];
+ GL_Color(red * r_colorscale, green * r_colorscale, blue * r_colorscale, alpha);
R_Mesh_Draw(4, 2, polygonelements);
}
void (GLAPIENTRY *qglTexCoordPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
void (GLAPIENTRY *qglArrayElement)(GLint i);
-void (GLAPIENTRY *qglColor4ub)(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);
+void (GLAPIENTRY *qglColor4f)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
void (GLAPIENTRY *qglTexCoord2f)(GLfloat s, GLfloat t);
void (GLAPIENTRY *qglVertex2f)(GLfloat x, GLfloat y);
void (GLAPIENTRY *qglVertex3f)(GLfloat x, GLfloat y, GLfloat z);
{"glColorPointer", (void **) &qglColorPointer},
{"glTexCoordPointer", (void **) &qglTexCoordPointer},
{"glArrayElement", (void **) &qglArrayElement},
- {"glColor4ub", (void **) &qglColor4ub},
+ {"glColor4f", (void **) &qglColor4f},
{"glTexCoord2f", (void **) &qglTexCoord2f},
{"glVertex2f", (void **) &qglVertex2f},
{"glVertex3f", (void **) &qglVertex3f},