R_RegisterModule("R_Particles", r_part_start, r_part_shutdown, r_part_newmap);
}
-int partindexarray[6] = {0, 1, 2, 0, 2, 3};
-
void R_DrawParticleCallback(const void *calldata1, int calldata2)
{
int additive, texnum, orientation;
R_Mesh_Matrix(&r_identitymatrix);
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)
{
VectorScale(vright, p->scalex, right);
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);
+ R_Mesh_Draw(4, 2, polygonelements);
}
void R_DrawParticles (void)
#include "quakedef.h"
-cvar_t gl_mesh_maxtriangles = {0, "gl_mesh_maxtriangles", "1024"};
+cvar_t gl_mesh_maxverts = {0, "gl_mesh_maxverts", "1024"};
cvar_t gl_mesh_floatcolors = {0, "gl_mesh_floatcolors", "1"};
cvar_t gl_mesh_drawmode = {CVAR_SAVE, "gl_mesh_drawmode", "3"};
cvar_t gl_dither = {CVAR_SAVE, "gl_dither", "1"}; // whether or not to use dithering
cvar_t gl_lockarrays = {0, "gl_lockarrays", "1"};
-// this is used to increase gl_mesh_maxtriangles automatically if a mesh was
-// too large for the buffers in the previous frame
-int overflowedverts = 0;
-
int gl_maxdrawrangeelementsvertices;
int gl_maxdrawrangeelementsindices;
// 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
+int mesh_maxverts;
static matrix4x4_t backend_viewmatrix;
static matrix4x4_t backend_modelmatrix;
static qbyte *varray_bcolor;
static mempool_t *gl_backend_mempool;
+int polygonelements[768];
+
void GL_Backend_AllocArrays(void)
{
int i;
+ for (i = 0;i < POLYGONELEMENTS_MAXPOINTS - 2;i++)
+ {
+ polygonelements[i * 3 + 0] = 0;
+ polygonelements[i * 3 + 1] = i + 1;
+ polygonelements[i * 3 + 2] = i + 2;
+ }
+
if (!gl_backend_mempool)
gl_backend_mempool = Mem_AllocPool("GL_Backend");
- 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]));
Mem_EmptyPool(gl_backend_mempool);
else
Mem_FreePool(&gl_backend_mempool);
- varray_element = NULL;
varray_vertex = NULL;
varray_color = NULL;
varray_bcolor = NULL;
static void gl_backend_start(void)
{
- Con_Printf("OpenGL Backend started with gl_mesh_maxtriangles %i\n", gl_mesh_maxtriangles.integer);
+ Con_Printf("OpenGL Backend started with gl_mesh_maxverts %i\n", gl_mesh_maxverts.integer);
if (qglDrawRangeElements != NULL)
{
qglGetIntegerv(GL_MAX_ELEMENTS_VERTICES, &gl_maxdrawrangeelementsvertices);
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 (gl_mesh_maxverts.integer < 1024)
+ Cvar_SetValueQuick(&gl_mesh_maxverts, 1024);
+ if (gl_mesh_maxverts.integer > 21760)
+ Cvar_SetValueQuick(&gl_mesh_maxverts, 21760);
}
void GL_Backend_ResizeArrays(int numtriangles)
{
- Cvar_SetValueQuick(&gl_mesh_maxtriangles, numtriangles);
+ Cvar_SetValueQuick(&gl_mesh_maxverts, numtriangles);
GL_Backend_CheckCvars();
- mesh_maxtris = gl_mesh_maxtriangles.integer;
+ mesh_maxverts = gl_mesh_maxverts.integer;
GL_Backend_FreeArrays(true);
GL_Backend_AllocArrays();
}
Cvar_SetValue("r_render", 0);
#endif
- Cvar_RegisterVariable(&gl_mesh_maxtriangles);
+ Cvar_RegisterVariable(&gl_mesh_maxverts);
Cvar_RegisterVariable(&gl_mesh_floatcolors);
Cvar_RegisterVariable(&gl_mesh_drawmode);
GL_Backend_CheckCvars();
c_meshtris = 0;
GL_Backend_CheckCvars();
- if (mesh_maxtris != gl_mesh_maxtriangles.integer)
- GL_Backend_ResizeArrays(gl_mesh_maxtriangles.integer);
+ if (mesh_maxverts != gl_mesh_maxverts.integer)
+ GL_Backend_ResizeArrays(gl_mesh_maxverts.integer);
GL_SetupFrame();
}
// enlarges geometry buffers if they are too small
-void _R_Mesh_ResizeCheck(int numverts, int numtriangles)
+void _R_Mesh_ResizeCheck(int numverts)
{
- if (numtriangles > mesh_maxtris || numverts > mesh_maxverts)
+ if (numverts > mesh_maxverts)
{
BACKENDACTIVECHECK
- GL_Backend_ResizeArrays(max(numtriangles, (numverts + 2) / 3) + 100);
+ GL_Backend_ResizeArrays(numverts + 100);
GL_Backend_ResetState();
}
}
// renders the mesh
-void R_Mesh_Draw(int numverts, int numtriangles)
+void R_Mesh_Draw(int numverts, int numtriangles, int *elements)
{
BACKENDACTIVECHECK
//GL_TransformVertices(numverts);
if (!r_render.integer)
return;
- GL_DrawRangeElements(0, numverts, numtriangles * 3, varray_element);
+ GL_DrawRangeElements(0, numverts, numtriangles * 3, elements);
}
// restores backend state, used when done with 3D rendering
#define MAX_TEXTUREUNITS 8
+#define POLYGONELEMENTS_MAXPOINTS 258
+extern int polygonelements[768];
+
extern cvar_t gl_lockarrays;
extern int c_meshtris, c_meshs;
+//input to R_Mesh_State
typedef struct
{
- //input to R_Mesh_Draw_GetBuffer
int depthwrite; // force depth writing enabled even if polygon is not opaque
int depthdisable; // disable depth read/write entirely
int blendfunc1;
// 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);
// sets up the requested state
void R_Mesh_State(const rmeshstate_t *m);
-// 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);
+// enlarges vertex arrays if they are too small
+#define R_Mesh_ResizeCheck(numverts) if ((numverts) > mesh_maxverts) _R_Mesh_ResizeCheck(numverts);
+void _R_Mesh_ResizeCheck(int numverts);
// renders the mesh in the varray_* buffers
-void R_Mesh_Draw(int numverts, int numtriangles);
+void R_Mesh_Draw(int numverts, int numtriangles, int *elements);
// saves a section of the rendered frame to a .tga file
qboolean SCR_ScreenShot(char *filename, int x, int y, int width, int height);
}
model = ent->model;
- R_Mesh_ResizeCheck(model->numverts, model->numtris);
+ R_Mesh_ResizeCheck(model->numverts);
skinframe = R_FetchSkinFrame(ent);
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;
R_SetupMDLMD2Frames(ent, mesh_colorscale, mesh_colorscale, mesh_colorscale);
aliasvert = aliasvertbuf;
aliasvertcolor = aliasvertcolorbuf;
- R_Mesh_Draw(model->numverts, model->numtris);
+ R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
return;
}
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);
+ R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
return;
}
blendfunc2 = GL_ONE;
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);
+ R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
}
if (colormapped)
R_FillColors(varray_color, model->numverts, pantscolor[0] * mesh_colorscale, pantscolor[1] * mesh_colorscale, pantscolor[2] * mesh_colorscale, ent->alpha);
else
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);
+ R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
}
}
if (skinframe->shirt)
R_FillColors(varray_color, model->numverts, shirtcolor[0] * mesh_colorscale, shirtcolor[1] * mesh_colorscale, shirtcolor[2] * mesh_colorscale, ent->alpha);
else
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);
+ R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
}
}
}
blendfunc2 = GL_ONE;
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);
+ R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
}
}
if (fog)
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);
+ R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
}
}
{
float fog;
vec3_t diff;
- int i, *renderlist;
+ int i, *renderlist, *elements;
zymtype1header_t *m;
rtexture_t *texture;
rmeshstate_t mstate;
texture = ((rtexture_t **)(m->lump_shaders.start + (int) m))[shadernum];
numverts = m->numverts;
- numtriangles = renderlist[0];
- R_Mesh_ResizeCheck(numverts, numtriangles);
+ numtriangles = *renderlist++;
+ elements = renderlist;
+ R_Mesh_ResizeCheck(numverts);
fog = 0;
if (fogenabled)
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);
+ R_Mesh_Draw(numverts, numtriangles, elements);
if (fog)
{
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);
+ R_Mesh_Draw(numverts, numtriangles, elements);
}
}
R_Mesh_Matrix(&r_identitymatrix);
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_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);
+ R_Mesh_Draw(3, 1, polygonelements);
}
/*
R_Mesh_Matrix(&r_identitymatrix);
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];
void R_DrawNoModelCallback(const void *calldata1, int calldata2)
{
const entity_render_t *ent = calldata1;
- int i;
+ int i, element[24];
float f1, f2, *c, diff[3];
rmeshstate_t m;
memset(&m, 0, sizeof(m));
R_Mesh_Matrix(&ent->matrix);
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;
+ element[ 0] = 5;element[ 1] = 2;element[ 2] = 0;
+ element[ 3] = 5;element[ 4] = 1;element[ 5] = 2;
+ element[ 6] = 5;element[ 7] = 0;element[ 8] = 3;
+ element[ 9] = 5;element[10] = 3;element[11] = 1;
+ element[12] = 0;element[13] = 2;element[14] = 4;
+ element[15] = 2;element[16] = 1;element[17] = 4;
+ element[18] = 3;element[19] = 0;element[20] = 4;
+ element[21] = 1;element[22] = 3;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;
c[2] *= mesh_colorscale;
}
}
- R_Mesh_Draw(6, 8);
+ R_Mesh_Draw(6, 8, element);
}
void R_DrawNoModel(entity_render_t *ent)
{
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
- R_Mesh_ResizeCheck(mesh->numverts, mesh->numtriangles);
- memcpy(varray_element, mesh->index, mesh->numtriangles * sizeof(int[3]));
+ R_Mesh_ResizeCheck(mesh->numverts);
memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
if (skyrendermasked)
memset(varray_color, 0, mesh->numverts * sizeof(float[4]));
else
R_FillColors(varray_color, mesh->numverts, fogcolor[0] * mesh_colorscale, fogcolor[1] * mesh_colorscale, fogcolor[2] * mesh_colorscale, 1);
- R_Mesh_Draw(mesh->numverts, mesh->numtriangles);
+ R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
}
}
}
R_Mesh_State(&m);
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
- R_Mesh_ResizeCheck(mesh->numverts, mesh->numtriangles);
- memcpy(varray_element, mesh->index, mesh->numtriangles * sizeof(int[3]));
+ R_Mesh_ResizeCheck(mesh->numverts);
memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
f = surf->flags & SURF_DRAWFULLBRIGHT ? 1.0f : ((surf->flags & SURF_LIGHTMAP) ? 0 : 0.5f);
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);
+ R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
}
if (fogenabled)
R_Mesh_State(&m);
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
- R_Mesh_ResizeCheck(mesh->numverts, mesh->numtriangles);
- memcpy(varray_element, mesh->index, mesh->numtriangles * sizeof(int[3]));
+ R_Mesh_ResizeCheck(mesh->numverts);
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);
+ R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
}
}
}
R_Mesh_State(&m);
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
- R_Mesh_ResizeCheck(mesh->numverts, mesh->numtriangles);
- memcpy(varray_element, mesh->index, mesh->numtriangles * sizeof(int[3]));
+ R_Mesh_ResizeCheck(mesh->numverts);
memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
R_FillColors(varray_color, mesh->numverts, base, base, base, ent->alpha);
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);
+ R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
}
}
R_Mesh_State(&m);
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
- R_Mesh_ResizeCheck(mesh->numverts, mesh->numtriangles);
- memcpy(varray_element, mesh->index, mesh->numtriangles * sizeof(int[3]));
+ R_Mesh_ResizeCheck(mesh->numverts);
memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
RSurf_FoggedColors(varray_vertex, varray_color, 1, 1, 1, ent->alpha, mesh_colorscale, mesh->numverts, modelorg);
- R_Mesh_Draw(mesh->numverts, mesh->numtriangles);
+ R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
}
}
R_Mesh_State(&m);
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
- R_Mesh_ResizeCheck(mesh->numverts, mesh->numtriangles);
- memcpy(varray_element, mesh->index, mesh->numtriangles * sizeof(int[3]));
+ R_Mesh_ResizeCheck(mesh->numverts);
memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
RSurf_FoggedColors(varray_vertex, varray_color, 1, 1, 1, ent->alpha, mesh_colorscale, mesh->numverts, modelorg);
- R_Mesh_Draw(mesh->numverts, mesh->numtriangles);
+ R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
}
}
R_Mesh_State(&m);
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
- R_Mesh_ResizeCheck(mesh->numverts, mesh->numtriangles);
- memcpy(varray_element, mesh->index, mesh->numtriangles * sizeof(int[3]));
+ R_Mesh_ResizeCheck(mesh->numverts);
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);
+ R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
}
}
}
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
- R_Mesh_ResizeCheck(mesh->numverts, mesh->numtriangles);
- memcpy(varray_element, mesh->index, mesh->numtriangles * sizeof(int[3]));
+ R_Mesh_ResizeCheck(mesh->numverts);
memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
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);
+ R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
}
}
}
}
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
- R_Mesh_ResizeCheck(mesh->numverts, mesh->numtriangles);
- memcpy(varray_element, mesh->index, mesh->numtriangles * sizeof(int[3]));
+ R_Mesh_ResizeCheck(mesh->numverts);
memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
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);
+ R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
}
}
}
{
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
- R_Mesh_ResizeCheck(mesh->numverts, mesh->numtriangles);
- memcpy(varray_element, mesh->index, mesh->numtriangles * sizeof(int[3]));
+ R_Mesh_ResizeCheck(mesh->numverts);
memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
R_FillColors(varray_color, mesh->numverts, 1, 1, 1, 1);
- R_Mesh_Draw(mesh->numverts, mesh->numtriangles);
+ R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
}
}
}
}
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
- R_Mesh_ResizeCheck(mesh->numverts, mesh->numtriangles);
- memcpy(varray_element, mesh->index, mesh->numtriangles * sizeof(int[3]));
+ R_Mesh_ResizeCheck(mesh->numverts);
memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
memcpy(varray_texcoord[0], mesh->uv, mesh->numverts * sizeof(float[2]));
cl = (float) (1 << lightscalebit) * mesh_colorscale;
R_FillColors(varray_color, mesh->numverts, cl, cl, cl, 1);
- R_Mesh_Draw(mesh->numverts, mesh->numtriangles);
+ R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
}
}
}
{
if (RSurf_LightCheck(&ent->inversematrix, surf->dlightbits, mesh))
{
- R_Mesh_ResizeCheck(mesh->numverts, mesh->numtriangles);
- memcpy(varray_element, mesh->index, mesh->numtriangles * sizeof(int[3]));
+ R_Mesh_ResizeCheck(mesh->numverts);
memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
R_FillColors(varray_color, mesh->numverts, 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);
+ R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
}
}
}
{
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
- R_Mesh_ResizeCheck(mesh->numverts, mesh->numtriangles);
- memcpy(varray_element, mesh->index, mesh->numtriangles * sizeof(int[3]));
+ R_Mesh_ResizeCheck(mesh->numverts);
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);
+ R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
}
}
}
{
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
- R_Mesh_ResizeCheck(mesh->numverts, mesh->numtriangles);
- memcpy(varray_element, mesh->index, mesh->numtriangles * sizeof(int[3]));
+ R_Mesh_ResizeCheck(mesh->numverts);
memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
memcpy(varray_texcoord[0], mesh->ab, mesh->numverts * sizeof(float[2]));
R_FillColors(varray_color, mesh->numverts, 1, 1, 1, 1);
- R_Mesh_Draw(mesh->numverts, mesh->numtriangles);
+ R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
}
}
}
{
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
- R_Mesh_ResizeCheck(mesh->numverts, mesh->numtriangles);
- memcpy(varray_element, mesh->index, mesh->numtriangles * sizeof(int[3]));
+ R_Mesh_ResizeCheck(mesh->numverts);
memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
R_FillColors(varray_color, mesh->numverts, mesh_colorscale, mesh_colorscale, mesh_colorscale, 1);
- R_Mesh_Draw(mesh->numverts, mesh->numtriangles);
+ R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
}
}
}
//m.wantoverbright = false;
R_Mesh_Matrix(&ent->matrix);
R_Mesh_State(&m);
- R_Mesh_ResizeCheck(portal->numpoints, portal->numpoints - 2);
- for (i = 0;i < portal->numpoints - 2;i++)
- {
- varray_element[i * 3 + 0] = 0;
- varray_element[i * 3 + 1] = i + 1;
- varray_element[i * 3 + 2] = i + 2;
- }
+ R_Mesh_ResizeCheck(portal->numpoints);
i = portal - ent->model->portals;
R_FillColors(varray_color, portal->numpoints,
((i & 0x0007) >> 0) * (1.0f / 7.0f) * mesh_colorscale,
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);
+ R_Mesh_Draw(portal->numpoints, portal->numpoints - 2, polygonelements);
}
static void R_DrawPortals(entity_render_t *ent)
{
if (portal->here->pvsframe == r_pvsframecount || portal->past->pvsframe == r_pvsframecount)
{
- VectorClear(temp);
- for (i = 0;i < portal->numpoints;i++)
- VectorAdd(temp, portal->points[i].position, temp);
- f = ixtable[portal->numpoints];
- VectorScale(temp, f, temp);
- Matrix4x4_Transform(&ent->matrix, temp, center);
- R_MeshQueue_AddTransparent(center, R_DrawPortal_Callback, ent, portal - ent->model->portals);
+ if (portal->numpoints <= POLYGONELEMENTS_MAXPOINTS)
+ {
+ VectorClear(temp);
+ for (i = 0;i < portal->numpoints;i++)
+ VectorAdd(temp, portal->points[i].position, temp);
+ f = ixtable[portal->numpoints];
+ VectorScale(temp, f, temp);
+ Matrix4x4_Transform(&ent->matrix, temp, center);
+ R_MeshQueue_AddTransparent(center, R_DrawPortal_Callback, ent, portal - ent->model->portals);
+ }
}
}
}
R_Mesh_Matrix(&r_identitymatrix);
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_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);
+ R_Mesh_Draw(4, 2, polygonelements);
}
void R_DrawCrosshair(void)
numtriangles = EXPLOSIONTRIS;
numverts = EXPLOSIONVERTS;
- R_Mesh_ResizeCheck(numverts, numtriangles);
+ R_Mesh_ResizeCheck(numverts);
- memcpy(varray_element, explosiontris, numtriangles * sizeof(int[3]));
for (i = 0, v = varray_vertex;i < numverts;i++, v += 4)
{
v[0] = e->vert[i][0];
c[3] = 1;
}
}
- R_Mesh_Draw(numverts, numtriangles);
+ R_Mesh_Draw(numverts, numtriangles, explosiontris[0]);
}
void R_MoveExplosion(explosion_t *e)
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_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);
+ R_Mesh_Draw(4, 2, polygonelements);
}
}
}
}
}
-int skyboxindex[6] = {0, 1, 2, 0, 2, 3};
-
static void R_SkyBox(void)
{
rmeshstate_t m;
m.tex[0] = R_GetTexture(skyboxside[3]); // front
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;
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);
+ R_Mesh_Draw(4, 2, polygonelements);
m.tex[0] = R_GetTexture(skyboxside[1]); // back
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;
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);
+ R_Mesh_Draw(4, 2, polygonelements);
m.tex[0] = R_GetTexture(skyboxside[0]); // right
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;
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);
+ R_Mesh_Draw(4, 2, polygonelements);
m.tex[0] = R_GetTexture(skyboxside[2]); // left
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;
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);
+ R_Mesh_Draw(4, 2, polygonelements);
m.tex[0] = R_GetTexture(skyboxside[4]); // up
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;
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);
+ R_Mesh_Draw(4, 2, polygonelements);
m.tex[0] = R_GetTexture(skyboxside[5]); // down
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;
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);
+ R_Mesh_Draw(4, 2, polygonelements);
}
#define skygridx 32
numverts = skygridx1*skygridy1;
numtriangles = skygridx*skygridy*2;
- R_Mesh_ResizeCheck(numverts, numtriangles);
+ R_Mesh_ResizeCheck(numverts);
memset(&m, 0, sizeof(m));
m.blendfunc1 = GL_ONE;
m.tex[0] = R_GetTexture(solidskytexture);
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);
+ R_Mesh_Draw(numverts, numtriangles, skysphereindices);
m.blendfunc1 = GL_SRC_ALPHA;
m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
m.tex[0] = R_GetTexture(alphaskytexture);
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);
+ R_Mesh_Draw(numverts, numtriangles, skysphereindices);
}
void R_Sky(void)
m.tex[0] = texture;
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_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);
+ R_Mesh_Draw(4, 2, polygonelements);
}
void R_DrawSpriteModelCallback(const void *calldata1, int calldata2)