#include "quakedef.h"
#include "image.h"
-cvar_t scr_conalpha = {CVAR_SAVE, "scr_conalpha", "1"};
-
static rtexture_t *char_texture;
//=============================================================================
hashkey = ((crc >> 8) ^ crc) % CACHEPICHASHSIZE;
for (pic = cachepichash[hashkey];pic;pic = pic->chain)
{
- if (!strcmp (picname, pic->name))
+ if (!strcmp (picname, pic->name) && pic->tex)
{
R_FreeTexture(pic->tex);
pic->width = 0;
void GL_Draw_Init (void)
{
- Cvar_RegisterVariable (&scr_conalpha);
-
numcachepics = 0;
memset(cachepichash, 0, sizeof(cachepichash));
float blendvertex3f[9] = {-5000, -5000, 10, 10000, -5000, 10, -5000, 10000, 10};
int quadelements[768];
-float textverts[128*4*3];
-float texttexcoords[128*4*2];
void R_DrawQueue(void)
{
- int pos, num, chartexnum, overbright, texnum, additive, batch;
+ int pos, num, chartexnum, texnum, batch;
float x, y, w, h, s, t, u, v, *av, *at, c[4];
cachepic_t *pic;
drawqueue_t *dq;
memset(&m, 0, sizeof(m));
m.tex[0] = 0;
- R_Mesh_TextureState(&m);
+ R_Mesh_State_Texture(&m);
currentpic = "";
pic = NULL;
texnum = 0;
color = 0;
- overbright = v_overbrightbits.integer;
batch = false;
batchcount = 0;
for (pos = 0;pos < r_refdef.drawqueuesize;pos += ((drawqueue_t *)(r_refdef.drawqueue + pos))->size)
{
dq = (drawqueue_t *)(r_refdef.drawqueue + pos);
- additive = (dq->flags & DRAWFLAG_ADDITIVE) != 0;
color = dq->color;
- m.blendfunc1 = GL_SRC_ALPHA;
- if (additive)
- m.blendfunc2 = GL_ONE;
+
+ if(dq->flags == DRAWFLAG_ADDITIVE)
+ GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
+ else if(dq->flags == DRAWFLAG_MODULATE)
+ GL_BlendFunc(GL_DST_COLOR, GL_ZERO);
+ else if(dq->flags == DRAWFLAG_2XMODULATE)
+ GL_BlendFunc(GL_DST_COLOR,GL_SRC_COLOR);
else
- m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
- m.depthdisable = true;
+ GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+ GL_DepthMask(true);
+ GL_DepthTest(false);
- c[0] = (float) ((color >> 24) & 0xFF) * (1.0f / 255.0f) * r_colorscale;
- c[1] = (float) ((color >> 16) & 0xFF) * (1.0f / 255.0f) * r_colorscale;
- c[2] = (float) ((color >> 8) & 0xFF) * (1.0f / 255.0f) * r_colorscale;
+ c[0] = (float) ((color >> 24) & 0xFF) * (1.0f / 255.0f);
+ c[1] = (float) ((color >> 16) & 0xFF) * (1.0f / 255.0f);
+ c[2] = (float) ((color >> 8) & 0xFF) * (1.0f / 255.0f);
c[3] = (float) ( color & 0xFF) * (1.0f / 255.0f);
x = dq->x;
y = dq->y;
switch(dq->command)
{
case DRAWQUEUE_STRING:
+ GL_Color(c[0], c[1], c[2], c[3]);
str = (char *)(dq + 1);
if (strcmp("gfx/conchars", currentpic))
{
m.tex[0] = chartexnum;
}
batchcount = 0;
- at = texttexcoords;
- av = textverts;
- GL_Color(c[0], c[1], c[2], c[3]);
+ GL_VertexPointer(varray_vertex3f);
+ m.pointer_texcoord[0] = varray_texcoord2f[0];
+ R_Mesh_State_Texture(&m);
+ at = varray_texcoord2f[0];
+ av = varray_vertex3f;
while ((num = *str++) && x < vid.conwidth)
{
if (num != ' ')
batchcount++;
if (batchcount >= 128)
{
- if (gl_mesh_copyarrays.integer)
- {
- m.pointervertexcount = 0;
- m.pointer_vertex = NULL;
- m.pointer_texcoord[0] = NULL;
- m.pointer_color = NULL;
- R_Mesh_State(&m);
- R_Mesh_GetSpace(batchcount * 4);
- R_Mesh_CopyVertex3f(textverts, batchcount * 4);
- R_Mesh_CopyTexCoord2f(0, texttexcoords, batchcount * 4);
- }
- else
- {
- m.pointervertexcount = batchcount * 4;
- m.pointer_vertex = textverts;
- m.pointer_texcoord[0] = texttexcoords;
- m.pointer_color = NULL;
- R_Mesh_State(&m);
- }
R_Mesh_Draw(batchcount * 4, batchcount * 2, quadelements);
batchcount = 0;
- at = texttexcoords;
- av = textverts;
+ at = varray_texcoord2f[0];
+ av = varray_vertex3f;
}
}
x += w;
}
if (batchcount > 0)
- {
- if (gl_mesh_copyarrays.integer)
- {
- m.pointervertexcount = 0;
- m.pointer_vertex = NULL;
- m.pointer_texcoord[0] = NULL;
- m.pointer_color = NULL;
- R_Mesh_State(&m);
- R_Mesh_GetSpace(batchcount * 4);
- R_Mesh_CopyVertex3f(textverts, batchcount * 4);
- R_Mesh_CopyTexCoord2f(0, texttexcoords, batchcount * 4);
- }
- else
- {
- m.pointervertexcount = batchcount * 4;
- m.pointer_vertex = textverts;
- m.pointer_texcoord[0] = texttexcoords;
- m.pointer_color = NULL;
- R_Mesh_State(&m);
- }
R_Mesh_Draw(batchcount * 4, batchcount * 2, quadelements);
- }
break;
case DRAWQUEUE_MESH:
mesh = (void *)(dq + 1);
+ GL_VertexPointer(mesh->data_vertex3f);
+ GL_ColorPointer(mesh->data_color4f);
m.tex[0] = R_GetTexture(mesh->texture);
- GL_UseColorArray();
- if (gl_mesh_copyarrays.integer)
- {
- m.pointervertexcount = 0;
- m.pointer_vertex = NULL;
- m.pointer_texcoord[0] = NULL;
- m.pointer_color = NULL;
- R_Mesh_State(&m);
- R_Mesh_GetSpace(mesh->numvertices);
- R_Mesh_CopyVertex3f(mesh->vertex3f, mesh->numvertices);
- R_Mesh_CopyTexCoord2f(0, mesh->texcoord2f, mesh->numvertices);
- R_Mesh_CopyColor4f(mesh->color4f, mesh->numvertices);
- }
- else
+ m.pointer_texcoord[0] = mesh->data_texcoord2f;
+ R_Mesh_State_Texture(&m);
+ R_Mesh_Draw(mesh->num_vertices, mesh->num_triangles, mesh->data_element3i);
+ currentpic = "\0";
+ break;
+ case DRAWQUEUE_SETCLIP:
{
- m.pointervertexcount = mesh->numvertices;
- m.pointer_vertex = mesh->vertex3f;
- m.pointer_texcoord[0] = mesh->texcoord2f;
- m.pointer_color = mesh->color4f;
- R_Mesh_State(&m);
+ // We have to convert the con coords into real coords
+ int x , y, width, height;
+ x = dq->x * ((float)vid.realwidth / vid.conwidth);
+ // OGL uses top to bottom
+ y = dq->y * ((float) vid.realheight / vid.conheight);
+ width = dq->scalex * ((float)vid.realwidth / vid.conwidth);
+ height = dq->scaley * ((float)vid.realheight / vid.conheight);
+
+ GL_Scissor(x, y, width, height);
+
+ GL_ScissorTest(true);
}
- R_Mesh_Draw(mesh->numvertices, mesh->numtriangles, mesh->element3i);
- currentpic = "\0";
break;
+ case DRAWQUEUE_RESETCLIP:
+ GL_ScissorTest(false);
+ break;
}
}
{
// all the blends ignore depth
memset(&m, 0, sizeof(m));
- m.depthdisable = true;
+ R_Mesh_State_Texture(&m);
+ GL_DepthMask(true);
+ GL_DepthTest(false);
if (v_color_enable.integer)
{
c[0] = v_color_white_r.value;
}
else
c[0] = c[1] = c[2] = v_contrast.value;
- VectorScale(c, (float) (1 << v_overbrightbits.integer), c);
if (c[0] >= 1.01f || c[1] >= 1.01f || c[2] >= 1.01f)
{
- m.blendfunc1 = GL_DST_COLOR;
- m.blendfunc2 = GL_ONE;
- if (gl_mesh_copyarrays.integer)
- {
- R_Mesh_State(&m);
- R_Mesh_GetSpace(3);
- R_Mesh_CopyVertex3f(blendvertex3f, 3);
- }
- else
- {
- m.pointervertexcount = 3;
- m.pointer_vertex = blendvertex3f;
- R_Mesh_State(&m);
- }
+ GL_BlendFunc(GL_DST_COLOR, GL_ONE);
+ GL_VertexPointer(blendvertex3f);
while (c[0] >= 1.01f || c[1] >= 1.01f || c[2] >= 1.01f)
{
GL_Color(bound(0, c[0] - 1, 1), bound(0, c[1] - 1, 1), bound(0, c[2] - 1, 1), 1);
c[0] = c[1] = c[2] = v_brightness.value;
if (c[0] >= 0.01f || c[1] >= 0.01f || c[2] >= 0.01f)
{
- m.blendfunc1 = GL_ONE;
- m.blendfunc2 = GL_ONE;
- if (gl_mesh_copyarrays.integer)
- {
- m.pointervertexcount = 0;
- m.pointer_vertex = NULL;
- R_Mesh_State(&m);
- R_Mesh_GetSpace(3);
- R_Mesh_CopyVertex3f(blendvertex3f, 3);
- }
- else
- {
- m.pointervertexcount = 3;
- m.pointer_vertex = blendvertex3f;
- R_Mesh_State(&m);
- }
+ GL_BlendFunc(GL_ONE, GL_ONE);
+ GL_VertexPointer(blendvertex3f);
GL_Color(c[0], c[1], c[2], 1);
R_Mesh_Draw(3, 1, polygonelements);
}