From: havoc Date: Thu, 12 Sep 2002 16:07:13 +0000 (+0000) Subject: varray_element is gone, instead you pass your own element array to R_Mesh_Draw X-Git-Tag: RELEASE_0_2_0_RC1~239 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=59e91e85a8f84adf31e1c3e69b7089b77098b24e;p=xonotic%2Fdarkplaces.git varray_element is gone, instead you pass your own element array to R_Mesh_Draw this got a 3.5% speed gain in cavetest2bench also, R_Mesh_ResizeCheck now takes only a numverts parameter, since numtriangles was only used for the varray_element array git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2372 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/cl_particles.c b/cl_particles.c index 962f9cfa..11e0b4b4 100644 --- a/cl_particles.c +++ b/cl_particles.c @@ -1179,8 +1179,6 @@ void R_Particles_Init (void) 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; @@ -1205,12 +1203,6 @@ void R_DrawParticleCallback(const void *calldata1, int calldata2) 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); @@ -1285,7 +1277,7 @@ void R_DrawParticleCallback(const void *calldata1, int calldata2) 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) diff --git a/gl_backend.c b/gl_backend.c index 10acf3f0..3e569c2b 100644 --- a/gl_backend.c +++ b/gl_backend.c @@ -1,7 +1,7 @@ #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"}; @@ -9,10 +9,6 @@ cvar_t r_render = {0, "r_render", "1"}; 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; @@ -83,12 +79,10 @@ void SCR_ScreenShot_f (void); // 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; @@ -99,16 +93,22 @@ static int backendunits, backendactive; 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])); @@ -125,7 +125,6 @@ void GL_Backend_FreeArrays(int resizingbuffers) Mem_EmptyPool(gl_backend_mempool); else Mem_FreePool(&gl_backend_mempool); - varray_element = NULL; varray_vertex = NULL; varray_color = NULL; varray_bcolor = NULL; @@ -135,7 +134,7 @@ void GL_Backend_FreeArrays(int resizingbuffers) 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); @@ -178,17 +177,17 @@ void GL_Backend_CheckCvars(void) 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(); } @@ -206,7 +205,7 @@ void gl_backend_init(void) 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(); @@ -449,8 +448,8 @@ void R_Mesh_Start(float farclip) 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(); @@ -609,18 +608,18 @@ void GL_DrawRangeElements(int firstvert, int endvert, int indexcount, GLuint *in } // 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 @@ -635,7 +634,7 @@ void R_Mesh_Draw(int numverts, int numtriangles) //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 diff --git a/gl_backend.h b/gl_backend.h index 7190e0c2..a6981618 100644 --- a/gl_backend.h +++ b/gl_backend.h @@ -4,13 +4,16 @@ #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; @@ -23,12 +26,10 @@ 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); @@ -50,12 +51,12 @@ void R_Mesh_Matrix(const matrix4x4_t *matrix); // 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); diff --git a/gl_models.c b/gl_models.c index 38064f11..9d495ab3 100644 --- a/gl_models.c +++ b/gl_models.c @@ -271,7 +271,7 @@ void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2) } model = ent->model; - R_Mesh_ResizeCheck(model->numverts, model->numtris); + R_Mesh_ResizeCheck(model->numverts); skinframe = R_FetchSkinFrame(ent); @@ -302,7 +302,6 @@ void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2) 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; @@ -310,7 +309,7 @@ void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2) 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; } @@ -327,14 +326,13 @@ void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2) 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; } @@ -371,10 +369,9 @@ void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2) 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) @@ -397,10 +394,9 @@ void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2) 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) @@ -421,10 +417,9 @@ void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2) 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); } } } @@ -443,10 +438,9 @@ void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2) 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) @@ -460,10 +454,9 @@ void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2) 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); } } @@ -746,7 +739,7 @@ void R_DrawZymoticModelMeshCallback (const void *calldata1, int calldata2) { float fog; vec3_t diff; - int i, *renderlist; + int i, *renderlist, *elements; zymtype1header_t *m; rtexture_t *texture; rmeshstate_t mstate; @@ -764,8 +757,9 @@ void R_DrawZymoticModelMeshCallback (const void *calldata1, int calldata2) 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) @@ -811,11 +805,10 @@ void R_DrawZymoticModelMeshCallback (const void *calldata1, int calldata2) 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) { @@ -828,11 +821,10 @@ void R_DrawZymoticModelMeshCallback (const void *calldata1, int calldata2) 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); } } diff --git a/gl_rmain.c b/gl_rmain.c index 8948594a..024c1172 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -611,9 +611,6 @@ static void R_BlendView(void) 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]; @@ -629,7 +626,7 @@ static void R_BlendView(void) 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); } /* @@ -717,7 +714,6 @@ void R_DrawBBoxMesh(vec3_t mins, vec3_t maxs, float cr, float cg, float cb, floa 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]; @@ -750,7 +746,7 @@ void R_DrawBBoxMesh(vec3_t mins, vec3_t maxs, float cr, float cg, float cb, floa 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)); @@ -773,14 +769,14 @@ void R_DrawNoModelCallback(const void *calldata1, int calldata2) 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; @@ -814,7 +810,7 @@ void R_DrawNoModelCallback(const void *calldata1, int calldata2) c[2] *= mesh_colorscale; } } - R_Mesh_Draw(6, 8); + R_Mesh_Draw(6, 8, element); } void R_DrawNoModel(entity_render_t *ent) diff --git a/gl_rsurf.c b/gl_rsurf.c index ef815ae6..9cdd6cf6 100644 --- a/gl_rsurf.c +++ b/gl_rsurf.c @@ -821,14 +821,13 @@ static void RSurfShader_Sky(const entity_render_t *ent, const texture_t *texture { 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); } } } @@ -867,8 +866,7 @@ static void RSurfShader_Water_Callback(const void *calldata1, int calldata2) 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); @@ -881,7 +879,7 @@ static void RSurfShader_Water_Callback(const void *calldata1, int calldata2) 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) @@ -894,13 +892,12 @@ static void RSurfShader_Water_Callback(const void *calldata1, int calldata2) 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); } } } @@ -951,8 +948,7 @@ static void RSurfShader_Wall_Pass_BaseVertex(const entity_render_t *ent, const m 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); @@ -964,7 +960,7 @@ static void RSurfShader_Wall_Pass_BaseVertex(const entity_render_t *ent, const m 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); } } @@ -995,12 +991,11 @@ static void RSurfShader_Wall_Pass_BaseFullbright(const entity_render_t *ent, con 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); } } @@ -1018,12 +1013,11 @@ static void RSurfShader_Wall_Pass_Glow(const entity_render_t *ent, const msurfac 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); } } @@ -1041,13 +1035,12 @@ static void RSurfShader_Wall_Pass_Fog(const entity_render_t *ent, const msurface 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); } } @@ -1079,15 +1072,14 @@ static void RSurfShader_OpaqueWall_Pass_BaseTripleTexCombine(const entity_render } 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); } } } @@ -1116,14 +1108,13 @@ static void RSurfShader_OpaqueWall_Pass_BaseDoubleTex(const 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])); 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); } } } @@ -1143,12 +1134,11 @@ static void RSurfShader_OpaqueWall_Pass_BaseTexture(const 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])); 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); } } } @@ -1176,13 +1166,12 @@ static void RSurfShader_OpaqueWall_Pass_BaseLightmap(const 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])); 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); } } } @@ -1207,14 +1196,13 @@ static void RSurfShader_OpaqueWall_Pass_Light(const entity_render_t *ent, const { 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); } } } @@ -1238,13 +1226,12 @@ static void RSurfShader_OpaqueWall_Pass_Fog(const entity_render_t *ent, const te { 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); } } } @@ -1264,12 +1251,11 @@ static void RSurfShader_OpaqueWall_Pass_BaseDetail(const entity_render_t *ent, c { 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); } } } @@ -1289,12 +1275,11 @@ static void RSurfShader_OpaqueWall_Pass_Glow(const entity_render_t *ent, const t { 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); } } } @@ -1526,13 +1511,7 @@ static void R_DrawPortal_Callback(const void *calldata1, int calldata2) //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, @@ -1547,7 +1526,7 @@ static void R_DrawPortal_Callback(const void *calldata1, int calldata2) 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) @@ -1563,13 +1542,16 @@ 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); + } } } } diff --git a/r_crosshairs.c b/r_crosshairs.c index 6e141754..40ac2bc5 100644 --- a/r_crosshairs.c +++ b/r_crosshairs.c @@ -174,12 +174,6 @@ void R_DrawCrosshairSprite(rtexture_t *texture, vec3_t origin, vec_t scale, floa 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; @@ -204,7 +198,7 @@ void R_DrawCrosshairSprite(rtexture_t *texture, vec3_t origin, vec_t scale, floa 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) diff --git a/r_explosion.c b/r_explosion.c index 15212ccd..26eb2cda 100644 --- a/r_explosion.c +++ b/r_explosion.c @@ -191,9 +191,8 @@ void R_DrawExplosionCallback(const void *calldata1, int calldata2) 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]; @@ -243,7 +242,7 @@ void R_DrawExplosionCallback(const void *calldata1, int calldata2) c[3] = 1; } } - R_Mesh_Draw(numverts, numtriangles); + R_Mesh_Draw(numverts, numtriangles, explosiontris[0]); } void R_MoveExplosion(explosion_t *e) diff --git a/r_light.c b/r_light.c index 29e88876..56d040fc 100644 --- a/r_light.c +++ b/r_light.c @@ -168,12 +168,6 @@ void R_DrawCoronas(void) 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; @@ -201,7 +195,7 @@ void R_DrawCoronas(void) 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); } } } diff --git a/r_sky.c b/r_sky.c index 6ab1f25a..ca799a9d 100644 --- a/r_sky.c +++ b/r_sky.c @@ -114,8 +114,6 @@ void LoadSky_f (void) } } -int skyboxindex[6] = {0, 1, 2, 0, 2, 3}; - static void R_SkyBox(void) { rmeshstate_t m; @@ -135,7 +133,6 @@ static void R_SkyBox(void) 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; @@ -144,10 +141,9 @@ static void R_SkyBox(void) 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; @@ -156,10 +152,9 @@ static void R_SkyBox(void) 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; @@ -168,10 +163,9 @@ static void R_SkyBox(void) 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; @@ -180,10 +174,9 @@ static void R_SkyBox(void) 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; @@ -192,10 +185,9 @@ static void R_SkyBox(void) 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; @@ -204,7 +196,7 @@ static void R_SkyBox(void) 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 @@ -294,7 +286,7 @@ static void R_SkySphere(void) 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; @@ -304,18 +296,16 @@ static void R_SkySphere(void) 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) diff --git a/r_sprites.c b/r_sprites.c index 57710263..5408962c 100644 --- a/r_sprites.c +++ b/r_sprites.c @@ -90,12 +90,6 @@ static void R_DrawSpriteImage (int wantoverbright, int additive, mspriteframe_t 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; @@ -121,7 +115,7 @@ static void R_DrawSpriteImage (int wantoverbright, int additive, mspriteframe_t 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)