int additive, texnum, orientation;
float org[3], up2[3], right2[3], v[3], right[3], up[3], fog, ifog, fogvec[3], cr, cg, cb, ca;
particletexture_t *tex;
- rmeshbufferinfo_t m;
+ rmeshstate_t m;
const particle_t *p = calldata1;
VectorCopy(p->org, org);
m.blendfunc2 = GL_ONE;
else
m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
- m.numtriangles = 2;
- m.numverts = 4;
m.tex[0] = R_GetTexture(particlefonttexture);
Matrix4x4_CreateIdentity(&m.matrix);
- if (R_Mesh_Draw_GetBuffer(&m, false))
+ R_Mesh_State(&m);
+
+ varray_element[0] = 0;
+ varray_element[1] = 1;
+ varray_element[2] = 2;
+ varray_element[3] = 0;
+ varray_element[4] = 2;
+ varray_element[5] = 3;
+ if (orientation == PARTICLE_BILLBOARD)
{
- m.index[0] = 0;
- m.index[1] = 1;
- m.index[2] = 2;
- m.index[3] = 0;
- m.index[4] = 2;
- m.index[5] = 3;
- if (orientation == PARTICLE_BILLBOARD)
- {
- VectorScale(vright, p->scalex, right);
- VectorScale(vup, p->scaley, up);
- }
- else if (orientation == PARTICLE_UPRIGHT_FACING)
- {
- v[0] = r_origin[0] - org[0];
- v[1] = r_origin[1] - org[1];
- v[2] = 0;
- VectorNormalizeFast(v);
- VectorVectors(v, right2, up2);
- VectorScale(right2, p->scalex, right);
- VectorScale(up2, p->scaley, up);
- }
- else if (orientation == PARTICLE_ORIENTED_DOUBLESIDED)
+ VectorScale(vright, p->scalex, right);
+ VectorScale(vup, p->scaley, up);
+ }
+ else if (orientation == PARTICLE_UPRIGHT_FACING)
+ {
+ v[0] = r_origin[0] - org[0];
+ v[1] = r_origin[1] - org[1];
+ v[2] = 0;
+ VectorNormalizeFast(v);
+ VectorVectors(v, right2, up2);
+ VectorScale(right2, p->scalex, right);
+ VectorScale(up2, p->scaley, up);
+ }
+ else if (orientation == PARTICLE_ORIENTED_DOUBLESIDED)
+ {
+ // double-sided
+ if (DotProduct(p->vel2, r_origin) > DotProduct(p->vel2, org))
{
- // double-sided
- if (DotProduct(p->vel2, r_origin) > DotProduct(p->vel2, org))
- {
- VectorNegate(p->vel2, v);
- VectorVectors(v, right, up);
- }
- else
- VectorVectors(p->vel2, right, up);
- VectorScale(right, p->scalex, right);
- VectorScale(up, p->scaley, up);
+ VectorNegate(p->vel2, v);
+ VectorVectors(v, right, up);
}
else
- Host_Error("R_DrawParticles: unknown particle orientation %i\n", orientation);
- m.vertex[0] = org[0] - right[0] - up[0];
- m.vertex[1] = org[1] - right[1] - up[1];
- m.vertex[2] = org[2] - right[2] - up[2];
- m.vertex[4] = org[0] - right[0] + up[0];
- m.vertex[5] = org[1] - right[1] + up[1];
- m.vertex[6] = org[2] - right[2] + up[2];
- m.vertex[8] = org[0] + right[0] + up[0];
- m.vertex[9] = org[1] + right[1] + up[1];
- m.vertex[10] = org[2] + right[2] + up[2];
- m.vertex[12] = org[0] + right[0] - up[0];
- m.vertex[13] = org[1] + right[1] - up[1];
- m.vertex[14] = org[2] + right[2] - up[2];
- tex = &particletexture[texnum];
- m.texcoords[0][0] = tex->s1;
- m.texcoords[0][1] = tex->t1;
- m.texcoords[0][2] = tex->s1;
- m.texcoords[0][3] = tex->t2;
- m.texcoords[0][4] = tex->s2;
- m.texcoords[0][5] = tex->t2;
- m.texcoords[0][6] = tex->s2;
- m.texcoords[0][7] = tex->t1;
- cr = p->color[0] * (1.0f / 255.0f);
- cg = p->color[1] * (1.0f / 255.0f);
- cb = p->color[2] * (1.0f / 255.0f);
- ca = p->alpha * (1.0f / 255.0f);
- if (fogenabled)
+ VectorVectors(p->vel2, right, up);
+ VectorScale(right, p->scalex, right);
+ VectorScale(up, p->scaley, up);
+ }
+ else
+ Host_Error("R_DrawParticles: unknown particle orientation %i\n", orientation);
+ varray_vertex[0] = org[0] - right[0] - up[0];
+ varray_vertex[1] = org[1] - right[1] - up[1];
+ varray_vertex[2] = org[2] - right[2] - up[2];
+ varray_vertex[4] = org[0] - right[0] + up[0];
+ varray_vertex[5] = org[1] - right[1] + up[1];
+ varray_vertex[6] = org[2] - right[2] + up[2];
+ varray_vertex[8] = org[0] + right[0] + up[0];
+ varray_vertex[9] = org[1] + right[1] + up[1];
+ varray_vertex[10] = org[2] + right[2] + up[2];
+ varray_vertex[12] = org[0] + right[0] - up[0];
+ varray_vertex[13] = org[1] + right[1] - up[1];
+ varray_vertex[14] = org[2] + right[2] - up[2];
+ tex = &particletexture[texnum];
+ varray_texcoord[0][0] = tex->s1;
+ varray_texcoord[0][1] = tex->t1;
+ varray_texcoord[0][2] = tex->s1;
+ varray_texcoord[0][3] = tex->t2;
+ varray_texcoord[0][4] = tex->s2;
+ varray_texcoord[0][5] = tex->t2;
+ varray_texcoord[0][6] = tex->s2;
+ varray_texcoord[0][7] = tex->t1;
+ cr = p->color[0] * (1.0f / 255.0f);
+ cg = p->color[1] * (1.0f / 255.0f);
+ cb = p->color[2] * (1.0f / 255.0f);
+ ca = p->alpha * (1.0f / 255.0f);
+ if (fogenabled)
+ {
+ VectorSubtract(org, r_origin, fogvec);
+ fog = exp(fogdensity/DotProduct(fogvec,fogvec));
+ ifog = 1 - fog;
+ cr = cr * ifog;
+ cg = cg * ifog;
+ cb = cb * ifog;
+ if (!additive)
{
- VectorSubtract(org, r_origin, fogvec);
- fog = exp(fogdensity/DotProduct(fogvec,fogvec));
- ifog = 1 - fog;
- cr = cr * ifog;
- cg = cg * ifog;
- cb = cb * ifog;
- if (!additive)
- {
- cr += fogcolor[0] * fog;
- cg += fogcolor[1] * fog;
- cb += fogcolor[2] * fog;
- }
+ cr += fogcolor[0] * fog;
+ cg += fogcolor[1] * fog;
+ cb += fogcolor[2] * fog;
}
- m.color[0] = m.color[4] = m.color[8] = m.color[12] = cr * m.colorscale;
- m.color[1] = m.color[5] = m.color[9] = m.color[13] = cg * m.colorscale;
- m.color[2] = m.color[6] = m.color[10] = m.color[14] = cb * m.colorscale;
- m.color[3] = m.color[7] = m.color[11] = m.color[15] = ca;
- R_Mesh_Render();
}
+ varray_color[0] = varray_color[4] = varray_color[8] = varray_color[12] = cr * mesh_colorscale;
+ varray_color[1] = varray_color[5] = varray_color[9] = varray_color[13] = cg * mesh_colorscale;
+ varray_color[2] = varray_color[6] = varray_color[10] = varray_color[14] = cb * mesh_colorscale;
+ varray_color[3] = varray_color[7] = varray_color[11] = varray_color[15] = ca;
+ R_Mesh_Draw(4, 2);
}
void R_DrawParticles (void)
void SCR_ScreenShot_f (void);
-static int max_tris;
-static int max_verts; // always max_tris * 3
+// these are externally accessible
+float mesh_colorscale;
+int *varray_element;
+float *varray_vertex;
+float *varray_color;
+float *varray_texcoord[MAX_TEXTUREUNITS];
+int mesh_maxtris;
+int mesh_maxverts; // always mesh_maxtris * 3
-typedef struct buf_mesh_s
-{
- int depthmask;
- int depthtest;
- int blendfunc1, blendfunc2;
- int textures[MAX_TEXTUREUNITS];
- int texturergbscale[MAX_TEXTUREUNITS];
- int triangles;
- int verts;
- matrix4x4_t matrix;
- struct buf_mesh_s *chain;
-}
-buf_mesh_t;
+static matrix4x4_t backendmatrix;
-typedef struct buf_tri_s
-{
- int index[3];
-}
-buf_tri_t;
+static int backendunits, backendactive;
+static qbyte *varray_bcolor;
+static mempool_t *gl_backend_mempool;
-typedef struct
+void GL_Backend_AllocArrays(void)
{
- float v[4];
-}
-buf_vertex_t;
+ int i;
-typedef struct
-{
- float c[4];
-}
-buf_fcolor_t;
+ if (!gl_backend_mempool)
+ gl_backend_mempool = Mem_AllocPool("GL_Backend");
-typedef struct
-{
- qbyte c[4];
+ mesh_maxverts = mesh_maxtris * 3;
+
+ varray_element = Mem_Alloc(gl_backend_mempool, mesh_maxtris * sizeof(int[3]));
+ varray_vertex = Mem_Alloc(gl_backend_mempool, mesh_maxverts * sizeof(float[4]));
+ varray_color = Mem_Alloc(gl_backend_mempool, mesh_maxverts * sizeof(float[4]));
+ varray_bcolor = Mem_Alloc(gl_backend_mempool, mesh_maxverts * sizeof(qbyte[4]));
+ for (i = 0;i < backendunits;i++)
+ varray_texcoord[i] = Mem_Alloc(gl_backend_mempool, mesh_maxverts * sizeof(float[2]));
+ for (;i < MAX_TEXTUREUNITS;i++)
+ varray_texcoord[i] = NULL;
}
-buf_bcolor_t;
-typedef struct
+void GL_Backend_FreeArrays(int resizingbuffers)
{
- float t[2];
+ int i;
+ if (resizingbuffers)
+ Mem_EmptyPool(gl_backend_mempool);
+ else
+ Mem_FreePool(&gl_backend_mempool);
+ varray_element = NULL;
+ varray_vertex = NULL;
+ varray_color = NULL;
+ varray_bcolor = NULL;
+ for (i = 0;i < MAX_TEXTUREUNITS;i++)
+ varray_texcoord[i] = NULL;
}
-buf_texcoord_t;
-
-static int backendunits, backendactive;
-static buf_mesh_t buf_mesh;
-static buf_tri_t *buf_tri;
-static buf_vertex_t *buf_vertex;
-static buf_fcolor_t *buf_fcolor;
-static buf_bcolor_t *buf_bcolor;
-static buf_texcoord_t *buf_texcoord[MAX_TEXTUREUNITS];
-
-static mempool_t *gl_backend_mempool;
-static int resizingbuffers = false;
static void gl_backend_start(void)
{
- int i;
-
- qglGetIntegerv(GL_MAX_ELEMENTS_VERTICES, &gl_maxdrawrangeelementsvertices);
- qglGetIntegerv(GL_MAX_ELEMENTS_INDICES, &gl_maxdrawrangeelementsindices);
-
Con_Printf("OpenGL Backend started with gl_mesh_maxtriangles %i\n", gl_mesh_maxtriangles.integer);
if (qglDrawRangeElements != NULL)
+ {
+ qglGetIntegerv(GL_MAX_ELEMENTS_VERTICES, &gl_maxdrawrangeelementsvertices);
+ qglGetIntegerv(GL_MAX_ELEMENTS_INDICES, &gl_maxdrawrangeelementsindices);
+ CHECKGLERROR
Con_Printf("glDrawRangeElements detected (max vertices %i, max indices %i)\n", gl_maxdrawrangeelementsvertices, gl_maxdrawrangeelementsindices);
+ }
if (strstr(gl_renderer, "3Dfx"))
{
Con_Printf("3Dfx driver detected, forcing gl_mesh_floatcolors to 0 to prevent crashs\n");
Cvar_SetValueQuick(&gl_mesh_floatcolors, 0);
}
- Con_Printf("\n");
-
- max_verts = max_tris * 3;
-
- if (!gl_backend_mempool)
- gl_backend_mempool = Mem_AllocPool("GL_Backend");
-#define BACKENDALLOC(var, count, sizeofstruct, varname)\
- {\
- var = Mem_Alloc(gl_backend_mempool, count * sizeof(sizeofstruct));\
- if (var == NULL)\
- Sys_Error("gl_backend_start: unable to allocate memory for %s (%d bytes)\n", (varname), count * sizeof(sizeofstruct));\
- memset(var, 0, count * sizeof(sizeofstruct));\
- }
+ backendunits = min(MAX_TEXTUREUNITS, gl_textureunits);
- BACKENDALLOC(buf_tri, max_tris, buf_tri_t, "buf_tri")
- BACKENDALLOC(buf_vertex, max_verts, buf_vertex_t, "buf_vertex")
- BACKENDALLOC(buf_fcolor, max_verts, buf_fcolor_t, "buf_fcolor")
- BACKENDALLOC(buf_bcolor, max_verts, buf_bcolor_t, "buf_bcolor")
+ GL_Backend_AllocArrays();
- for (i = 0;i < MAX_TEXTUREUNITS;i++)
- {
- // only allocate as many texcoord arrays as we need
- if (i < gl_textureunits)
- {
- BACKENDALLOC(buf_texcoord[i], max_verts, buf_texcoord_t, va("buf_texcoord[%d]", i))
- }
- else
- {
- buf_texcoord[i] = NULL;
- }
- }
- backendunits = min(MAX_TEXTUREUNITS, gl_textureunits);
backendactive = true;
}
static void gl_backend_shutdown(void)
{
- Con_Printf("OpenGL Backend shutting down\n");
-
- if (resizingbuffers)
- Mem_EmptyPool(gl_backend_mempool);
- else
- Mem_FreePool(&gl_backend_mempool);
-
backendunits = 0;
backendactive = false;
+
+ Con_Printf("OpenGL Backend shutting down\n");
+
+ GL_Backend_FreeArrays(false);
}
-static void gl_backend_bufferchanges(int init)
+void GL_Backend_CheckCvars(void)
{
- if (overflowedverts > gl_mesh_maxtriangles.integer * 3)
- Cvar_SetValueQuick(&gl_mesh_maxtriangles, (int) ((overflowedverts + 2) / 3));
- overflowedverts = 0;
-
if (gl_mesh_drawmode.integer < 0)
Cvar_SetValueQuick(&gl_mesh_drawmode, 0);
if (gl_mesh_drawmode.integer > 3)
Cvar_SetValueQuick(&gl_mesh_drawmode, 3);
+ // change drawmode 3 to 2 if 3 won't work
if (gl_mesh_drawmode.integer >= 3 && qglDrawRangeElements == NULL)
- {
- // change drawmode 3 to 2 if 3 won't work at all
Cvar_SetValueQuick(&gl_mesh_drawmode, 2);
- }
// 21760 is (65536 / 3) rounded off to a multiple of 128
if (gl_mesh_maxtriangles.integer < 1024)
Cvar_SetValueQuick(&gl_mesh_maxtriangles, 1024);
if (gl_mesh_maxtriangles.integer > 21760)
Cvar_SetValueQuick(&gl_mesh_maxtriangles, 21760);
+}
- if (max_tris != gl_mesh_maxtriangles.integer)
- {
- max_tris = gl_mesh_maxtriangles.integer;
-
- if (!init)
- {
- resizingbuffers = true;
- gl_backend_shutdown();
- gl_backend_start();
- resizingbuffers = false;
- }
- }
+void GL_Backend_ResizeArrays(int numtriangles)
+{
+ Cvar_SetValueQuick(&gl_mesh_maxtriangles, numtriangles);
+ GL_Backend_CheckCvars();
+ mesh_maxtris = gl_mesh_maxtriangles.integer;
+ GL_Backend_FreeArrays(true);
+ GL_Backend_AllocArrays();
}
static void gl_backend_newmap(void)
Cvar_RegisterVariable(&gl_mesh_maxtriangles);
Cvar_RegisterVariable(&gl_mesh_floatcolors);
Cvar_RegisterVariable(&gl_mesh_drawmode);
+ GL_Backend_CheckCvars();
R_RegisterModule("GL_Backend", gl_backend_start, gl_backend_shutdown, gl_backend_newmap);
- gl_backend_bufferchanges(true);
}
int arraylocked = false;
int blendfunc2;
int blend;
GLboolean depthmask;
- int depthtest;
+ int depthdisable;
int unit;
int clientunit;
int texture[MAX_TEXTUREUNITS];
if (gl_mesh_drawmode.integer > 0)
{
qglClientActiveTexture(GL_TEXTURE0_ARB + (gl_state.clientunit = i));CHECKGLERROR
- qglTexCoordPointer(2, GL_FLOAT, sizeof(buf_texcoord_t), buf_texcoord[i]);CHECKGLERROR
+ qglTexCoordPointer(2, GL_FLOAT, sizeof(float[2]), varray_texcoord[i]);CHECKGLERROR
if (gl_state.texture[i])
{
qglEnableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
}
if (gl_mesh_drawmode.integer > 0)
{
- qglTexCoordPointer(2, GL_FLOAT, sizeof(buf_texcoord_t), buf_texcoord[0]);CHECKGLERROR
+ qglTexCoordPointer(2, GL_FLOAT, sizeof(float[2]), varray_texcoord[0]);CHECKGLERROR
if (gl_state.texture[0])
{
qglEnableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
}
}
-// called at beginning of frame
int usedarrays;
-void R_Mesh_Start(float farclip)
+void GL_Backend_ResetState(void)
{
int i;
- if (!backendactive)
- Sys_Error("R_Mesh_Clear: called when backend is not active\n");
-
- CHECKGLERROR
-
- gl_backend_bufferchanges(false);
-
- r_mesh_farclip = farclip;
- viewdist = DotProduct(r_origin, vpn);
- vpnbit0 = vpn[0] < 0;
- vpnbit1 = vpn[1] < 0;
- vpnbit2 = vpn[2] < 0;
-
- c_meshs = 0;
- c_meshtris = 0;
-
- GL_SetupFrame();
-
gl_state.unit = 0;
gl_state.clientunit = 0;
qglEnable(GL_CULL_FACE);CHECKGLERROR
qglCullFace(GL_FRONT);CHECKGLERROR
- gl_state.depthtest = true;
+ gl_state.depthdisable = false;
qglEnable(GL_DEPTH_TEST);CHECKGLERROR
gl_state.blendfunc1 = GL_ONE;
if (gl_mesh_drawmode.integer > 0)
{
usedarrays = true;
- qglVertexPointer(3, GL_FLOAT, sizeof(buf_vertex_t), &buf_vertex[0].v[0]);CHECKGLERROR
+ qglVertexPointer(3, GL_FLOAT, sizeof(float[4]), varray_vertex);CHECKGLERROR
qglEnableClientState(GL_VERTEX_ARRAY);CHECKGLERROR
if (gl_mesh_floatcolors.integer)
{
- qglColorPointer(4, GL_FLOAT, sizeof(buf_fcolor_t), &buf_fcolor[0].c[0]);CHECKGLERROR
+ qglColorPointer(4, GL_FLOAT, sizeof(float[4]), varray_color);CHECKGLERROR
}
else
{
- qglColorPointer(4, GL_UNSIGNED_BYTE, sizeof(buf_bcolor_t), &buf_bcolor[0].c[0]);CHECKGLERROR
+ qglColorPointer(4, GL_UNSIGNED_BYTE, sizeof(qbyte[4]), varray_bcolor);CHECKGLERROR
}
qglEnableClientState(GL_COLOR_ARRAY);CHECKGLERROR
}
GL_SetupTextureState();
}
+// called at beginning of frame
+void R_Mesh_Start(float farclip)
+{
+ if (!backendactive)
+ Sys_Error("R_Mesh_Clear: called when backend is not active\n");
+
+ CHECKGLERROR
+
+ r_mesh_farclip = farclip;
+ viewdist = DotProduct(r_origin, vpn);
+ vpnbit0 = vpn[0] < 0;
+ vpnbit1 = vpn[1] < 0;
+ vpnbit2 = vpn[2] < 0;
+
+ c_meshs = 0;
+ c_meshtris = 0;
+
+ GL_Backend_CheckCvars();
+ if (mesh_maxtris != gl_mesh_maxtriangles.integer)
+ GL_Backend_ResizeArrays(gl_mesh_maxtriangles.integer);
+
+ GL_SetupFrame();
+
+ GL_Backend_ResetState();
+}
+
int gl_backend_rebindtextures;
void GL_ConvertColorsFloatToByte(int numverts)
total = numverts * 4;
// shift float to have 8bit fraction at base of number
- fcolor = &buf_fcolor->c[0];
+ fcolor = varray_color;
for (i = 0;i < total;)
{
fcolor[i ] += 32768.0f;
}
// then read as integer and kill float bits...
- icolor = (int *)&buf_fcolor->c[0];
- bcolor = &buf_bcolor->c[0];
+ icolor = (int *)varray_color;
+ bcolor = varray_bcolor;
for (i = 0;i < total;)
{
k = icolor[i ] & 0x7FFFFF;if (k > 255) k = 255;bcolor[i ] = (qbyte) k;
{
int i;
float m[12], tempv[4], *v;
- m[0] = buf_mesh.matrix.m[0][0];
- m[1] = buf_mesh.matrix.m[0][1];
- m[2] = buf_mesh.matrix.m[0][2];
- m[3] = buf_mesh.matrix.m[0][3];
- m[4] = buf_mesh.matrix.m[1][0];
- m[5] = buf_mesh.matrix.m[1][1];
- m[6] = buf_mesh.matrix.m[1][2];
- m[7] = buf_mesh.matrix.m[1][3];
- m[8] = buf_mesh.matrix.m[2][0];
- m[9] = buf_mesh.matrix.m[2][1];
- m[10] = buf_mesh.matrix.m[2][2];
- m[11] = buf_mesh.matrix.m[2][3];
- for (i = 0, v = buf_vertex[0].v;i < numverts;i++, v += 4)
+ m[0] = backendmatrix.m[0][0];
+ m[1] = backendmatrix.m[0][1];
+ m[2] = backendmatrix.m[0][2];
+ m[3] = backendmatrix.m[0][3];
+ m[4] = backendmatrix.m[1][0];
+ m[5] = backendmatrix.m[1][1];
+ m[6] = backendmatrix.m[1][2];
+ m[7] = backendmatrix.m[1][3];
+ m[8] = backendmatrix.m[2][0];
+ m[9] = backendmatrix.m[2][1];
+ m[10] = backendmatrix.m[2][2];
+ m[11] = backendmatrix.m[2][3];
+ for (i = 0, v = varray_vertex;i < numverts;i++, v += 4)
{
VectorCopy(v, tempv);
v[0] = tempv[0] * m[0] + tempv[1] * m[1] + tempv[2] * m[2] + m[3];
}
}
-void GL_MeshState(void)
-{
- int i;
- if (backendunits > 1)
- {
- for (i = 0;i < backendunits;i++)
- {
- if (gl_state.texture[i] != buf_mesh.textures[i])
- {
- if (gl_state.unit != i)
- {
- qglActiveTexture(GL_TEXTURE0_ARB + (gl_state.unit = i));CHECKGLERROR
- }
- if (gl_state.texture[i] == 0)
- {
- qglEnable(GL_TEXTURE_2D);CHECKGLERROR
- // have to disable texcoord array on disabled texture
- // units due to NVIDIA driver bug with
- // compiled_vertex_array
- if (gl_state.clientunit != i)
- {
- qglClientActiveTexture(GL_TEXTURE0_ARB + (gl_state.clientunit = i));CHECKGLERROR
- }
- qglEnableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
- }
- qglBindTexture(GL_TEXTURE_2D, (gl_state.texture[i] = buf_mesh.textures[i]));CHECKGLERROR
- if (gl_state.texture[i] == 0)
- {
- qglDisable(GL_TEXTURE_2D);CHECKGLERROR
- // have to disable texcoord array on disabled texture
- // units due to NVIDIA driver bug with
- // compiled_vertex_array
- if (gl_state.clientunit != i)
- {
- qglClientActiveTexture(GL_TEXTURE0_ARB + (gl_state.clientunit = i));CHECKGLERROR
- }
- qglDisableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
- }
- }
- if (gl_state.texturergbscale[i] != buf_mesh.texturergbscale[i])
- {
- if (gl_state.unit != i)
- {
- qglActiveTexture(GL_TEXTURE0_ARB + (gl_state.unit = i));CHECKGLERROR
- }
- qglTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, (gl_state.texturergbscale[i] = buf_mesh.texturergbscale[i]));CHECKGLERROR
- }
- }
- }
- else
- {
- if (gl_state.texture[0] != buf_mesh.textures[0])
- {
- if (gl_state.texture[0] == 0)
- {
- qglEnable(GL_TEXTURE_2D);CHECKGLERROR
- qglEnableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
- }
- qglBindTexture(GL_TEXTURE_2D, (gl_state.texture[0] = buf_mesh.textures[0]));CHECKGLERROR
- if (gl_state.texture[0] == 0)
- {
- qglDisable(GL_TEXTURE_2D);CHECKGLERROR
- qglDisableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
- }
- }
- }
- if (gl_state.blendfunc1 != buf_mesh.blendfunc1 || gl_state.blendfunc2 != buf_mesh.blendfunc2)
- {
- qglBlendFunc(gl_state.blendfunc1 = buf_mesh.blendfunc1, gl_state.blendfunc2 = buf_mesh.blendfunc2);CHECKGLERROR
- if (gl_state.blendfunc2 == GL_ZERO)
- {
- if (gl_state.blendfunc1 == GL_ONE)
- {
- if (gl_state.blend)
- {
- gl_state.blend = 0;
- qglDisable(GL_BLEND);CHECKGLERROR
- }
- }
- else
- {
- if (!gl_state.blend)
- {
- gl_state.blend = 1;
- qglEnable(GL_BLEND);CHECKGLERROR
- }
- }
- }
- else
- {
- if (!gl_state.blend)
- {
- gl_state.blend = 1;
- qglEnable(GL_BLEND);CHECKGLERROR
- }
- }
- }
- if (gl_state.depthtest != buf_mesh.depthtest)
- {
- gl_state.depthtest = buf_mesh.depthtest;
- if (gl_state.depthtest)
- qglEnable(GL_DEPTH_TEST);
- else
- qglDisable(GL_DEPTH_TEST);
- }
- if (gl_state.depthmask != buf_mesh.depthmask)
- {
- qglDepthMask(gl_state.depthmask = buf_mesh.depthmask);CHECKGLERROR
- }
-}
-
void GL_DrawRangeElements(int firstvert, int endvert, int indexcount, GLuint *index)
{
unsigned int i, j, in;
+ qbyte *c;
+ float *v;
+ GL_LockArray(firstvert, endvert - firstvert);
if (gl_mesh_drawmode.integer >= 3/* && (endvert - firstvert) <= gl_maxdrawrangeelementsvertices && (indexcount) <= gl_maxdrawrangeelementsindices*/)
{
// GL 1.2 or GL 1.1 with extension
qglDrawRangeElements(GL_TRIANGLES, firstvert, endvert, indexcount, GL_UNSIGNED_INT, index);
+ CHECKGLERROR
}
else if (gl_mesh_drawmode.integer >= 2)
{
// GL 1.1
qglDrawElements(GL_TRIANGLES, indexcount, GL_UNSIGNED_INT, index);
+ CHECKGLERROR
}
else if (gl_mesh_drawmode.integer >= 1)
{
for (i = 0;i < indexcount;i++)
qglArrayElement(index[i]);
qglEnd();
+ CHECKGLERROR
}
else
{
for (i = 0;i < indexcount;i++)
{
in = index[i];
- qglColor4ub(buf_bcolor[in].c[0], buf_bcolor[in].c[1], buf_bcolor[in].c[2], buf_bcolor[in].c[3]);
+ c = varray_bcolor + in * 4;
+ qglColor4ub(c[0], c[1], c[2], c[3]);
for (j = 0;j < backendunits;j++)
+ {
if (gl_state.texture[j])
- qglMultiTexCoord2f(GL_TEXTURE0_ARB + j, buf_texcoord[j][in].t[0], buf_texcoord[j][in].t[1]);
- qglVertex3f(buf_vertex[in].v[0], buf_vertex[in].v[1], buf_vertex[in].v[2]);
+ {
+ v = varray_texcoord[j] + in * 2;
+ qglMultiTexCoord2f(GL_TEXTURE0_ARB + j, v[0], v[1]);
+ }
+ }
+ v = varray_vertex + in * 4;
+ qglVertex3f(v[0], v[1], v[2]);
}
}
else
for (i = 0;i < indexcount;i++)
{
in = index[i];
- qglColor4ub(buf_bcolor[in].c[0], buf_bcolor[in].c[1], buf_bcolor[in].c[2], buf_bcolor[in].c[3]);
+ c = varray_bcolor + in * 4;
+ qglColor4ub(c[0], c[1], c[2], c[3]);
if (gl_state.texture[0])
- qglTexCoord2f(buf_texcoord[0][in].t[0], buf_texcoord[0][in].t[1]);
- qglVertex3f(buf_vertex[in].v[0], buf_vertex[in].v[1], buf_vertex[in].v[2]);
+ {
+ v = varray_texcoord[j] + in * 2;
+ qglTexCoord2f(v[0], v[1]);
+ }
+ v = varray_vertex + in * 4;
+ qglVertex3f(v[0], v[1], v[2]);
}
}
qglEnd();
+ CHECKGLERROR
+ }
+ GL_UnlockArray();
+}
+
+// enlarges geometry buffers if they are too small
+void _R_Mesh_ResizeCheck(int numverts, int numtriangles)
+{
+ if (numtriangles > mesh_maxtris || numverts > mesh_maxverts)
+ {
+ if (!backendactive)
+ Sys_Error("R_Mesh_Begin: called when backend is not active\n");
+ GL_Backend_ResizeArrays(max(numtriangles, (numverts + 2) / 3) + 100);
+ GL_Backend_ResetState();
}
}
-// renders mesh buffers, called to flush buffers when full
-void R_Mesh_Render(void)
+// renders the mesh
+void R_Mesh_Draw(int numverts, int numtriangles)
{
if (!backendactive)
- Sys_Error("R_Mesh_Render: called when backend is not active\n");
+ Sys_Error("R_Mesh_End: called when backend is not active\n");
- if (!r_render.integer)
- return;
+ c_meshs++;
+ c_meshtris += numtriangles;
CHECKGLERROR
// drawmode 0 always uses byte colors
if (!gl_mesh_floatcolors.integer || gl_mesh_drawmode.integer <= 0)
- GL_ConvertColorsFloatToByte(buf_mesh.verts);
- GL_TransformVertices(buf_mesh.verts);
- GL_LockArray(0, buf_mesh.verts);CHECKGLERROR
- GL_DrawRangeElements(0, buf_mesh.verts, buf_mesh.triangles * 3, &buf_tri[0].index[0]);CHECKGLERROR
- GL_UnlockArray();CHECKGLERROR
+ GL_ConvertColorsFloatToByte(numverts);
+ GL_TransformVertices(numverts);
+ if (!r_render.integer)
+ return;
+ GL_DrawRangeElements(0, numverts, numtriangles * 3, varray_element);
}
// restores backend state, used when done with 3D rendering
R_Mesh_Start(r_mesh_farclip);
}
-// allocates space in geometry buffers, and fills in pointers to the buffers in passsed struct
-// (this is used for very high speed rendering, no copying)
-int R_Mesh_Draw_GetBuffer(rmeshbufferinfo_t *m, int wantoverbright)
+// sets up the requested state
+void R_Mesh_State(const rmeshstate_t *m)
{
- // these are static because gcc runs out of virtual registers otherwise
- int i, j, overbright;
+ int i, overbright;
+ int texturergbscale[MAX_TEXTUREUNITS];
float scaler;
if (!backendactive)
- Sys_Error("R_Mesh_Draw_GetBuffer: called when backend is not active\n");
+ Sys_Error("R_Mesh_State: called when backend is not active\n");
- if (!m->numtriangles
- || !m->numverts)
- Host_Error("R_Mesh_Draw_GetBuffer: no triangles or verts\n");
-
- i = max(m->numtriangles * 3, m->numverts);
- if (overflowedverts < i)
- overflowedverts = i;
-
- if (m->numtriangles > max_tris || m->numverts > max_verts)
+ if (gl_backend_rebindtextures)
{
- Con_Printf("R_Mesh_Draw_GetBuffer: mesh too big for current gl_mesh_maxtriangles setting, increasing limits\n");
- return false;
+ gl_backend_rebindtextures = false;
+ GL_SetupTextureState();
}
- c_meshs++;
- c_meshtris += m->numtriangles;
- m->index = &buf_tri[0].index[0];
- m->vertex = &buf_vertex[0].v[0];
- m->color = &buf_fcolor[0].c[0];
- for (i = 0;i < backendunits;i++)
- m->texcoords[i] = &buf_texcoord[i][0].t[0];
-
- buf_mesh.blendfunc1 = m->blendfunc1;
- buf_mesh.blendfunc2 = m->blendfunc2;
- buf_mesh.depthmask = (m->blendfunc2 == GL_ZERO || m->depthwrite);
- buf_mesh.depthtest = !m->depthdisable;
- buf_mesh.triangles = m->numtriangles;
- buf_mesh.verts = m->numverts;
- buf_mesh.matrix = m->matrix; // this copies the struct
+ backendmatrix = m->matrix; // this copies the struct
overbright = false;
scaler = 1;
{
if (m->tex[0])
{
- overbright = wantoverbright && gl_combine.integer;
+ overbright = m->wantoverbright && gl_combine.integer;
if (overbright)
scaler *= 0.25f;
}
scaler *= overbrightscale;
}
- m->colorscale = scaler;
+ mesh_colorscale = scaler;
- j = -1;
- for (i = 0;i < MAX_TEXTUREUNITS;i++)
+ if (gl_state.blendfunc1 != m->blendfunc1 || gl_state.blendfunc2 != m->blendfunc2)
{
- if ((buf_mesh.textures[i] = m->tex[i]))
+ qglBlendFunc(gl_state.blendfunc1 = m->blendfunc1, gl_state.blendfunc2 = m->blendfunc2);CHECKGLERROR
+ if (gl_state.blendfunc2 == GL_ZERO)
+ {
+ if (gl_state.blendfunc1 == GL_ONE)
+ {
+ if (gl_state.blend)
+ {
+ gl_state.blend = 0;
+ qglDisable(GL_BLEND);CHECKGLERROR
+ }
+ }
+ else
+ {
+ if (!gl_state.blend)
+ {
+ gl_state.blend = 1;
+ qglEnable(GL_BLEND);CHECKGLERROR
+ }
+ }
+ }
+ else
{
- j = i;
- if (i >= backendunits)
- Sys_Error("R_Mesh_Draw_GetBuffer: texture %i supplied when there are only %i texture units\n", j + 1, backendunits);
+ if (!gl_state.blend)
+ {
+ gl_state.blend = 1;
+ qglEnable(GL_BLEND);CHECKGLERROR
+ }
}
- buf_mesh.texturergbscale[i] = m->texrgbscale[i];
- if (buf_mesh.texturergbscale[i] != 1 && buf_mesh.texturergbscale[i] != 2 && buf_mesh.texturergbscale[i] != 4)
- buf_mesh.texturergbscale[i] = 1;
}
- if (overbright && j >= 0)
- buf_mesh.texturergbscale[j] = 4;
-
- if (gl_backend_rebindtextures)
+ if (gl_state.depthdisable != m->depthdisable)
{
- gl_backend_rebindtextures = false;
- GL_SetupTextureState();
+ gl_state.depthdisable = m->depthdisable;
+ if (gl_state.depthdisable)
+ qglDisable(GL_DEPTH_TEST);
+ else
+ qglEnable(GL_DEPTH_TEST);
+ }
+ if (gl_state.depthmask != (m->blendfunc2 == GL_ZERO || m->depthwrite))
+ {
+ qglDepthMask(gl_state.depthmask = (m->blendfunc2 == GL_ZERO || m->depthwrite));CHECKGLERROR
}
- GL_MeshState();
+ for (i = 0;i < backendunits;i++)
+ {
+ if (m->texrgbscale[i])
+ texturergbscale[i] = m->texrgbscale[i];
+ else
+ texturergbscale[i] = 1;
+ }
+ if (overbright)
+ for (i = backendunits - 1;i >= 0;i--)
+ if (m->tex[i])
+ texturergbscale[i] = 4;
- return true;
+ if (backendunits > 1)
+ {
+ for (i = 0;i < backendunits;i++)
+ {
+ if (gl_state.texture[i] != m->tex[i])
+ {
+ if (gl_state.unit != i)
+ {
+ qglActiveTexture(GL_TEXTURE0_ARB + (gl_state.unit = i));CHECKGLERROR
+ }
+ if (gl_state.texture[i] == 0)
+ {
+ qglEnable(GL_TEXTURE_2D);CHECKGLERROR
+ if (gl_state.clientunit != i)
+ {
+ qglClientActiveTexture(GL_TEXTURE0_ARB + (gl_state.clientunit = i));CHECKGLERROR
+ }
+ qglEnableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
+ }
+ qglBindTexture(GL_TEXTURE_2D, (gl_state.texture[i] = m->tex[i]));CHECKGLERROR
+ if (gl_state.texture[i] == 0)
+ {
+ qglDisable(GL_TEXTURE_2D);CHECKGLERROR
+ if (gl_state.clientunit != i)
+ {
+ qglClientActiveTexture(GL_TEXTURE0_ARB + (gl_state.clientunit = i));CHECKGLERROR
+ }
+ qglDisableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
+ }
+ }
+ if (gl_state.texturergbscale[i] != texturergbscale[i])
+ {
+ if (gl_state.unit != i)
+ {
+ qglActiveTexture(GL_TEXTURE0_ARB + (gl_state.unit = i));CHECKGLERROR
+ }
+ qglTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, (gl_state.texturergbscale[i] = texturergbscale[i]));CHECKGLERROR
+ }
+ }
+ }
+ else
+ {
+ if (gl_state.texture[0] != m->tex[0])
+ {
+ if (gl_state.texture[0] == 0)
+ {
+ qglEnable(GL_TEXTURE_2D);CHECKGLERROR
+ qglEnableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
+ }
+ qglBindTexture(GL_TEXTURE_2D, (gl_state.texture[0] = m->tex[0]));CHECKGLERROR
+ if (gl_state.texture[0] == 0)
+ {
+ qglDisable(GL_TEXTURE_2D);CHECKGLERROR
+ qglDisableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
+ }
+ }
+ }
}
/*
#define MAX_TEXTUREUNITS 8
-extern int c_meshtris, c_meshs, c_transtris, c_transmeshs;
+extern int c_meshtris, c_meshs;
typedef struct
{
int depthdisable; // disable depth read/write entirely
int blendfunc1;
int blendfunc2;
- int numtriangles;
- int numverts;
+ int wantoverbright;
int tex[MAX_TEXTUREUNITS];
int texrgbscale[MAX_TEXTUREUNITS]; // used only if COMBINE is present
matrix4x4_t matrix; // model to world transform matrix
-
- // output
- int *index;
- float *vertex;
- float *color;
- float colorscale;
- float *texcoords[MAX_TEXTUREUNITS];
}
-rmeshbufferinfo_t;
+rmeshstate_t;
+
+// overbright rendering scale for the current state
+extern float mesh_colorscale;
+extern int *varray_element;
+extern float *varray_vertex;
+extern float *varray_color;
+extern float *varray_texcoord[MAX_TEXTUREUNITS];
+extern int mesh_maxverts;
+extern int mesh_maxtris;
// adds console variables and registers the render module (only call from GL_Init)
void gl_backend_init(void);
// (only valid between R_Mesh_Start and R_Mesh_Finish)
void R_Mesh_ClearDepth(void);
-// renders current batch of meshs
-// (only valid between R_Mesh_Start and R_Mesh_Finish)
-void R_Mesh_Render(void);
+// sets up the requested state
+void R_Mesh_State(const rmeshstate_t *m);
-// allocates space in geometry buffers, and fills in pointers to the buffers in passsed struct
-// (it is up to the caller to fill in the geometry data)
-// (make sure you scale your colors by the colorscale field)
-// (only valid between R_Mesh_Start and R_Mesh_Finish)
-int R_Mesh_Draw_GetBuffer(rmeshbufferinfo_t *m, int wantoverbright);
+// enlarges geometry buffers if they are too small
+#define R_Mesh_ResizeCheck(numverts, numtriangles) if ((numverts) > mesh_maxverts || (numtriangles) > mesh_maxtris) _R_Mesh_ResizeCheck(numverts, numtriangles);
+void _R_Mesh_ResizeCheck(int numverts, int numtriangles);
+
+// renders the mesh in the varray_* buffers
+void R_Mesh_Draw(int numverts, int numtriangles);
// saves a section of the rendered frame to a .tga file
qboolean SCR_ScreenShot(char *filename, int x, int y, int width, int height);
float fog;
vec3_t diff;
qbyte *bcolor;
- rmeshbufferinfo_t m;
+ rmeshstate_t m;
model_t *model;
skinframe_t *skinframe;
const entity_render_t *ent = calldata1;
}
model = ent->model;
+ R_Mesh_ResizeCheck(model->numverts, model->numtris);
skinframe = R_FetchSkinFrame(ent);
memset(&m, 0, sizeof(m));
m.blendfunc1 = blendfunc1;
m.blendfunc2 = blendfunc2;
- m.numtriangles = model->numtris;
- m.numverts = model->numverts;
+ m.wantoverbright = true;
m.tex[0] = R_GetTexture(r_notexture);
m.matrix = ent->matrix;
-
- c_alias_polys += m.numtriangles;
- if (R_Mesh_Draw_GetBuffer(&m, true))
- {
- memcpy(m.index, model->mdlmd2data_indices, m.numtriangles * sizeof(int[3]));
- for (i = 0;i < m.numverts * 2;i++)
- m.texcoords[0][i] = model->mdlmd2data_texcoords[i] * 8.0f;
-
- aliasvert = m.vertex;
- aliasvertcolor = m.color;
- R_SetupMDLMD2Frames(ent, m.colorscale, m.colorscale, m.colorscale);
- aliasvert = aliasvertbuf;
- aliasvertcolor = aliasvertcolorbuf;
-
- R_Mesh_Render();
- }
+ R_Mesh_State(&m);
+
+ c_alias_polys += model->numtris;
+ memcpy(varray_element, model->mdlmd2data_indices, model->numtris * sizeof(int[3]));
+ for (i = 0;i < model->numverts * 2;i++)
+ varray_texcoord[0][i] = model->mdlmd2data_texcoords[i] * 8.0f;
+ aliasvert = varray_vertex;
+ aliasvertcolor = varray_color;
+ R_SetupMDLMD2Frames(ent, mesh_colorscale, mesh_colorscale, mesh_colorscale);
+ aliasvert = aliasvertbuf;
+ aliasvertcolor = aliasvertcolorbuf;
+ R_Mesh_Draw(model->numverts, model->numtris);
return;
}
memset(&m, 0, sizeof(m));
m.blendfunc1 = blendfunc1;
m.blendfunc2 = blendfunc2;
- m.numtriangles = model->numtris;
- m.numverts = model->numverts;
+ m.wantoverbright = true;
m.tex[0] = R_GetTexture(skinframe->merged);
m.matrix = ent->matrix;
-
- c_alias_polys += m.numtriangles;
- if (R_Mesh_Draw_GetBuffer(&m, true))
- {
- memcpy(m.index, model->mdlmd2data_indices, m.numtriangles * sizeof(int[3]));
- memcpy(m.texcoords[0], model->mdlmd2data_texcoords, m.numverts * sizeof(float[2]));
-
- aliasvert = m.vertex;
- aliasvertcolor = m.color;
- R_SetupMDLMD2Frames(ent, m.colorscale, m.colorscale, m.colorscale);
- aliasvert = aliasvertbuf;
- aliasvertcolor = aliasvertcolorbuf;
-
- R_Mesh_Render();
- }
+ R_Mesh_State(&m);
+
+ c_alias_polys += model->numtris;
+ memcpy(varray_element, model->mdlmd2data_indices, model->numtris * sizeof(int[3]));
+ memcpy(varray_texcoord[0], model->mdlmd2data_texcoords, model->numverts * sizeof(float[2]));
+ aliasvert = varray_vertex;
+ aliasvertcolor = varray_color;
+ R_SetupMDLMD2Frames(ent, mesh_colorscale, mesh_colorscale, mesh_colorscale);
+ aliasvert = aliasvertbuf;
+ aliasvertcolor = aliasvertcolorbuf;
+ R_Mesh_Draw(model->numverts, model->numtris);
return;
}
memset(&m, 0, sizeof(m));
m.blendfunc1 = blendfunc1;
m.blendfunc2 = blendfunc2;
- m.numtriangles = model->numtris;
- m.numverts = model->numverts;
+ m.wantoverbright = true;
m.matrix = ent->matrix;
m.tex[0] = colormapped ? R_GetTexture(skinframe->base) : R_GetTexture(skinframe->merged);
- if (m.tex[0] && R_Mesh_Draw_GetBuffer(&m, true))
+ if (m.tex[0])
{
+ R_Mesh_State(&m);
+
blendfunc1 = GL_SRC_ALPHA;
blendfunc2 = GL_ONE;
- c_alias_polys += m.numtriangles;
- R_ModulateColors(aliasvertcolor, m.color, m.numverts, m.colorscale, m.colorscale, m.colorscale);
- memcpy(m.index, model->mdlmd2data_indices, m.numtriangles * sizeof(int[3]));
- memcpy(m.vertex, aliasvert, m.numverts * sizeof(float[4]));
- memcpy(m.texcoords[0], model->mdlmd2data_texcoords, m.numverts * sizeof(float[2]));
- R_Mesh_Render();
+ c_alias_polys += model->numtris;
+ R_ModulateColors(aliasvertcolor, varray_color, model->numverts, mesh_colorscale, mesh_colorscale, mesh_colorscale);
+ memcpy(varray_element, model->mdlmd2data_indices, model->numtris * sizeof(int[3]));
+ 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);
}
if (colormapped)
memset(&m, 0, sizeof(m));
m.blendfunc1 = blendfunc1;
m.blendfunc2 = blendfunc2;
- m.numtriangles = model->numtris;
- m.numverts = model->numverts;
+ m.wantoverbright = true;
m.matrix = ent->matrix;
m.tex[0] = R_GetTexture(skinframe->pants);
- if (m.tex[0] && R_Mesh_Draw_GetBuffer(&m, true))
+ if (m.tex[0])
{
+ R_Mesh_State(&m);
+
blendfunc1 = GL_SRC_ALPHA;
blendfunc2 = GL_ONE;
- c_alias_polys += m.numtriangles;
+ c_alias_polys += model->numtris;
if (pantsfullbright)
- R_FillColors(m.color, m.numverts, pantscolor[0] * m.colorscale, pantscolor[1] * m.colorscale, pantscolor[2] * m.colorscale, ent->alpha);
+ R_FillColors(varray_color, model->numverts, pantscolor[0] * mesh_colorscale, pantscolor[1] * mesh_colorscale, pantscolor[2] * mesh_colorscale, ent->alpha);
else
- R_ModulateColors(aliasvertcolor, m.color, m.numverts, pantscolor[0] * m.colorscale, pantscolor[1] * m.colorscale, pantscolor[2] * m.colorscale);
- memcpy(m.index, model->mdlmd2data_indices, m.numtriangles * sizeof(int[3]));
- memcpy(m.vertex, aliasvert, m.numverts * sizeof(float[4]));
- memcpy(m.texcoords[0], model->mdlmd2data_texcoords, m.numverts * sizeof(float[2]));
- R_Mesh_Render();
+ R_ModulateColors(aliasvertcolor, varray_color, model->numverts, pantscolor[0] * mesh_colorscale, pantscolor[1] * mesh_colorscale, pantscolor[2] * mesh_colorscale);
+ memcpy(varray_element, model->mdlmd2data_indices, model->numtris * sizeof(int[3]));
+ 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);
}
}
if (skinframe->shirt)
memset(&m, 0, sizeof(m));
m.blendfunc1 = blendfunc1;
m.blendfunc2 = blendfunc2;
- m.numtriangles = model->numtris;
- m.numverts = model->numverts;
+ m.wantoverbright = true;
m.matrix = ent->matrix;
m.tex[0] = R_GetTexture(skinframe->shirt);
- if (m.tex[0] && R_Mesh_Draw_GetBuffer(&m, true))
+ if (m.tex[0])
{
+ R_Mesh_State(&m);
+
blendfunc1 = GL_SRC_ALPHA;
blendfunc2 = GL_ONE;
- c_alias_polys += m.numtriangles;
+ c_alias_polys += model->numtris;
if (shirtfullbright)
- R_FillColors(m.color, m.numverts, shirtcolor[0] * m.colorscale, shirtcolor[1] * m.colorscale, shirtcolor[2] * m.colorscale, ent->alpha);
+ R_FillColors(varray_color, model->numverts, shirtcolor[0] * mesh_colorscale, shirtcolor[1] * mesh_colorscale, shirtcolor[2] * mesh_colorscale, ent->alpha);
else
- R_ModulateColors(aliasvertcolor, m.color, m.numverts, shirtcolor[0] * m.colorscale, shirtcolor[1] * m.colorscale, shirtcolor[2] * m.colorscale);
- memcpy(m.index, model->mdlmd2data_indices, m.numtriangles * sizeof(int[3]));
- memcpy(m.vertex, aliasvert, m.numverts * sizeof(float[4]));
- memcpy(m.texcoords[0], model->mdlmd2data_texcoords, m.numverts * sizeof(float[2]));
- R_Mesh_Render();
+ R_ModulateColors(aliasvertcolor, varray_color, model->numverts, shirtcolor[0] * mesh_colorscale, shirtcolor[1] * mesh_colorscale, shirtcolor[2] * mesh_colorscale);
+ memcpy(varray_element, model->mdlmd2data_indices, model->numtris * sizeof(int[3]));
+ 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);
}
}
}
memset(&m, 0, sizeof(m));
m.blendfunc1 = blendfunc1;
m.blendfunc2 = blendfunc2;
- m.numtriangles = model->numtris;
- m.numverts = model->numverts;
+ m.wantoverbright = true;
m.matrix = ent->matrix;
m.tex[0] = R_GetTexture(skinframe->glow);
- if (m.tex[0] && R_Mesh_Draw_GetBuffer(&m, true))
+ if (m.tex[0])
{
+ R_Mesh_State(&m);
+
blendfunc1 = GL_SRC_ALPHA;
blendfunc2 = GL_ONE;
- c_alias_polys += m.numtriangles;
- R_FillColors(m.color, m.numverts, (1 - fog) * m.colorscale, (1 - fog) * m.colorscale, (1 - fog) * m.colorscale, ent->alpha);
- memcpy(m.index, model->mdlmd2data_indices, m.numtriangles * sizeof(int[3]));
- memcpy(m.vertex, aliasvert, m.numverts * sizeof(float[4]));
- memcpy(m.texcoords[0], model->mdlmd2data_texcoords, m.numverts * sizeof(float[2]));
- R_Mesh_Render();
+ c_alias_polys += model->numtris;
+ R_FillColors(varray_color, model->numverts, (1 - fog) * mesh_colorscale, (1 - fog) * mesh_colorscale, (1 - fog) * mesh_colorscale, ent->alpha);
+ memcpy(varray_element, model->mdlmd2data_indices, model->numtris * sizeof(int[3]));
+ 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);
}
}
if (fog)
memset(&m, 0, sizeof(m));
m.blendfunc1 = GL_SRC_ALPHA;
m.blendfunc2 = GL_ONE;
- m.numtriangles = model->numtris;
- m.numverts = model->numverts;
+ m.wantoverbright = false;
m.matrix = ent->matrix;
m.tex[0] = R_GetTexture(skinframe->fog);
- if (R_Mesh_Draw_GetBuffer(&m, true))
- {
- c_alias_polys += m.numtriangles;
- R_FillColors(m.color, m.numverts, fogcolor[0] * fog * m.colorscale, fogcolor[1] * fog * m.colorscale, fogcolor[2] * fog * m.colorscale, ent->alpha);
- memcpy(m.index, model->mdlmd2data_indices, m.numtriangles * sizeof(int[3]));
- memcpy(m.vertex, aliasvert, m.numverts * sizeof(float[4]));
- memcpy(m.texcoords[0], model->mdlmd2data_texcoords, m.numverts * sizeof(float[2]));
- R_Mesh_Render();
- }
+ R_Mesh_State(&m);
+
+ c_alias_polys += model->numtris;
+ R_FillColors(varray_color, model->numverts, fogcolor[0] * fog * mesh_colorscale, fogcolor[1] * fog * mesh_colorscale, fogcolor[2] * fog * mesh_colorscale, ent->alpha);
+ memcpy(varray_element, model->mdlmd2data_indices, model->numtris * sizeof(int[3]));
+ 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);
}
}
int i, *renderlist;
zymtype1header_t *m;
rtexture_t *texture;
- rmeshbufferinfo_t mbuf;
+ rmeshstate_t mstate;
const entity_render_t *ent = calldata1;
int shadernum = calldata2;
+ int numverts, numtriangles;
// find the vertex index list and texture
m = ent->model->zymdata_header;
renderlist += renderlist[0] * 3 + 1;
texture = ((rtexture_t **)(m->lump_shaders.start + (int) m))[shadernum];
+ numverts = m->numverts;
+ numtriangles = renderlist[0];
+ R_Mesh_ResizeCheck(numverts, numtriangles);
+
fog = 0;
if (fogenabled)
{
}
ZymoticLerpBones(m->numbones, (zymbonematrix *)(m->lump_poses.start + (int) m), ent->frameblend, (zymbone_t *)(m->lump_bones.start + (int) m));
- ZymoticTransformVerts(m->numverts, (int *)(m->lump_vertbonecounts.start + (int) m), (zymvertex_t *)(m->lump_verts.start + (int) m));
- ZymoticCalcNormals(m->numverts, m->numshaders, (int *)(m->lump_render.start + (int) m));
+ ZymoticTransformVerts(numverts, (int *)(m->lump_vertbonecounts.start + (int) m), (zymvertex_t *)(m->lump_verts.start + (int) m));
+ ZymoticCalcNormals(numverts, m->numshaders, (int *)(m->lump_render.start + (int) m));
- R_LightModel(ent, m->numverts, 1 - fog, 1 - fog, 1 - fog, false);
+ R_LightModel(ent, numverts, 1 - fog, 1 - fog, 1 - fog, false);
- memset(&mbuf, 0, sizeof(mbuf));
- mbuf.numverts = m->numverts;
- mbuf.numtriangles = renderlist[0];
+ memset(&mstate, 0, sizeof(mstate));
+ mstate.wantoverbright = true;
if (ent->effects & EF_ADDITIVE)
{
- mbuf.blendfunc1 = GL_SRC_ALPHA;
- mbuf.blendfunc2 = GL_ONE;
+ mstate.blendfunc1 = GL_SRC_ALPHA;
+ mstate.blendfunc2 = GL_ONE;
}
else if (ent->alpha != 1.0 || R_TextureHasAlpha(texture))
{
- mbuf.blendfunc1 = GL_SRC_ALPHA;
- mbuf.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
+ mstate.blendfunc1 = GL_SRC_ALPHA;
+ mstate.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
}
else
{
- mbuf.blendfunc1 = GL_ONE;
- mbuf.blendfunc2 = GL_ZERO;
- }
- mbuf.tex[0] = R_GetTexture(texture);
- mbuf.matrix = ent->matrix;
- if (R_Mesh_Draw_GetBuffer(&mbuf, true))
- {
- c_alias_polys += mbuf.numtriangles;
- memcpy(mbuf.index, renderlist + 1, mbuf.numtriangles * sizeof(int[3]));
- memcpy(mbuf.vertex, aliasvert, mbuf.numverts * sizeof(float[4]));
- R_ModulateColors(aliasvertcolor, mbuf.color, mbuf.numverts, mbuf.colorscale, mbuf.colorscale, mbuf.colorscale);
- //memcpy(mbuf.color, aliasvertcolor, mbuf.numverts * sizeof(float[4]));
- memcpy(mbuf.texcoords[0], (float *)(m->lump_texcoords.start + (int) m), mbuf.numverts * sizeof(float[2]));
- R_Mesh_Render();
+ mstate.blendfunc1 = GL_ONE;
+ mstate.blendfunc2 = GL_ZERO;
}
+ mstate.tex[0] = R_GetTexture(texture);
+ mstate.matrix = ent->matrix;
+ R_Mesh_State(&mstate);
+
+ c_alias_polys += numtriangles;
+ memcpy(varray_element, renderlist + 1, numtriangles * sizeof(int[3]));
+ memcpy(varray_vertex, aliasvert, numverts * sizeof(float[4]));
+ R_ModulateColors(aliasvertcolor, varray_color, numverts, mesh_colorscale, mesh_colorscale, mesh_colorscale);
+ memcpy(varray_texcoord[0], (float *)(m->lump_texcoords.start + (int) m), numverts * sizeof(float[2]));
+ R_Mesh_Draw(numverts, numtriangles);
if (fog)
{
- memset(&mbuf, 0, sizeof(mbuf));
- mbuf.numverts = m->numverts;
- mbuf.numtriangles = renderlist[0];
- mbuf.blendfunc1 = GL_SRC_ALPHA;
- mbuf.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
+ memset(&mstate, 0, sizeof(mstate));
+ mstate.wantoverbright = false;
+ mstate.blendfunc1 = GL_SRC_ALPHA;
+ mstate.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
// FIXME: need alpha mask for fogging...
- //mbuf.tex[0] = R_GetTexture(texture);
- mbuf.matrix = ent->matrix;
- if (R_Mesh_Draw_GetBuffer(&mbuf, false))
- {
- c_alias_polys += mbuf.numtriangles;
- memcpy(mbuf.index, renderlist + 1, mbuf.numtriangles * sizeof(int[3]));
- memcpy(mbuf.vertex, aliasvert, mbuf.numverts * sizeof(float[4]));
- R_FillColors(mbuf.color, mbuf.numverts, fogcolor[0] * mbuf.colorscale, fogcolor[1] * mbuf.colorscale, fogcolor[2] * mbuf.colorscale, ent->alpha * fog);
- //memcpy(mbuf.texcoords[0], (float *)(m->lump_texcoords.start + (int) m), mbuf.numverts * sizeof(float[2]));
- R_Mesh_Render();
- }
+ //mstate.tex[0] = R_GetTexture(texture);
+ mstate.matrix = ent->matrix;
+ R_Mesh_State(&mstate);
+
+ c_alias_polys += numtriangles;
+ memcpy(varray_element, renderlist + 1, numtriangles * sizeof(int[3]));
+ memcpy(varray_vertex, aliasvert, numverts * sizeof(float[4]));
+ R_FillColors(varray_color, numverts, fogcolor[0] * mesh_colorscale, fogcolor[1] * mesh_colorscale, fogcolor[2] * mesh_colorscale, ent->alpha * fog);
+ //memcpy(mesh_texcoord[0], (float *)(m->lump_texcoords.start + (int) m), numverts * sizeof(float[2]));
+ R_Mesh_Draw(numverts, numtriangles);
}
}
if (ent->effects & EF_ADDITIVE || ent->alpha != 1.0 || R_TextureHasAlpha(texture))
R_MeshQueue_AddTransparent(ent->origin, R_DrawZymoticModelMeshCallback, ent, i);
else
- R_MeshQueue_Add(R_DrawZymoticModelMeshCallback, ent, i);
+ R_DrawZymoticModelMeshCallback(ent, i);
}
}
if (ent->effects & EF_ADDITIVE || ent->alpha != 1.0 || R_FetchSkinFrame(ent)->fog != NULL)
R_MeshQueue_AddTransparent(ent->origin, R_DrawQ1Q2AliasModelCallback, ent, 0);
else
- R_MeshQueue_Add(R_DrawQ1Q2AliasModelCallback, ent, 0);
+ R_DrawQ1Q2AliasModelCallback(ent, 0);
}
static void R_BlendView(void)
{
- rmeshbufferinfo_t m;
+ rmeshstate_t m;
float r;
if (r_refdef.viewblend[3] < 0.01f)
memset(&m, 0, sizeof(m));
m.blendfunc1 = GL_SRC_ALPHA;
m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
+ m.wantoverbright = false;
m.depthdisable = true; // magic
- m.numtriangles = 1;
- m.numverts = 3;
Matrix4x4_CreateIdentity(&m.matrix);
- if (R_Mesh_Draw_GetBuffer(&m, false))
- {
- m.index[0] = 0;
- m.index[1] = 1;
- m.index[2] = 2;
- m.color[0] = m.color[4] = m.color[8] = r_refdef.viewblend[0];
- m.color[1] = m.color[5] = m.color[9] = r_refdef.viewblend[1];
- m.color[2] = m.color[6] = m.color[10] = r_refdef.viewblend[2];
- m.color[3] = m.color[7] = m.color[11] = r_refdef.viewblend[3];
- r = 64000;
- m.vertex[0] = r_origin[0] + vpn[0] * 1.5 - vright[0] * r - vup[0] * r;
- m.vertex[1] = r_origin[1] + vpn[1] * 1.5 - vright[1] * r - vup[1] * r;
- m.vertex[2] = r_origin[2] + vpn[2] * 1.5 - vright[2] * r - vup[2] * r;
- r *= 3;
- m.vertex[4] = m.vertex[0] + vup[0] * r;
- m.vertex[5] = m.vertex[1] + vup[1] * r;
- m.vertex[6] = m.vertex[2] + vup[2] * r;
- m.vertex[8] = m.vertex[0] + vright[0] * r;
- m.vertex[9] = m.vertex[1] + vright[1] * r;
- m.vertex[10] = m.vertex[2] + vright[2] * r;
- R_Mesh_Render();
- }
+ R_Mesh_State(&m);
+
+ varray_element[0] = 0;
+ varray_element[1] = 1;
+ varray_element[2] = 2;
+ 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[2] = r_origin[2] + vpn[2] * 1.5 - vright[2] * r - vup[2] * r;
+ r *= 3;
+ varray_vertex[4] = varray_vertex[0] + vup[0] * r;
+ varray_vertex[5] = varray_vertex[1] + vup[1] * r;
+ varray_vertex[6] = varray_vertex[2] + vup[2] * 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;
+ R_Mesh_Draw(3, 1);
}
/*
if (R_DrawBrushModelsSky())
R_TimeReport("bmodelsky");
+ // must occur early because it can draw sky
+ R_DrawWorld(world);
+ R_TimeReport("world");
+
+ // don't let sound skip if going slow
+ if (!intimerefresh && !r_speeds.integer)
+ S_ExtraUpdate ();
+
R_DrawModels();
R_TimeReport("models");
R_DrawExplosions();
R_TimeReport("explosions");
- // don't let sound skip if going slow
- if (!intimerefresh && !r_speeds.integer)
- S_ExtraUpdate ();
-
- R_DrawWorld(world);
- R_TimeReport("world");
-
R_MeshQueue_RenderTransparent();
R_TimeReport("drawtrans");
R_TimeReport("meshfinish");
}
+/*
void R_DrawBBoxMesh(vec3_t mins, vec3_t maxs, float cr, float cg, float cb, float ca)
{
int i;
float *v, *c, f1, f2, diff[3];
- rmeshbufferinfo_t m;
- m.numtriangles = 12;
- m.numverts = 8;
+ rmeshstate_t m;
m.blendfunc1 = GL_SRC_ALPHA;
m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
+ m.wantoverbright = false;
Matrix4x4_CreateIdentity(&m.matrix);
- if (R_Mesh_Draw_GetBuffer(&m, false))
+ R_Mesh_State(&m);
+
+ varray_element
+ varray_vertex[ 0] = mins[0];varray_vertex[ 1] = mins[1];varray_vertex[ 2] = mins[2];
+ varray_vertex[ 4] = maxs[0];varray_vertex[ 5] = mins[1];varray_vertex[ 6] = mins[2];
+ varray_vertex[ 8] = mins[0];varray_vertex[ 9] = maxs[1];varray_vertex[10] = mins[2];
+ varray_vertex[12] = maxs[0];varray_vertex[13] = maxs[1];varray_vertex[14] = mins[2];
+ varray_vertex[16] = mins[0];varray_vertex[17] = mins[1];varray_vertex[18] = maxs[2];
+ 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 * mesh_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 * mesh_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 * mesh_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;
+ if (fogenabled)
{
- m.vertex[ 0] = mins[0];m.vertex[ 1] = mins[1];m.vertex[ 2] = mins[2];
- m.vertex[ 4] = maxs[0];m.vertex[ 5] = mins[1];m.vertex[ 6] = mins[2];
- m.vertex[ 8] = mins[0];m.vertex[ 9] = maxs[1];m.vertex[10] = mins[2];
- m.vertex[12] = maxs[0];m.vertex[13] = maxs[1];m.vertex[14] = mins[2];
- m.vertex[16] = mins[0];m.vertex[17] = mins[1];m.vertex[18] = maxs[2];
- m.vertex[20] = maxs[0];m.vertex[21] = mins[1];m.vertex[22] = maxs[2];
- m.vertex[24] = mins[0];m.vertex[25] = maxs[1];m.vertex[26] = maxs[2];
- m.vertex[28] = maxs[0];m.vertex[29] = maxs[1];m.vertex[30] = maxs[2];
- m.color[ 0] = m.color[ 4] = m.color[ 8] = m.color[12] = m.color[16] = m.color[20] = m.color[24] = m.color[28] = cr * m.colorscale;
- m.color[ 1] = m.color[ 5] = m.color[ 9] = m.color[13] = m.color[17] = m.color[21] = m.color[25] = m.color[29] = cg * m.colorscale;
- m.color[ 2] = m.color[ 6] = m.color[10] = m.color[14] = m.color[18] = m.color[22] = m.color[26] = m.color[30] = cb * m.colorscale;
- m.color[ 3] = m.color[ 7] = m.color[11] = m.color[15] = m.color[19] = m.color[23] = m.color[27] = m.color[31] = ca;
- if (fogenabled)
+ for (i = 0, v = varray_vertex, c = varray_color;i < 8;i++, v += 4, c += 4)
{
- for (i = 0, v = m.vertex, c = m.color;i < m.numverts;i++, v += 4, c += 4)
- {
- VectorSubtract(v, r_origin, diff);
- f2 = exp(fogdensity/DotProduct(diff, diff));
- f1 = 1 - f2;
- f2 *= m.colorscale;
- c[0] = c[0] * f1 + fogcolor[0] * f2;
- c[1] = c[1] * f1 + fogcolor[1] * f2;
- c[2] = c[2] * f1 + fogcolor[2] * f2;
- }
+ VectorSubtract(v, r_origin, diff);
+ f2 = exp(fogdensity/DotProduct(diff, diff));
+ f1 = 1 - f2;
+ f2 *= mesh_colorscale;
+ c[0] = c[0] * f1 + fogcolor[0] * f2;
+ c[1] = c[1] * f1 + fogcolor[1] * f2;
+ c[2] = c[2] * f1 + fogcolor[2] * f2;
}
- R_Mesh_Render();
}
+ R_Mesh_Draw(8, 12);
}
+*/
void R_DrawNoModelCallback(const void *calldata1, int calldata2)
{
const entity_render_t *ent = calldata1;
int i;
float f1, f2, *c, diff[3];
- rmeshbufferinfo_t m;
+ rmeshstate_t m;
memset(&m, 0, sizeof(m));
if (ent->flags & EF_ADDITIVE)
{
m.blendfunc1 = GL_ONE;
m.blendfunc2 = GL_ZERO;
}
- m.numtriangles = 8;
- m.numverts = 6;
+ m.wantoverbright = false;
m.matrix = ent->matrix;
- if (R_Mesh_Draw_GetBuffer(&m, false))
+ R_Mesh_State(&m);
+
+ varray_element[ 0] = 5;varray_element[ 1] = 2;varray_element[ 2] = 0;
+ varray_element[ 3] = 5;varray_element[ 4] = 1;varray_element[ 5] = 2;
+ varray_element[ 6] = 5;varray_element[ 7] = 0;varray_element[ 8] = 3;
+ varray_element[ 9] = 5;varray_element[10] = 3;varray_element[11] = 1;
+ varray_element[12] = 0;varray_element[13] = 2;varray_element[14] = 4;
+ varray_element[15] = 2;varray_element[16] = 1;varray_element[17] = 4;
+ varray_element[18] = 3;varray_element[19] = 0;varray_element[20] = 4;
+ varray_element[21] = 1;varray_element[22] = 3;varray_element[23] = 4;
+ varray_vertex[ 0] = -16;varray_vertex[ 1] = 0;varray_vertex[ 2] = 0;
+ varray_vertex[ 4] = 16;varray_vertex[ 5] = 0;varray_vertex[ 6] = 0;
+ varray_vertex[ 8] = 0;varray_vertex[ 9] = -16;varray_vertex[10] = 0;
+ 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;
+ if (fogenabled)
{
- m.index[ 0] = 5;m.index[ 1] = 2;m.index[ 2] = 0;
- m.index[ 3] = 5;m.index[ 4] = 1;m.index[ 5] = 2;
- m.index[ 6] = 5;m.index[ 7] = 0;m.index[ 8] = 3;
- m.index[ 9] = 5;m.index[10] = 3;m.index[11] = 1;
- m.index[12] = 0;m.index[13] = 2;m.index[14] = 4;
- m.index[15] = 2;m.index[16] = 1;m.index[17] = 4;
- m.index[18] = 3;m.index[19] = 0;m.index[20] = 4;
- m.index[21] = 1;m.index[22] = 3;m.index[23] = 4;
- m.vertex[ 0] = -16;m.vertex[ 1] = 0;m.vertex[ 2] = 0;
- m.vertex[ 4] = 16;m.vertex[ 5] = 0;m.vertex[ 6] = 0;
- m.vertex[ 8] = 0;m.vertex[ 9] = -16;m.vertex[10] = 0;
- m.vertex[12] = 0;m.vertex[13] = 16;m.vertex[14] = 0;
- m.vertex[16] = 0;m.vertex[17] = 0;m.vertex[18] = -16;
- m.vertex[20] = 0;m.vertex[21] = 0;m.vertex[22] = 16;
- m.color[ 0] = 0.00f;m.color[ 1] = 0.00f;m.color[ 2] = 0.50f;m.color[ 3] = ent->alpha;
- m.color[ 4] = 0.00f;m.color[ 5] = 0.00f;m.color[ 6] = 0.50f;m.color[ 7] = ent->alpha;
- m.color[ 8] = 0.00f;m.color[ 9] = 0.50f;m.color[10] = 0.00f;m.color[11] = ent->alpha;
- m.color[12] = 0.00f;m.color[13] = 0.50f;m.color[14] = 0.00f;m.color[15] = ent->alpha;
- m.color[16] = 0.50f;m.color[17] = 0.00f;m.color[18] = 0.00f;m.color[19] = ent->alpha;
- m.color[20] = 0.50f;m.color[21] = 0.00f;m.color[22] = 0.00f;m.color[23] = ent->alpha;
- if (fogenabled)
+ VectorSubtract(ent->origin, r_origin, diff);
+ f2 = exp(fogdensity/DotProduct(diff, diff));
+ f1 = 1 - f2;
+ for (i = 0, c = varray_color;i < 6;i++, c += 4)
{
- VectorSubtract(ent->origin, r_origin, diff);
- f2 = exp(fogdensity/DotProduct(diff, diff));
- f1 = 1 - f2;
- for (i = 0, c = m.color;i < m.numverts;i++, c += 4)
- {
- c[0] = (c[0] * f1 + fogcolor[0] * f2) * m.colorscale;
- c[1] = (c[1] * f1 + fogcolor[1] * f2) * m.colorscale;
- c[2] = (c[2] * f1 + fogcolor[2] * f2) * m.colorscale;
- }
+ c[0] = (c[0] * f1 + fogcolor[0] * f2) * mesh_colorscale;
+ c[1] = (c[1] * f1 + fogcolor[1] * f2) * mesh_colorscale;
+ c[2] = (c[2] * f1 + fogcolor[2] * f2) * mesh_colorscale;
}
- else
+ }
+ else
+ {
+ for (i = 0, c = varray_color;i < 6;i++, c += 4)
{
- for (i = 0, c = m.color;i < m.numverts;i++, c += 4)
- {
- c[0] *= m.colorscale;
- c[1] *= m.colorscale;
- c[2] *= m.colorscale;
- }
+ c[0] *= mesh_colorscale;
+ c[1] *= mesh_colorscale;
+ c[2] *= mesh_colorscale;
}
- R_Mesh_Render();
}
+ R_Mesh_Draw(6, 8);
}
void R_DrawNoModel(entity_render_t *ent)
{
const msurface_t *surf;
const surfmesh_t *mesh;
- rmeshbufferinfo_t m;
+ rmeshstate_t m;
// LordHavoc: HalfLife maps have freaky skypolys...
if (ent->model->ishlbsp)
m.blendfunc1 = GL_ONE;
m.blendfunc2 = GL_ZERO;
}
+ m.wantoverbright = false;
m.depthwrite = true;
m.matrix = ent->matrix;
+ R_Mesh_State(&m);
for (surf = firstsurf;surf;surf = surf->chain)
{
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
- m.numtriangles = mesh->numtriangles;
- m.numverts = mesh->numverts;
- if (R_Mesh_Draw_GetBuffer(&m, false))
- {
- memcpy(m.index, mesh->index, m.numtriangles * sizeof(int[3]));
- memcpy(m.vertex, mesh->verts, m.numverts * sizeof(float[4]));
- if (skyrendermasked)
- memset(m.color, 0, m.numverts * sizeof(float[4]));
- else
- R_FillColors(m.color, m.numverts, fogcolor[0] * m.colorscale, fogcolor[1] * m.colorscale, fogcolor[2] * m.colorscale, 1);
- R_Mesh_Render();
- }
+ R_Mesh_ResizeCheck(mesh->numverts, mesh->numtriangles);
+ memcpy(varray_element, mesh->index, mesh->numtriangles * sizeof(int[3]));
+ 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] * mesh_colorscale, fogcolor[1] * mesh_colorscale, fogcolor[2] * mesh_colorscale, 1);
+ R_Mesh_Draw(mesh->numverts, mesh->numtriangles);
}
}
}
const msurface_t *surf = ent->model->surfaces + calldata2;
float f;
const surfmesh_t *mesh;
- rmeshbufferinfo_t m;
+ rmeshstate_t m;
float alpha = ent->alpha * (surf->flags & SURF_DRAWNOALPHA ? 1 : r_wateralpha.value);
float modelorg[3];
Matrix4x4_Transform(&ent->inversematrix, r_origin, modelorg);
m.blendfunc1 = GL_ONE;
m.blendfunc2 = GL_ZERO;
}
+ m.wantoverbright = true;
m.tex[0] = R_GetTexture(surf->currenttexture->texture);
m.matrix = ent->matrix;
+ R_Mesh_State(&m);
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
- m.numtriangles = mesh->numtriangles;
- m.numverts = mesh->numverts;
- if (R_Mesh_Draw_GetBuffer(&m, true))
+ R_Mesh_ResizeCheck(mesh->numverts, mesh->numtriangles);
+ memcpy(varray_element, mesh->index, mesh->numtriangles * sizeof(int[3]));
+ memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
+ memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
+ f = surf->flags & SURF_DRAWFULLBRIGHT ? 1.0f : ((surf->flags & SURF_LIGHTMAP) ? 0 : 0.5f);
+ R_FillColors(varray_color, mesh->numverts, f, f, f, alpha);
+ if (!(surf->flags & SURF_DRAWFULLBRIGHT || ent->effects & EF_FULLBRIGHT))
{
- memcpy(m.index, mesh->index, m.numtriangles * sizeof(int[3]));
- memcpy(m.vertex, mesh->verts, m.numverts * sizeof(float[4]));
- memcpy(m.texcoords[0], mesh->st, m.numverts * sizeof(float[2]));
- f = surf->flags & SURF_DRAWFULLBRIGHT ? 1.0f : ((surf->flags & SURF_LIGHTMAP) ? 0 : 0.5f);
- R_FillColors(m.color, m.numverts, f, f, f, alpha);
- if (!(surf->flags & SURF_DRAWFULLBRIGHT || ent->effects & EF_FULLBRIGHT))
- {
- if (surf->dlightframe == r_framecount)
- RSurf_LightSeparate(&ent->inversematrix, surf->dlightbits, m.numverts, m.vertex, m.color);
- if (surf->flags & SURF_LIGHTMAP)
- RSurf_AddLightmapToVertexColors(mesh->lightmapoffsets, m.color, m.numverts, surf->samples, ((surf->extents[0]>>4)+1)*((surf->extents[1]>>4)+1)*3, surf->styles);
- }
- RSurf_FogColors(m.vertex, m.color, m.colorscale, m.numverts, modelorg);
- R_Mesh_Render();
+ if (surf->dlightframe == r_framecount)
+ RSurf_LightSeparate(&ent->inversematrix, surf->dlightbits, mesh->numverts, varray_vertex, varray_color);
+ if (surf->flags & SURF_LIGHTMAP)
+ RSurf_AddLightmapToVertexColors(mesh->lightmapoffsets, varray_color, mesh->numverts, surf->samples, ((surf->extents[0]>>4)+1)*((surf->extents[1]>>4)+1)*3, surf->styles);
}
+ RSurf_FogColors(varray_vertex, varray_color, mesh_colorscale, mesh->numverts, modelorg);
+ R_Mesh_Draw(mesh->numverts, mesh->numtriangles);
}
if (fogenabled)
memset(&m, 0, sizeof(m));
m.blendfunc1 = GL_SRC_ALPHA;
m.blendfunc2 = GL_ONE;
+ m.wantoverbright = false;
m.tex[0] = R_GetTexture(surf->currenttexture->fogtexture);
m.matrix = ent->matrix;
+ R_Mesh_State(&m);
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
- m.numtriangles = mesh->numtriangles;
- m.numverts = mesh->numverts;
- if (R_Mesh_Draw_GetBuffer(&m, false))
- {
- memcpy(m.index, mesh->index, m.numtriangles * sizeof(int[3]));
- memcpy(m.vertex, mesh->verts, m.numverts * sizeof(float[4]));
- if (m.tex[0])
- memcpy(m.texcoords[0], mesh->st, m.numverts * sizeof(float[2]));
- RSurf_FogPassColors(m.vertex, m.color, fogcolor[0], fogcolor[1], fogcolor[2], alpha, m.colorscale, m.numverts, modelorg);
- R_Mesh_Render();
- }
+ R_Mesh_ResizeCheck(mesh->numverts, mesh->numtriangles);
+ memcpy(varray_element, mesh->index, mesh->numtriangles * sizeof(int[3]));
+ memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
+ if (m.tex[0])
+ memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
+ RSurf_FogPassColors(varray_vertex, varray_color, fogcolor[0], fogcolor[1], fogcolor[2], alpha, mesh_colorscale, mesh->numverts, modelorg);
+ R_Mesh_Draw(mesh->numverts, mesh->numtriangles);
}
}
}
{
float base;
const surfmesh_t *mesh;
- rmeshbufferinfo_t m;
+ rmeshstate_t m;
float modelorg[3];
Matrix4x4_Transform(&ent->inversematrix, r_origin, modelorg);
memset(&m, 0, sizeof(m));
m.blendfunc1 = GL_ONE;
m.blendfunc2 = GL_ZERO;
}
+ m.wantoverbright = true;
m.tex[0] = R_GetTexture(surf->currenttexture->texture);
base = ent->effects & EF_FULLBRIGHT ? 2.0f : r_ambient.value * (1.0f / 64.0f);
m.matrix = ent->matrix;
+ R_Mesh_State(&m);
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
- m.numtriangles = mesh->numtriangles;
- m.numverts = mesh->numverts;
- if (R_Mesh_Draw_GetBuffer(&m, true))
+ R_Mesh_ResizeCheck(mesh->numverts, mesh->numtriangles);
+ memcpy(varray_element, mesh->index, mesh->numtriangles * sizeof(int[3]));
+ 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, base, base, base, ent->alpha);
+ if (!(ent->effects & EF_FULLBRIGHT))
{
- memcpy(m.index, mesh->index, m.numtriangles * sizeof(int[3]));
- memcpy(m.vertex, mesh->verts, m.numverts * sizeof(float[4]));
- memcpy(m.texcoords[0], mesh->st, m.numverts * sizeof(float[2]));
- R_FillColors(m.color, m.numverts, base, base, base, ent->alpha);
- if (!(ent->effects & EF_FULLBRIGHT))
- {
- if (surf->dlightframe == r_framecount)
- RSurf_LightSeparate(&ent->inversematrix, surf->dlightbits, m.numverts, m.vertex, m.color);
- if (surf->flags & SURF_LIGHTMAP)
- RSurf_AddLightmapToVertexColors(mesh->lightmapoffsets, m.color, m.numverts, surf->samples, ((surf->extents[0]>>4)+1)*((surf->extents[1]>>4)+1)*3, surf->styles);
- }
- RSurf_FogColors(m.vertex, m.color, m.colorscale, m.numverts, modelorg);
- R_Mesh_Render();
+ if (surf->dlightframe == r_framecount)
+ RSurf_LightSeparate(&ent->inversematrix, surf->dlightbits, mesh->numverts, varray_vertex, varray_color);
+ if (surf->flags & SURF_LIGHTMAP)
+ RSurf_AddLightmapToVertexColors(mesh->lightmapoffsets, varray_color, mesh->numverts, surf->samples, ((surf->extents[0]>>4)+1)*((surf->extents[1]>>4)+1)*3, surf->styles);
}
+ RSurf_FogColors(varray_vertex, varray_color, mesh_colorscale, mesh->numverts, modelorg);
+ R_Mesh_Draw(mesh->numverts, mesh->numtriangles);
}
}
static void RSurfShader_Wall_Pass_BaseFullbright(const entity_render_t *ent, const msurface_t *surf)
{
const surfmesh_t *mesh;
- rmeshbufferinfo_t m;
+ rmeshstate_t m;
float modelorg[3];
Matrix4x4_Transform(&ent->inversematrix, r_origin, modelorg);
memset(&m, 0, sizeof(m));
m.blendfunc1 = GL_ONE;
m.blendfunc2 = GL_ZERO;
}
+ m.wantoverbright = false;
m.tex[0] = R_GetTexture(surf->currenttexture->texture);
m.matrix = ent->matrix;
+ R_Mesh_State(&m);
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
- m.numtriangles = mesh->numtriangles;
- m.numverts = mesh->numverts;
- if (R_Mesh_Draw_GetBuffer(&m, false))
- {
- memcpy(m.index, mesh->index, m.numtriangles * sizeof(int[3]));
- memcpy(m.vertex, mesh->verts, m.numverts * sizeof(float[4]));
- memcpy(m.texcoords[0], mesh->st, m.numverts * sizeof(float[2]));
- RSurf_FoggedColors(m.vertex, m.color, 1, 1, 1, ent->alpha, m.colorscale, m.numverts, modelorg);
- R_Mesh_Render();
- }
+ R_Mesh_ResizeCheck(mesh->numverts, mesh->numtriangles);
+ memcpy(varray_element, mesh->index, mesh->numtriangles * sizeof(int[3]));
+ memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
+ memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
+ RSurf_FoggedColors(varray_vertex, varray_color, 1, 1, 1, ent->alpha, mesh_colorscale, mesh->numverts, modelorg);
+ R_Mesh_Draw(mesh->numverts, mesh->numtriangles);
}
}
static void RSurfShader_Wall_Pass_Glow(const entity_render_t *ent, const msurface_t *surf)
{
const surfmesh_t *mesh;
- rmeshbufferinfo_t m;
+ rmeshstate_t m;
float modelorg[3];
Matrix4x4_Transform(&ent->inversematrix, r_origin, modelorg);
memset(&m, 0, sizeof(m));
m.blendfunc1 = GL_SRC_ALPHA;
m.blendfunc2 = GL_ONE;
+ m.wantoverbright = false;
m.tex[0] = R_GetTexture(surf->currenttexture->glowtexture);
m.matrix = ent->matrix;
+ R_Mesh_State(&m);
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
- m.numtriangles = mesh->numtriangles;
- m.numverts = mesh->numverts;
- if (R_Mesh_Draw_GetBuffer(&m, false))
- {
- memcpy(m.index, mesh->index, m.numtriangles * sizeof(int[3]));
- memcpy(m.vertex, mesh->verts, m.numverts * sizeof(float[4]));
- memcpy(m.texcoords[0], mesh->st, m.numverts * sizeof(float[2]));
- RSurf_FoggedColors(m.vertex, m.color, 1, 1, 1, ent->alpha, m.colorscale, m.numverts, modelorg);
- R_Mesh_Render();
- }
+ R_Mesh_ResizeCheck(mesh->numverts, mesh->numtriangles);
+ memcpy(varray_element, mesh->index, mesh->numtriangles * sizeof(int[3]));
+ memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
+ memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
+ RSurf_FoggedColors(varray_vertex, varray_color, 1, 1, 1, ent->alpha, mesh_colorscale, mesh->numverts, modelorg);
+ R_Mesh_Draw(mesh->numverts, mesh->numtriangles);
}
}
static void RSurfShader_Wall_Pass_Fog(const entity_render_t *ent, const msurface_t *surf)
{
const surfmesh_t *mesh;
- rmeshbufferinfo_t m;
+ rmeshstate_t m;
float modelorg[3];
Matrix4x4_Transform(&ent->inversematrix, r_origin, modelorg);
memset(&m, 0, sizeof(m));
m.blendfunc1 = GL_SRC_ALPHA;
m.blendfunc2 = GL_ONE;
+ m.wantoverbright = false;
m.matrix = ent->matrix;
m.tex[0] = R_GetTexture(surf->currenttexture->fogtexture);
+ R_Mesh_State(&m);
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
- m.numtriangles = mesh->numtriangles;
- m.numverts = mesh->numverts;
- if (R_Mesh_Draw_GetBuffer(&m, false))
- {
- memcpy(m.index, mesh->index, m.numtriangles * sizeof(int[3]));
- memcpy(m.vertex, mesh->verts, m.numverts * sizeof(float[4]));
- if (m.tex[0])
- memcpy(m.texcoords[0], mesh->st, m.numverts * sizeof(float[2]));
- RSurf_FogPassColors(m.vertex, m.color, fogcolor[0], fogcolor[1], fogcolor[2], ent->alpha, m.colorscale, m.numverts, modelorg);
- R_Mesh_Render();
- }
+ R_Mesh_ResizeCheck(mesh->numverts, mesh->numtriangles);
+ memcpy(varray_element, mesh->index, mesh->numtriangles * sizeof(int[3]));
+ memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
+ if (m.tex[0])
+ memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
+ RSurf_FogPassColors(varray_vertex, varray_color, fogcolor[0], fogcolor[1], fogcolor[2], ent->alpha, mesh_colorscale, mesh->numverts, modelorg);
+ R_Mesh_Draw(mesh->numverts, mesh->numtriangles);
}
}
static void RSurfShader_OpaqueWall_Pass_TripleTexCombine(const entity_render_t *ent, const msurface_t *surf)
{
const surfmesh_t *mesh;
- static rmeshbufferinfo_t m;
+ static rmeshstate_t m;
float cl;
//memset(&m, 0, sizeof(m));
m.blendfunc1 = GL_ONE;
m.blendfunc2 = GL_ZERO;
+ m.wantoverbright = false;
m.tex[0] = R_GetTexture(surf->currenttexture->texture);
m.texrgbscale[0] = 1.0f;
m.tex[1] = R_GetTexture(surf->lightmaptexture);
m.tex[2] = R_GetTexture(surf->currenttexture->detailtexture);
m.texrgbscale[2] = 2.0f;
m.matrix = ent->matrix;
+ R_Mesh_State(&m);
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
- m.numtriangles = mesh->numtriangles;
- m.numverts = mesh->numverts;
- if (R_Mesh_Draw_GetBuffer(&m, false))
- {
- memcpy(m.index, mesh->index, m.numtriangles * sizeof(int[3]));
- memcpy(m.vertex, mesh->verts, m.numverts * sizeof(float[4]));
- memcpy(m.texcoords[0], mesh->st, m.numverts * sizeof(float[2]));
- memcpy(m.texcoords[1], mesh->uv, m.numverts * sizeof(float[2]));
- memcpy(m.texcoords[2], mesh->ab, m.numverts * sizeof(float[2]));
- cl = (float) (1 << lightscalebit) * m.colorscale;
- R_FillColors(m.color, m.numverts, cl, cl, cl, 1);
- R_Mesh_Render();
- }
+ R_Mesh_ResizeCheck(mesh->numverts, mesh->numtriangles);
+ memcpy(varray_element, mesh->index, mesh->numtriangles * sizeof(int[3]));
+ 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]));
+ memcpy(varray_texcoord[2], mesh->ab, mesh->numverts * sizeof(float[2]));
+ cl = (float) (1 << lightscalebit) * mesh_colorscale;
+ R_FillColors(varray_color, mesh->numverts, cl, cl, cl, 1);
+ R_Mesh_Draw(mesh->numverts, mesh->numtriangles);
}
}
static void RSurfShader_OpaqueWall_Pass_BaseMTex(const entity_render_t *ent, const msurface_t *surf)
{
const surfmesh_t *mesh;
- rmeshbufferinfo_t m;
+ rmeshstate_t m;
float cl;
memset(&m, 0, sizeof(m));
m.blendfunc1 = GL_ONE;
m.blendfunc2 = GL_ZERO;
+ m.wantoverbright = true;
m.tex[0] = R_GetTexture(surf->currenttexture->texture);
m.tex[1] = R_GetTexture(surf->lightmaptexture);
m.matrix = ent->matrix;
+ R_Mesh_State(&m);
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
- m.numtriangles = mesh->numtriangles;
- m.numverts = mesh->numverts;
- if (R_Mesh_Draw_GetBuffer(&m, true))
- {
- memcpy(m.index, mesh->index, m.numtriangles * sizeof(int[3]));
- memcpy(m.vertex, mesh->verts, m.numverts * sizeof(float[4]));
- memcpy(m.texcoords[0], mesh->st, m.numverts * sizeof(float[2]));
- memcpy(m.texcoords[1], mesh->uv, m.numverts * sizeof(float[2]));
- cl = (float) (1 << lightscalebit) * m.colorscale;
- R_FillColors(m.color, m.numverts, cl, cl, cl, 1);
- R_Mesh_Render();
- }
+ R_Mesh_ResizeCheck(mesh->numverts, mesh->numtriangles);
+ memcpy(varray_element, mesh->index, mesh->numtriangles * sizeof(int[3]));
+ 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]));
+ cl = (float) (1 << lightscalebit) * mesh_colorscale;
+ R_FillColors(varray_color, mesh->numverts, cl, cl, cl, 1);
+ R_Mesh_Draw(mesh->numverts, mesh->numtriangles);
}
}
static void RSurfShader_OpaqueWall_Pass_BaseTexture(const entity_render_t *ent, const msurface_t *surf)
{
const surfmesh_t *mesh;
- rmeshbufferinfo_t m;
+ rmeshstate_t m;
float cl;
memset(&m, 0, sizeof(m));
m.blendfunc1 = GL_ONE;
m.blendfunc2 = GL_ZERO;
+ m.wantoverbright = false;
m.tex[0] = R_GetTexture(surf->currenttexture->texture);
m.matrix = ent->matrix;
+ R_Mesh_State(&m);
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
- m.numtriangles = mesh->numtriangles;
- m.numverts = mesh->numverts;
- if (R_Mesh_Draw_GetBuffer(&m, false))
- {
- memcpy(m.index, mesh->index, m.numtriangles * sizeof(int[3]));
- memcpy(m.vertex, mesh->verts, m.numverts * sizeof(float[4]));
- memcpy(m.texcoords[0], mesh->st, m.numverts * sizeof(float[2]));
- cl = m.colorscale;
- R_FillColors(m.color, m.numverts, cl, cl, cl, 1);
- R_Mesh_Render();
- }
+ R_Mesh_ResizeCheck(mesh->numverts, mesh->numtriangles);
+ memcpy(varray_element, mesh->index, mesh->numtriangles * sizeof(int[3]));
+ memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
+ memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
+ cl = mesh_colorscale;
+ R_FillColors(varray_color, mesh->numverts, cl, cl, cl, 1);
+ R_Mesh_Draw(mesh->numverts, mesh->numtriangles);
}
}
static void RSurfShader_OpaqueWall_Pass_BaseLightmap(const entity_render_t *ent, const msurface_t *surf)
{
const surfmesh_t *mesh;
- rmeshbufferinfo_t m;
+ rmeshstate_t m;
float cl;
memset(&m, 0, sizeof(m));
m.blendfunc1 = GL_ZERO;
m.blendfunc2 = GL_SRC_COLOR;
+ m.wantoverbright = true;
m.tex[0] = R_GetTexture(surf->lightmaptexture);
m.matrix = ent->matrix;
+ R_Mesh_State(&m);
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
- m.numtriangles = mesh->numtriangles;
- m.numverts = mesh->numverts;
- if (R_Mesh_Draw_GetBuffer(&m, true))
- {
- memcpy(m.index, mesh->index, m.numtriangles * sizeof(int[3]));
- memcpy(m.vertex, mesh->verts, m.numverts * sizeof(float[4]));
- memcpy(m.texcoords[0], mesh->uv, m.numverts * sizeof(float[2]));
- cl = (float) (1 << lightscalebit) * m.colorscale;
- R_FillColors(m.color, m.numverts, cl, cl, cl, 1);
- R_Mesh_Render();
- }
+ R_Mesh_ResizeCheck(mesh->numverts, mesh->numtriangles);
+ memcpy(varray_element, mesh->index, mesh->numtriangles * sizeof(int[3]));
+ memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
+ memcpy(varray_texcoord[0], mesh->uv, mesh->numverts * sizeof(float[2]));
+ cl = (float) (1 << lightscalebit) * mesh_colorscale;
+ R_FillColors(varray_color, mesh->numverts, cl, cl, cl, 1);
+ R_Mesh_Draw(mesh->numverts, mesh->numtriangles);
}
}
static void RSurfShader_OpaqueWall_Pass_Light(const entity_render_t *ent, const msurface_t *surf)
{
const surfmesh_t *mesh;
- rmeshbufferinfo_t m;
+ rmeshstate_t m;
if (surf->dlightframe != r_framecount)
return;
memset(&m, 0, sizeof(m));
m.blendfunc1 = GL_SRC_ALPHA;
m.blendfunc2 = GL_ONE;
+ m.wantoverbright = true;
m.tex[0] = R_GetTexture(surf->currenttexture->texture);
m.matrix = ent->matrix;
+ R_Mesh_State(&m);
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
if (RSurf_LightCheck(&ent->inversematrix, surf->dlightbits, mesh))
{
- m.numtriangles = mesh->numtriangles;
- m.numverts = mesh->numverts;
- if (R_Mesh_Draw_GetBuffer(&m, true))
- {
- memcpy(m.index, mesh->index, m.numtriangles * sizeof(int[3]));
- memcpy(m.vertex, mesh->verts, m.numverts * sizeof(float[4]));
- memcpy(m.texcoords[0], mesh->st, m.numverts * sizeof(float[2]));
- R_FillColors(m.color, m.numverts, 0, 0, 0, 1);
- RSurf_LightSeparate(&ent->inversematrix, surf->dlightbits, m.numverts, m.vertex, m.color);
- RSurf_ScaleColors(m.color, m.colorscale, m.numverts);
- R_Mesh_Render();
- }
+ R_Mesh_ResizeCheck(mesh->numverts, mesh->numtriangles);
+ memcpy(varray_element, mesh->index, mesh->numtriangles * sizeof(int[3]));
+ 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, 0, 0, 0, 1);
+ RSurf_LightSeparate(&ent->inversematrix, surf->dlightbits, mesh->numverts, varray_vertex, varray_color);
+ RSurf_ScaleColors(varray_color, mesh_colorscale, mesh->numverts);
+ R_Mesh_Draw(mesh->numverts, mesh->numtriangles);
}
}
}
static void RSurfShader_OpaqueWall_Pass_Fog(const entity_render_t *ent, const msurface_t *surf)
{
const surfmesh_t *mesh;
- rmeshbufferinfo_t m;
+ rmeshstate_t m;
float modelorg[3];
Matrix4x4_Transform(&ent->inversematrix, r_origin, modelorg);
memset(&m, 0, sizeof(m));
m.blendfunc1 = GL_SRC_ALPHA;
m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
+ m.wantoverbright = false;
m.tex[0] = R_GetTexture(surf->currenttexture->fogtexture);
m.matrix = ent->matrix;
+ R_Mesh_State(&m);
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
- m.numtriangles = mesh->numtriangles;
- m.numverts = mesh->numverts;
- if (R_Mesh_Draw_GetBuffer(&m, false))
- {
- memcpy(m.index, mesh->index, m.numtriangles * sizeof(int[3]));
- memcpy(m.vertex, mesh->verts, m.numverts * sizeof(float[4]));
- if (m.tex[0])
- memcpy(m.texcoords[0], mesh->st, m.numverts * sizeof(float[2]));
- RSurf_FogPassColors(m.vertex, m.color, fogcolor[0], fogcolor[1], fogcolor[2], 1, m.colorscale, m.numverts, modelorg);
- R_Mesh_Render();
- }
+ R_Mesh_ResizeCheck(mesh->numverts, mesh->numtriangles);
+ memcpy(varray_element, mesh->index, mesh->numtriangles * sizeof(int[3]));
+ memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
+ if (m.tex[0])
+ memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
+ RSurf_FogPassColors(varray_vertex, varray_color, fogcolor[0], fogcolor[1], fogcolor[2], 1, mesh_colorscale, mesh->numverts, modelorg);
+ R_Mesh_Draw(mesh->numverts, mesh->numtriangles);
}
}
static void RSurfShader_OpaqueWall_Pass_BaseDetail(const entity_render_t *ent, const msurface_t *surf)
{
const surfmesh_t *mesh;
- rmeshbufferinfo_t m;
+ rmeshstate_t m;
memset(&m, 0, sizeof(m));
m.blendfunc1 = GL_DST_COLOR;
m.blendfunc2 = GL_SRC_COLOR;
+ m.wantoverbright = false;
m.tex[0] = R_GetTexture(surf->currenttexture->detailtexture);
m.matrix = ent->matrix;
+ R_Mesh_State(&m);
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
- m.numtriangles = mesh->numtriangles;
- m.numverts = mesh->numverts;
- if (R_Mesh_Draw_GetBuffer(&m, false))
- {
- memcpy(m.index, mesh->index, m.numtriangles * sizeof(int[3]));
- memcpy(m.vertex, mesh->verts, m.numverts * sizeof(float[4]));
- memcpy(m.texcoords[0], mesh->ab, m.numverts * sizeof(float[2]));
- R_FillColors(m.color, m.numverts, 1, 1, 1, 1);
- R_Mesh_Render();
- }
+ R_Mesh_ResizeCheck(mesh->numverts, mesh->numtriangles);
+ memcpy(varray_element, mesh->index, mesh->numtriangles * sizeof(int[3]));
+ 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);
}
}
static void RSurfShader_OpaqueWall_Pass_Glow(const entity_render_t *ent, const msurface_t *surf)
{
const surfmesh_t *mesh;
- rmeshbufferinfo_t m;
+ rmeshstate_t m;
memset(&m, 0, sizeof(m));
m.blendfunc1 = GL_SRC_ALPHA;
m.blendfunc2 = GL_ONE;
+ m.wantoverbright = false;
m.tex[0] = R_GetTexture(surf->currenttexture->glowtexture);
m.matrix = ent->matrix;
+ R_Mesh_State(&m);
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
- m.numtriangles = mesh->numtriangles;
- m.numverts = mesh->numverts;
- if (R_Mesh_Draw_GetBuffer(&m, false))
- {
- memcpy(m.index, mesh->index, m.numtriangles * sizeof(int[3]));
- memcpy(m.vertex, mesh->verts, m.numverts * sizeof(float[4]));
- memcpy(m.texcoords[0], mesh->st, m.numverts * sizeof(float[2]));
- R_FillColors(m.color, m.numverts, m.colorscale, m.colorscale, m.colorscale, 1);
- R_Mesh_Render();
- }
+ R_Mesh_ResizeCheck(mesh->numverts, mesh->numtriangles);
+ memcpy(varray_element, mesh->index, mesh->numtriangles * sizeof(int[3]));
+ 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, mesh_colorscale, mesh_colorscale, mesh_colorscale, 1);
+ R_Mesh_Draw(mesh->numverts, mesh->numtriangles);
}
}
{
int i;
float *v;
- rmeshbufferinfo_t m;
+ rmeshstate_t m;
const entity_render_t *ent = calldata1;
const mportal_t *portal = ent->model->portals + calldata2;
memset(&m, 0, sizeof(m));
m.blendfunc1 = GL_SRC_ALPHA;
m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
- m.numverts = portal->numpoints;
- m.numtriangles = portal->numpoints - 2;
+ m.wantoverbright = false;
m.matrix = ent->matrix;
- if (R_Mesh_Draw_GetBuffer(&m, false))
+ R_Mesh_State(&m);
+ R_Mesh_ResizeCheck(portal->numpoints, portal->numpoints - 2);
+ for (i = 0;i < mesh->numtriangles;i++)
{
- for (i = 0;i < m.numtriangles;i++)
- {
- m.index[i * 3 + 0] = 0;
- m.index[i * 3 + 1] = i + 1;
- m.index[i * 3 + 2] = i + 2;
- }
- i = portal - ent->model->portals;
- R_FillColors(m.color, m.numverts,
- ((i & 0x0007) >> 0) * (1.0f / 7.0f) * m.colorscale,
- ((i & 0x0038) >> 3) * (1.0f / 7.0f) * m.colorscale,
- ((i & 0x01C0) >> 6) * (1.0f / 7.0f) * m.colorscale,
- 0.125f);
- if (PlaneDiff(r_origin, (&portal->plane)) > 0)
- {
- for (i = portal->numpoints - 1, v = m.vertex;i >= 0;i--, v += 4)
- VectorCopy(portal->points[i].position, v);
- }
- else
- for (i = 0, v = m.vertex;i < portal->numpoints;i++, v += 4)
- VectorCopy(portal->points[i].position, v);
- R_Mesh_Render();
+ varray_element[i * 3 + 0] = 0;
+ varray_element[i * 3 + 1] = i + 1;
+ varray_element[i * 3 + 2] = i + 2;
}
+ i = portal - ent->model->portals;
+ R_FillColors(varray_color, mesh->numverts,
+ ((i & 0x0007) >> 0) * (1.0f / 7.0f) * mesh_colorscale,
+ ((i & 0x0038) >> 3) * (1.0f / 7.0f) * mesh_colorscale,
+ ((i & 0x01C0) >> 6) * (1.0f / 7.0f) * mesh_colorscale,
+ 0.125f);
+ if (PlaneDiff(r_origin, (&portal->plane)) > 0)
+ {
+ for (i = portal->numpoints - 1, v = varray_vertex;i >= 0;i--, v += 4)
+ VectorCopy(portal->points[i].position, v);
+ }
+ else
+ for (i = 0, v = varray_vertex;i < portal->numpoints;i++, v += 4)
+ VectorCopy(portal->points[i].position, v);
+ R_Mesh_Draw(portal->numpoints, portal->numpoints - 2);
}
static void R_DrawPortals(entity_render_t *ent)
void R_DrawCrosshairSprite(rtexture_t *texture, vec3_t origin, vec_t scale, float cr, float cg, float cb, float ca)
{
- rmeshbufferinfo_t m;
+ rmeshstate_t m;
float diff[3];
if (fogenabled)
memset(&m, 0, sizeof(m));
m.blendfunc1 = GL_SRC_ALPHA;
m.blendfunc2 = GL_ONE;
+ m.wantoverbright = false;
m.depthdisable = true;
- m.numtriangles = 2;
- m.numverts = 4;
m.tex[0] = R_GetTexture(texture);
Matrix4x4_CreateIdentity(&m.matrix);
- if (R_Mesh_Draw_GetBuffer(&m, false))
- {
- m.index[0] = 0;
- m.index[1] = 1;
- m.index[2] = 2;
- m.index[3] = 0;
- m.index[4] = 2;
- m.index[5] = 3;
- m.color[0] = m.color[4] = m.color[8] = m.color[12] = cr * m.colorscale;
- m.color[1] = m.color[5] = m.color[9] = m.color[13] = cg * m.colorscale;
- m.color[2] = m.color[6] = m.color[10] = m.color[14] = cb * m.colorscale;
- m.color[3] = m.color[7] = m.color[11] = m.color[15] = ca;
- m.texcoords[0][0] = 0;
- m.texcoords[0][1] = 0;
- m.texcoords[0][2] = 0;
- m.texcoords[0][3] = 1;
- m.texcoords[0][4] = 1;
- m.texcoords[0][5] = 1;
- m.texcoords[0][6] = 1;
- m.texcoords[0][7] = 0;
- m.vertex[0] = origin[0] - vright[0] * scale - vup[0] * scale;
- m.vertex[1] = origin[1] - vright[1] * scale - vup[1] * scale;
- m.vertex[2] = origin[2] - vright[2] * scale - vup[2] * scale;
- m.vertex[4] = origin[0] - vright[0] * scale + vup[0] * scale;
- m.vertex[5] = origin[1] - vright[1] * scale + vup[1] * scale;
- m.vertex[6] = origin[2] - vright[2] * scale + vup[2] * scale;
- m.vertex[8] = origin[0] + vright[0] * scale + vup[0] * scale;
- m.vertex[9] = origin[1] + vright[1] * scale + vup[1] * scale;
- m.vertex[10] = origin[2] + vright[2] * scale + vup[2] * scale;
- m.vertex[12] = origin[0] + vright[0] * scale - vup[0] * scale;
- m.vertex[13] = origin[1] + vright[1] * scale - vup[1] * scale;
- m.vertex[14] = origin[2] + vright[2] * scale - vup[2] * scale;
- R_Mesh_Render();
- }
+ R_Mesh_State(&m);
+
+ varray_element[0] = 0;
+ varray_element[1] = 1;
+ varray_element[2] = 2;
+ varray_element[3] = 0;
+ varray_element[4] = 2;
+ varray_element[5] = 3;
+ varray_color[0] = varray_color[4] = varray_color[8] = varray_color[12] = cr * mesh_colorscale;
+ varray_color[1] = varray_color[5] = varray_color[9] = varray_color[13] = cg * mesh_colorscale;
+ varray_color[2] = varray_color[6] = varray_color[10] = varray_color[14] = cb * mesh_colorscale;
+ 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] = 0;
+ varray_texcoord[0][3] = 1;
+ varray_texcoord[0][4] = 1;
+ varray_texcoord[0][5] = 1;
+ varray_texcoord[0][6] = 1;
+ varray_texcoord[0][7] = 0;
+ varray_vertex[0] = origin[0] - vright[0] * scale - vup[0] * scale;
+ varray_vertex[1] = origin[1] - vright[1] * scale - vup[1] * scale;
+ varray_vertex[2] = origin[2] - vright[2] * scale - vup[2] * scale;
+ varray_vertex[4] = origin[0] - vright[0] * scale + vup[0] * scale;
+ varray_vertex[5] = origin[1] - vright[1] * scale + vup[1] * scale;
+ varray_vertex[6] = origin[2] - vright[2] * scale + vup[2] * scale;
+ varray_vertex[8] = origin[0] + vright[0] * scale + vup[0] * scale;
+ varray_vertex[9] = origin[1] + vright[1] * scale + vup[1] * scale;
+ varray_vertex[10] = origin[2] + vright[2] * scale + vup[2] * scale;
+ varray_vertex[12] = origin[0] + vright[0] * scale - vup[0] * scale;
+ varray_vertex[13] = origin[1] + vright[1] * scale - vup[1] * scale;
+ varray_vertex[14] = origin[2] + vright[2] * scale - vup[2] * scale;
+ R_Mesh_Draw(4, 2);
}
void R_DrawCrosshair(void)
void R_DrawExplosionCallback(const void *calldata1, int calldata2)
{
- int i;
+ int i, numtriangles, numverts;
float *c, *v, diff[3], centerdir[3], ifog, alpha, dist;
- rmeshbufferinfo_t m;
+ rmeshstate_t m;
const explosion_t *e;
e = calldata1;
memset(&m, 0, sizeof(m));
m.blendfunc1 = GL_SRC_ALPHA;
m.blendfunc2 = GL_ONE;
- m.numtriangles = EXPLOSIONTRIS;
- m.numverts = EXPLOSIONVERTS;
+ m.wantoverbright = false;
m.tex[0] = R_GetTexture(explosiontexture);
Matrix4x4_CreateIdentity(&m.matrix);
- if (R_Mesh_Draw_GetBuffer(&m, false))
+ R_Mesh_State(&m);
+
+ numtriangles = EXPLOSIONTRIS;
+ numverts = EXPLOSIONVERTS;
+ R_Mesh_ResizeCheck(numverts, numtriangles);
+
+ memcpy(varray_element, explosiontris, numtriangles * sizeof(int[3]));
+ for (i = 0, v = varray_vertex;i < numverts;i++, v += 4)
{
- memcpy(m.index, explosiontris, m.numtriangles * sizeof(int[3]));
- for (i = 0, v = m.vertex;i < m.numverts;i++, v += 4)
- {
- v[0] = e->vert[i][0];
- v[1] = e->vert[i][1];
- v[2] = e->vert[i][2];
- }
- memcpy(m.texcoords[0], explosiontexcoords, m.numverts * sizeof(float[2]));
- alpha = e->alpha;
- VectorSubtract(r_origin, e->origin, centerdir);
- VectorNormalizeFast(centerdir);
- if (fogenabled)
- {
- for (i = 0, c = m.color;i < EXPLOSIONVERTS;i++, c += 4)
- {
- VectorSubtract(e->vert[i], e->origin, diff);
- VectorNormalizeFast(diff);
- dist = (DotProduct(diff, centerdir) * 6.0f - 4.0f) * alpha;
- if (dist > 0)
- {
- // use inverse fog alpha
- VectorSubtract(e->vert[i], r_origin, diff);
- ifog = 1 - exp(fogdensity/DotProduct(diff,diff));
- dist = dist * ifog;
- if (dist < 0)
- dist = 0;
- else
- dist *= m.colorscale;
- }
- else
- dist = 0;
- c[0] = c[1] = c[2] = dist;
- c[3] = 1;
- }
- }
- else
+ v[0] = e->vert[i][0];
+ v[1] = e->vert[i][1];
+ v[2] = e->vert[i][2];
+ }
+ memcpy(varray_texcoord[0], explosiontexcoords, numverts * sizeof(float[2]));
+ alpha = e->alpha;
+ VectorSubtract(r_origin, e->origin, centerdir);
+ VectorNormalizeFast(centerdir);
+ if (fogenabled)
+ {
+ for (i = 0, c = varray_color;i < EXPLOSIONVERTS;i++, c += 4)
{
- for (i = 0, c = m.color;i < EXPLOSIONVERTS;i++, c += 4)
+ VectorSubtract(e->vert[i], e->origin, diff);
+ VectorNormalizeFast(diff);
+ dist = (DotProduct(diff, centerdir) * 6.0f - 4.0f) * alpha;
+ if (dist > 0)
{
- VectorSubtract(e->vert[i], e->origin, diff);
- VectorNormalizeFast(diff);
- dist = (DotProduct(diff, centerdir) * 6.0f - 4.0f) * alpha;
+ // use inverse fog alpha
+ VectorSubtract(e->vert[i], r_origin, diff);
+ ifog = 1 - exp(fogdensity/DotProduct(diff,diff));
+ dist = dist * ifog;
if (dist < 0)
dist = 0;
else
- dist *= m.colorscale;
- c[0] = c[1] = c[2] = dist;
- c[3] = 1;
+ dist *= mesh_colorscale;
}
+ else
+ dist = 0;
+ c[0] = c[1] = c[2] = dist;
+ c[3] = 1;
+ }
+ }
+ else
+ {
+ for (i = 0, c = varray_color;i < EXPLOSIONVERTS;i++, c += 4)
+ {
+ VectorSubtract(e->vert[i], e->origin, diff);
+ VectorNormalizeFast(diff);
+ dist = (DotProduct(diff, centerdir) * 6.0f - 4.0f) * alpha;
+ if (dist < 0)
+ dist = 0;
+ else
+ dist *= mesh_colorscale;
+ c[0] = c[1] = c[2] = dist;
+ c[3] = 1;
}
- R_Mesh_Render();
}
+ R_Mesh_Draw(numverts, numtriangles);
}
void R_MoveExplosion(explosion_t *e)
void R_DrawCoronas(void)
{
int i;
- rmeshbufferinfo_t m;
+ rmeshstate_t m;
float scale, viewdist, diff[3], dist;
rdlight_t *rd;
if (!r_coronas.integer)
memset(&m, 0, sizeof(m));
m.blendfunc1 = GL_ONE;
m.blendfunc2 = GL_ONE;
+ m.wantoverbright = false;
m.depthdisable = true; // magic
- m.numtriangles = 2;
- m.numverts = 4;
m.tex[0] = R_GetTexture(lightcorona);
+ Matrix4x4_CreateIdentity(&m.matrix);
+ R_Mesh_State(&m);
viewdist = DotProduct(r_origin, vpn);
for (i = 0;i < r_numdlights;i++)
{
rd = r_dlight + i;
dist = (DotProduct(rd->origin, vpn) - viewdist);
- if (dist >= 24.0f)
+ if (dist >= 24.0f && CL_TraceLine(rd->origin, r_origin, NULL, NULL, 0, true) == 1)
{
- if (CL_TraceLine(rd->origin, r_origin, NULL, NULL, 0, true) == 1)
+ scale = mesh_colorscale * (1.0f / 131072.0f);
+ if (gl_flashblend.integer)
+ scale *= 4.0f;
+ if (fogenabled)
{
- Matrix4x4_CreateIdentity(&m.matrix);
- if (R_Mesh_Draw_GetBuffer(&m, false))
- {
- scale = m.colorscale * (1.0f / 131072.0f);
- if (gl_flashblend.integer)
- scale *= 4.0f;
- if (fogenabled)
- {
- VectorSubtract(rd->origin, r_origin, diff);
- scale *= 1 - exp(fogdensity/DotProduct(diff,diff));
- }
- m.index[0] = 0;
- m.index[1] = 1;
- m.index[2] = 2;
- m.index[3] = 0;
- m.index[4] = 2;
- m.index[5] = 3;
- m.color[0] = m.color[4] = m.color[8] = m.color[12] = rd->light[0] * scale;
- m.color[1] = m.color[5] = m.color[9] = m.color[13] = rd->light[1] * scale;
- m.color[2] = m.color[6] = m.color[10] = m.color[14] = rd->light[2] * scale;
- m.color[3] = m.color[7] = m.color[11] = m.color[15] = 1;
- m.texcoords[0][0] = 0;
- m.texcoords[0][1] = 0;
- m.texcoords[0][2] = 0;
- m.texcoords[0][3] = 1;
- m.texcoords[0][4] = 1;
- m.texcoords[0][5] = 1;
- m.texcoords[0][6] = 1;
- m.texcoords[0][7] = 0;
- scale = rd->cullradius * 0.25f;
- if (gl_flashblend.integer)
- scale *= 2.0f;
- m.vertex[0] = rd->origin[0] - vright[0] * scale - vup[0] * scale;
- m.vertex[1] = rd->origin[1] - vright[1] * scale - vup[1] * scale;
- m.vertex[2] = rd->origin[2] - vright[2] * scale - vup[2] * scale;
- m.vertex[4] = rd->origin[0] - vright[0] * scale + vup[0] * scale;
- m.vertex[5] = rd->origin[1] - vright[1] * scale + vup[1] * scale;
- m.vertex[6] = rd->origin[2] - vright[2] * scale + vup[2] * scale;
- m.vertex[8] = rd->origin[0] + vright[0] * scale + vup[0] * scale;
- m.vertex[9] = rd->origin[1] + vright[1] * scale + vup[1] * scale;
- m.vertex[10] = rd->origin[2] + vright[2] * scale + vup[2] * scale;
- m.vertex[12] = rd->origin[0] + vright[0] * scale - vup[0] * scale;
- m.vertex[13] = rd->origin[1] + vright[1] * scale - vup[1] * scale;
- m.vertex[14] = rd->origin[2] + vright[2] * scale - vup[2] * scale;
- R_Mesh_Render();
- }
+ VectorSubtract(rd->origin, r_origin, diff);
+ scale *= 1 - exp(fogdensity/DotProduct(diff,diff));
}
+ varray_element[0] = 0;
+ varray_element[1] = 1;
+ varray_element[2] = 2;
+ varray_element[3] = 0;
+ varray_element[4] = 2;
+ varray_element[5] = 3;
+ 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;
+ varray_texcoord[0][0] = 0;
+ varray_texcoord[0][1] = 0;
+ varray_texcoord[0][2] = 0;
+ varray_texcoord[0][3] = 1;
+ varray_texcoord[0][4] = 1;
+ varray_texcoord[0][5] = 1;
+ varray_texcoord[0][6] = 1;
+ varray_texcoord[0][7] = 0;
+ scale = rd->cullradius * 0.25f;
+ if (gl_flashblend.integer)
+ scale *= 2.0f;
+ varray_vertex[0] = rd->origin[0] - vright[0] * scale - vup[0] * scale;
+ varray_vertex[1] = rd->origin[1] - vright[1] * scale - vup[1] * scale;
+ varray_vertex[2] = rd->origin[2] - vright[2] * scale - vup[2] * scale;
+ varray_vertex[4] = rd->origin[0] - vright[0] * scale + vup[0] * scale;
+ varray_vertex[5] = rd->origin[1] - vright[1] * scale + vup[1] * scale;
+ varray_vertex[6] = rd->origin[2] - vright[2] * scale + vup[2] * scale;
+ varray_vertex[8] = rd->origin[0] + vright[0] * scale + vup[0] * scale;
+ varray_vertex[9] = rd->origin[1] + vright[1] * scale + vup[1] * scale;
+ varray_vertex[10] = rd->origin[2] + vright[2] * scale + vup[2] * scale;
+ varray_vertex[12] = rd->origin[0] + vright[0] * scale - vup[0] * scale;
+ varray_vertex[13] = rd->origin[1] + vright[1] * scale - vup[1] * scale;
+ varray_vertex[14] = rd->origin[2] + vright[2] * scale - vup[2] * scale;
+ R_Mesh_Draw(4, 2);
}
}
}
static void R_SkyBox(void)
{
- rmeshbufferinfo_t m;
+ rmeshstate_t m;
#define R_SkyBoxPolyVec(i,s,t,x,y,z) \
- m.vertex[i * 4 + 0] = (x) * 16.0f;\
- m.vertex[i * 4 + 1] = (y) * 16.0f;\
- m.vertex[i * 4 + 2] = (z) * 16.0f;\
- m.texcoords[0][i * 2 + 0] = (s) * (254.0f/256.0f) + (1.0f/256.0f);\
- m.texcoords[0][i * 2 + 1] = (t) * (254.0f/256.0f) + (1.0f/256.0f);
+ varray_vertex[i * 4 + 0] = (x) * 16.0f;\
+ varray_vertex[i * 4 + 1] = (y) * 16.0f;\
+ varray_vertex[i * 4 + 2] = (z) * 16.0f;\
+ varray_texcoord[0][i * 2 + 0] = (s) * (254.0f/256.0f) + (1.0f/256.0f);\
+ varray_texcoord[0][i * 2 + 1] = (t) * (254.0f/256.0f) + (1.0f/256.0f);
memset(&m, 0, sizeof(m));
m.blendfunc1 = GL_ONE;
m.blendfunc2 = GL_ZERO;
+ m.wantoverbright = false;
m.depthdisable = true; // don't modify or read zbuffer
- m.numtriangles = 2;
- m.numverts = 4;
m.tex[0] = R_GetTexture(skyboxside[3]); // front
Matrix4x4_CreateTranslate(&m.matrix, r_origin[0], r_origin[1], r_origin[2]);
- if (R_Mesh_Draw_GetBuffer(&m, false))
- {
- memcpy(m.index, skyboxindex, sizeof(int[6]));
- m.color[0] = m.color[4] = m.color[8] = m.color[12] = m.colorscale;
- m.color[1] = m.color[5] = m.color[9] = m.color[13] = m.colorscale;
- m.color[2] = m.color[6] = m.color[10] = m.color[14] = m.colorscale;
- m.color[3] = m.color[7] = m.color[11] = m.color[15] = 1;
- R_SkyBoxPolyVec(0, 1, 0, 1, -1, 1);
- R_SkyBoxPolyVec(1, 1, 1, 1, -1, -1);
- R_SkyBoxPolyVec(2, 0, 1, 1, 1, -1);
- R_SkyBoxPolyVec(3, 0, 0, 1, 1, 1);
- R_Mesh_Render();
- }
+ R_Mesh_State(&m);
+
+ memcpy(varray_element, skyboxindex, sizeof(int[6]));
+ varray_color[0] = varray_color[4] = varray_color[8] = varray_color[12] = mesh_colorscale;
+ varray_color[1] = varray_color[5] = varray_color[9] = varray_color[13] = mesh_colorscale;
+ varray_color[2] = varray_color[6] = varray_color[10] = varray_color[14] = mesh_colorscale;
+ varray_color[3] = varray_color[7] = varray_color[11] = varray_color[15] = 1;
+ R_SkyBoxPolyVec(0, 1, 0, 1, -1, 1);
+ R_SkyBoxPolyVec(1, 1, 1, 1, -1, -1);
+ R_SkyBoxPolyVec(2, 0, 1, 1, 1, -1);
+ R_SkyBoxPolyVec(3, 0, 0, 1, 1, 1);
+ R_Mesh_Draw(4, 2);
m.tex[0] = R_GetTexture(skyboxside[1]); // back
- if (R_Mesh_Draw_GetBuffer(&m, false))
- {
- memcpy(m.index, skyboxindex, sizeof(int[6]));
- m.color[0] = m.color[4] = m.color[8] = m.color[12] = m.colorscale;
- m.color[1] = m.color[5] = m.color[9] = m.color[13] = m.colorscale;
- m.color[2] = m.color[6] = m.color[10] = m.color[14] = m.colorscale;
- m.color[3] = m.color[7] = m.color[11] = m.color[15] = 1;
- R_SkyBoxPolyVec(0, 1, 0, -1, 1, 1);
- R_SkyBoxPolyVec(1, 1, 1, -1, 1, -1);
- R_SkyBoxPolyVec(2, 0, 1, -1, -1, -1);
- R_SkyBoxPolyVec(3, 0, 0, -1, -1, 1);
- R_Mesh_Render();
- }
+ R_Mesh_State(&m);
+ memcpy(varray_element, skyboxindex, sizeof(int[6]));
+ varray_color[0] = varray_color[4] = varray_color[8] = varray_color[12] = mesh_colorscale;
+ varray_color[1] = varray_color[5] = varray_color[9] = varray_color[13] = mesh_colorscale;
+ varray_color[2] = varray_color[6] = varray_color[10] = varray_color[14] = mesh_colorscale;
+ varray_color[3] = varray_color[7] = varray_color[11] = varray_color[15] = 1;
+ R_SkyBoxPolyVec(0, 1, 0, -1, 1, 1);
+ R_SkyBoxPolyVec(1, 1, 1, -1, 1, -1);
+ R_SkyBoxPolyVec(2, 0, 1, -1, -1, -1);
+ R_SkyBoxPolyVec(3, 0, 0, -1, -1, 1);
+ R_Mesh_Draw(4, 2);
m.tex[0] = R_GetTexture(skyboxside[0]); // right
- if (R_Mesh_Draw_GetBuffer(&m, false))
- {
- memcpy(m.index, skyboxindex, sizeof(int[6]));
- m.color[0] = m.color[4] = m.color[8] = m.color[12] = m.colorscale;
- m.color[1] = m.color[5] = m.color[9] = m.color[13] = m.colorscale;
- m.color[2] = m.color[6] = m.color[10] = m.color[14] = m.colorscale;
- m.color[3] = m.color[7] = m.color[11] = m.color[15] = 1;
- R_SkyBoxPolyVec(0, 1, 0, 1, 1, 1);
- R_SkyBoxPolyVec(1, 1, 1, 1, 1, -1);
- R_SkyBoxPolyVec(2, 0, 1, -1, 1, -1);
- R_SkyBoxPolyVec(3, 0, 0, -1, 1, 1);
- R_Mesh_Render();
- }
+ R_Mesh_State(&m);
+ memcpy(varray_element, skyboxindex, sizeof(int[6]));
+ varray_color[0] = varray_color[4] = varray_color[8] = varray_color[12] = mesh_colorscale;
+ varray_color[1] = varray_color[5] = varray_color[9] = varray_color[13] = mesh_colorscale;
+ varray_color[2] = varray_color[6] = varray_color[10] = varray_color[14] = mesh_colorscale;
+ varray_color[3] = varray_color[7] = varray_color[11] = varray_color[15] = 1;
+ R_SkyBoxPolyVec(0, 1, 0, 1, 1, 1);
+ R_SkyBoxPolyVec(1, 1, 1, 1, 1, -1);
+ R_SkyBoxPolyVec(2, 0, 1, -1, 1, -1);
+ R_SkyBoxPolyVec(3, 0, 0, -1, 1, 1);
+ R_Mesh_Draw(4, 2);
m.tex[0] = R_GetTexture(skyboxside[2]); // left
- if (R_Mesh_Draw_GetBuffer(&m, false))
- {
- memcpy(m.index, skyboxindex, sizeof(int[6]));
- m.color[0] = m.color[4] = m.color[8] = m.color[12] = m.colorscale;
- m.color[1] = m.color[5] = m.color[9] = m.color[13] = m.colorscale;
- m.color[2] = m.color[6] = m.color[10] = m.color[14] = m.colorscale;
- m.color[3] = m.color[7] = m.color[11] = m.color[15] = 1;
- R_SkyBoxPolyVec(0, 1, 0, -1, -1, 1);
- R_SkyBoxPolyVec(1, 1, 1, -1, -1, -1);
- R_SkyBoxPolyVec(2, 0, 1, 1, -1, -1);
- R_SkyBoxPolyVec(3, 0, 0, 1, -1, 1);
- R_Mesh_Render();
- }
+ R_Mesh_State(&m);
+ memcpy(varray_element, skyboxindex, sizeof(int[6]));
+ varray_color[0] = varray_color[4] = varray_color[8] = varray_color[12] = mesh_colorscale;
+ varray_color[1] = varray_color[5] = varray_color[9] = varray_color[13] = mesh_colorscale;
+ varray_color[2] = varray_color[6] = varray_color[10] = varray_color[14] = mesh_colorscale;
+ varray_color[3] = varray_color[7] = varray_color[11] = varray_color[15] = 1;
+ R_SkyBoxPolyVec(0, 1, 0, -1, -1, 1);
+ R_SkyBoxPolyVec(1, 1, 1, -1, -1, -1);
+ R_SkyBoxPolyVec(2, 0, 1, 1, -1, -1);
+ R_SkyBoxPolyVec(3, 0, 0, 1, -1, 1);
+ R_Mesh_Draw(4, 2);
m.tex[0] = R_GetTexture(skyboxside[4]); // up
- if (R_Mesh_Draw_GetBuffer(&m, false))
- {
- memcpy(m.index, skyboxindex, sizeof(int[6]));
- m.color[0] = m.color[4] = m.color[8] = m.color[12] = m.colorscale;
- m.color[1] = m.color[5] = m.color[9] = m.color[13] = m.colorscale;
- m.color[2] = m.color[6] = m.color[10] = m.color[14] = m.colorscale;
- m.color[3] = m.color[7] = m.color[11] = m.color[15] = 1;
- R_SkyBoxPolyVec(0, 1, 0, 1, -1, 1);
- R_SkyBoxPolyVec(1, 1, 1, 1, 1, 1);
- R_SkyBoxPolyVec(2, 0, 1, -1, 1, 1);
- R_SkyBoxPolyVec(3, 0, 0, -1, -1, 1);
- R_Mesh_Render();
- }
+ R_Mesh_State(&m);
+ memcpy(varray_element, skyboxindex, sizeof(int[6]));
+ varray_color[0] = varray_color[4] = varray_color[8] = varray_color[12] = mesh_colorscale;
+ varray_color[1] = varray_color[5] = varray_color[9] = varray_color[13] = mesh_colorscale;
+ varray_color[2] = varray_color[6] = varray_color[10] = varray_color[14] = mesh_colorscale;
+ varray_color[3] = varray_color[7] = varray_color[11] = varray_color[15] = 1;
+ R_SkyBoxPolyVec(0, 1, 0, 1, -1, 1);
+ R_SkyBoxPolyVec(1, 1, 1, 1, 1, 1);
+ R_SkyBoxPolyVec(2, 0, 1, -1, 1, 1);
+ R_SkyBoxPolyVec(3, 0, 0, -1, -1, 1);
+ R_Mesh_Draw(4, 2);
m.tex[0] = R_GetTexture(skyboxside[5]); // down
- if (R_Mesh_Draw_GetBuffer(&m, false))
- {
- memcpy(m.index, skyboxindex, sizeof(int[6]));
- m.color[0] = m.color[4] = m.color[8] = m.color[12] = m.colorscale;
- m.color[1] = m.color[5] = m.color[9] = m.color[13] = m.colorscale;
- m.color[2] = m.color[6] = m.color[10] = m.color[14] = m.colorscale;
- m.color[3] = m.color[7] = m.color[11] = m.color[15] = 1;
- R_SkyBoxPolyVec(0, 1, 0, 1, 1, -1);
- R_SkyBoxPolyVec(1, 1, 1, 1, -1, -1);
- R_SkyBoxPolyVec(2, 0, 1, -1, -1, -1);
- R_SkyBoxPolyVec(3, 0, 0, -1, 1, -1);
- R_Mesh_Render();
- }
+ R_Mesh_State(&m);
+ memcpy(varray_element, skyboxindex, sizeof(int[6]));
+ varray_color[0] = varray_color[4] = varray_color[8] = varray_color[12] = mesh_colorscale;
+ varray_color[1] = varray_color[5] = varray_color[9] = varray_color[13] = mesh_colorscale;
+ varray_color[2] = varray_color[6] = varray_color[10] = varray_color[14] = mesh_colorscale;
+ varray_color[3] = varray_color[7] = varray_color[11] = varray_color[15] = 1;
+ R_SkyBoxPolyVec(0, 1, 0, 1, 1, -1);
+ R_SkyBoxPolyVec(1, 1, 1, 1, -1, -1);
+ R_SkyBoxPolyVec(2, 0, 1, -1, -1, -1);
+ R_SkyBoxPolyVec(3, 0, 0, -1, 1, -1);
+ R_Mesh_Draw(4, 2);
}
-#define skygridx 16
+#define skygridx 32
#define skygridx1 (skygridx + 1)
#define skygridxrecip (1.0f / (skygridx))
#define skygridy 32
static void R_SkySphere(void)
{
+ int numverts, numtriangles;
float speedscale, speedscale2;
static qboolean skysphereinitialized = false;
- rmeshbufferinfo_t m;
+ rmeshstate_t m;
if (!skysphereinitialized)
{
skysphereinitialized = true;
speedscale2 = cl.time*16.0/128.0;
speedscale2 -= (int)speedscale2;
+ numverts = skygridx1*skygridy1;
+ numtriangles = skygridx*skygridy*2;
+
+ R_Mesh_ResizeCheck(numverts, numtriangles);
+
memset(&m, 0, sizeof(m));
m.blendfunc1 = GL_ONE;
m.blendfunc2 = GL_ZERO;
+ m.wantoverbright = false;
m.depthdisable = true; // don't modify or read zbuffer
- m.numtriangles = skygridx*skygridy*2;
- m.numverts = skygridx1*skygridy1;
m.tex[0] = R_GetTexture(solidskytexture);
Matrix4x4_CreateTranslate(&m.matrix, r_origin[0], r_origin[1], r_origin[2]);
- if (R_Mesh_Draw_GetBuffer(&m, false))
- {
- memcpy(m.index, skysphereindices, m.numtriangles * sizeof(int[3]));
- skyspherearrays(m.vertex, m.texcoords[0], m.color, skysphere, speedscale, m.colorscale);
- R_Mesh_Render();
- }
+ R_Mesh_State(&m);
+
+ memcpy(varray_element, skysphereindices, numtriangles * sizeof(int[3]));
+ skyspherearrays(varray_vertex, varray_texcoord[0], varray_color, skysphere, speedscale, mesh_colorscale);
+ R_Mesh_Draw(numverts, numtriangles);
+
m.blendfunc1 = GL_SRC_ALPHA;
m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
m.tex[0] = R_GetTexture(alphaskytexture);
- if (R_Mesh_Draw_GetBuffer(&m, false))
- {
- memcpy(m.index, skysphereindices, m.numtriangles * sizeof(int[3]));
- skyspherearrays(m.vertex, m.texcoords[0], m.color, skysphere, speedscale2, m.colorscale);
- R_Mesh_Render();
- }
+ R_Mesh_State(&m);
+
+ memcpy(varray_element, skysphereindices, numtriangles * sizeof(int[3]));
+ skyspherearrays(varray_vertex, varray_texcoord[0], varray_color, skysphere, speedscale2, mesh_colorscale);
+ R_Mesh_Draw(numverts, numtriangles);
}
void R_Sky(void)
static void R_DrawSpriteImage (int wantoverbright, int additive, mspriteframe_t *frame, int texture, vec3_t origin, vec3_t up, vec3_t left, float red, float green, float blue, float alpha)
{
- rmeshbufferinfo_t m;
+ rmeshstate_t m;
memset(&m, 0, sizeof(m));
m.blendfunc1 = GL_SRC_ALPHA;
m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
if (additive)
m.blendfunc2 = GL_ONE;
- m.numtriangles = 2;
- m.numverts = 4;
+ m.wantoverbright = wantoverbright;
m.tex[0] = texture;
Matrix4x4_CreateIdentity(&m.matrix);
- if (R_Mesh_Draw_GetBuffer(&m, wantoverbright))
- {
- m.index[0] = 0;
- m.index[1] = 1;
- m.index[2] = 2;
- m.index[3] = 0;
- m.index[4] = 2;
- m.index[5] = 3;
- m.color[0] = m.color[4] = m.color[8] = m.color[12] = red * m.colorscale;
- m.color[1] = m.color[5] = m.color[9] = m.color[13] = green * m.colorscale;
- m.color[2] = m.color[6] = m.color[10] = m.color[14] = blue * m.colorscale;
- m.color[3] = m.color[7] = m.color[11] = m.color[15] = alpha;
- m.texcoords[0][0] = 0;
- m.texcoords[0][1] = 1;
- m.texcoords[0][2] = 0;
- m.texcoords[0][3] = 0;
- m.texcoords[0][4] = 1;
- m.texcoords[0][5] = 0;
- m.texcoords[0][6] = 1;
- m.texcoords[0][7] = 1;
- // FIXME: negate left and right in loader
- m.vertex[0] = origin[0] + frame->down * up[0] - frame->left * left[0];
- m.vertex[1] = origin[1] + frame->down * up[1] - frame->left * left[1];
- m.vertex[2] = origin[2] + frame->down * up[2] - frame->left * left[2];
- m.vertex[4] = origin[0] + frame->up * up[0] - frame->left * left[0];
- m.vertex[5] = origin[1] + frame->up * up[1] - frame->left * left[1];
- m.vertex[6] = origin[2] + frame->up * up[2] - frame->left * left[2];
- m.vertex[8] = origin[0] + frame->up * up[0] - frame->right * left[0];
- m.vertex[9] = origin[1] + frame->up * up[1] - frame->right * left[1];
- m.vertex[10] = origin[2] + frame->up * up[2] - frame->right * left[2];
- m.vertex[12] = origin[0] + frame->down * up[0] - frame->right * left[0];
- m.vertex[13] = origin[1] + frame->down * up[1] - frame->right * left[1];
- m.vertex[14] = origin[2] + frame->down * up[2] - frame->right * left[2];
- R_Mesh_Render();
- }
+ R_Mesh_State(&m);
+
+ varray_element[0] = 0;
+ varray_element[1] = 1;
+ varray_element[2] = 2;
+ varray_element[3] = 0;
+ varray_element[4] = 2;
+ varray_element[5] = 3;
+ varray_color[0] = varray_color[4] = varray_color[8] = varray_color[12] = red * mesh_colorscale;
+ varray_color[1] = varray_color[5] = varray_color[9] = varray_color[13] = green * mesh_colorscale;
+ varray_color[2] = varray_color[6] = varray_color[10] = varray_color[14] = blue * mesh_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_texcoord[0][3] = 0;
+ varray_texcoord[0][4] = 1;
+ varray_texcoord[0][5] = 0;
+ varray_texcoord[0][6] = 1;
+ varray_texcoord[0][7] = 1;
+ // FIXME: negate left and right in loader
+ varray_vertex[0] = origin[0] + frame->down * up[0] - frame->left * left[0];
+ varray_vertex[1] = origin[1] + frame->down * up[1] - frame->left * left[1];
+ varray_vertex[2] = origin[2] + frame->down * up[2] - frame->left * left[2];
+ varray_vertex[4] = origin[0] + frame->up * up[0] - frame->left * left[0];
+ varray_vertex[5] = origin[1] + frame->up * up[1] - frame->left * left[1];
+ varray_vertex[6] = origin[2] + frame->up * up[2] - frame->left * left[2];
+ varray_vertex[8] = origin[0] + frame->up * up[0] - frame->right * left[0];
+ varray_vertex[9] = origin[1] + frame->up * up[1] - frame->right * left[1];
+ varray_vertex[10] = origin[2] + frame->up * up[2] - frame->right * left[2];
+ 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];
+ R_Mesh_Draw(4, 2);
}
void R_DrawSpriteModelCallback(const void *calldata1, int calldata2)