mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-10 07:12:07 +00:00
Prepare for reuse mpoly with mvtx_t/glvk_vtx_t
This commit is contained in:
parent
a567201160
commit
821490bbbd
8 changed files with 24 additions and 22 deletions
|
@ -154,7 +154,7 @@ LM_BuildPolygonFromSurface(model_t *currentmodel, msurface_t *fa)
|
|||
|
||||
/* draw texture */
|
||||
poly = Hunk_Alloc(sizeof(mpoly_t) +
|
||||
(lnumverts - 4) * VERTEXSIZE * sizeof(float));
|
||||
(lnumverts - 4) * sizeof(glvk_vtx_t));
|
||||
poly->next = fa->polys;
|
||||
poly->flags = fa->flags;
|
||||
fa->polys = poly;
|
||||
|
|
|
@ -306,8 +306,8 @@ calcTexinfoAndFacesSize(const byte *mod_base, const lump_t *fl, const lump_t *tl
|
|||
else
|
||||
{
|
||||
// LM_BuildPolygonFromSurface(out);
|
||||
// => poly = Hunk_Alloc(sizeof(mpoly_t) + (numverts - 4) * VERTEXSIZE * sizeof(float));
|
||||
int polySize = sizeof(mpoly_t) + (numverts - 4) * VERTEXSIZE * sizeof(float);
|
||||
// => poly = Hunk_Alloc(sizeof(mpoly_t) + (numverts - 4) * sizeof(glvk_vtx_t));
|
||||
int polySize = sizeof(mpoly_t) + (numverts - 4) * sizeof(glvk_vtx_t);
|
||||
polySize = (polySize + 31) & ~31;
|
||||
ret += polySize;
|
||||
}
|
||||
|
@ -382,8 +382,8 @@ calcTexinfoAndQFacesSize(const byte *mod_base, const lump_t *fl, const lump_t *t
|
|||
else
|
||||
{
|
||||
// LM_BuildPolygonFromSurface(out);
|
||||
// => poly = Hunk_Alloc(sizeof(mpoly_t) + (numverts - 4) * VERTEXSIZE * sizeof(float));
|
||||
int polySize = sizeof(mpoly_t) + (numverts - 4) * VERTEXSIZE * sizeof(float);
|
||||
// => poly = Hunk_Alloc(sizeof(mpoly_t) + (numverts - 4) * sizeof(glvk_vtx_t));
|
||||
int polySize = sizeof(mpoly_t) + (numverts - 4) * sizeof(glvk_vtx_t);
|
||||
polySize = (polySize + 31) & ~31;
|
||||
ret += polySize;
|
||||
}
|
||||
|
|
|
@ -52,8 +52,8 @@ R_DrawGLPoly(mpoly_t *p)
|
|||
glEnableClientState( GL_VERTEX_ARRAY );
|
||||
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
|
||||
|
||||
glVertexPointer( 3, GL_FLOAT, VERTEXSIZE*sizeof(GLfloat), v );
|
||||
glTexCoordPointer( 2, GL_FLOAT, VERTEXSIZE*sizeof(GLfloat), v+3 );
|
||||
glVertexPointer( 3, GL_FLOAT, sizeof(glvk_vtx_t), v );
|
||||
glTexCoordPointer( 2, GL_FLOAT, sizeof(glvk_vtx_t), v+3 );
|
||||
glDrawArrays( GL_TRIANGLE_FAN, 0, p->numverts );
|
||||
|
||||
glDisableClientState( GL_VERTEX_ARRAY );
|
||||
|
@ -92,7 +92,7 @@ R_DrawGLFlowingPoly(msurface_t *fa)
|
|||
glEnableClientState( GL_VERTEX_ARRAY );
|
||||
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
|
||||
|
||||
glVertexPointer( 3, GL_FLOAT, VERTEXSIZE*sizeof(GLfloat), v );
|
||||
glVertexPointer( 3, GL_FLOAT, sizeof(glvk_vtx_t), v );
|
||||
glTexCoordPointer( 2, GL_FLOAT, 0, tex );
|
||||
glDrawArrays( GL_TRIANGLE_FAN, 0, p->numverts );
|
||||
|
||||
|
@ -171,8 +171,8 @@ R_DrawGLPolyChain(mpoly_t *p, float soffset, float toffset)
|
|||
glEnableClientState( GL_VERTEX_ARRAY );
|
||||
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
|
||||
|
||||
glVertexPointer( 3, GL_FLOAT, VERTEXSIZE*sizeof(GLfloat), v );
|
||||
glTexCoordPointer( 2, GL_FLOAT, VERTEXSIZE*sizeof(GLfloat), v+5 );
|
||||
glVertexPointer( 3, GL_FLOAT, sizeof(glvk_vtx_t), v );
|
||||
glTexCoordPointer( 2, GL_FLOAT, sizeof(glvk_vtx_t), v+5 );
|
||||
glDrawArrays( GL_TRIANGLE_FAN, 0, p->numverts );
|
||||
|
||||
glDisableClientState( GL_VERTEX_ARRAY );
|
||||
|
@ -216,7 +216,7 @@ R_DrawGLPolyChain(mpoly_t *p, float soffset, float toffset)
|
|||
glEnableClientState( GL_VERTEX_ARRAY );
|
||||
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
|
||||
|
||||
glVertexPointer( 3, GL_FLOAT, VERTEXSIZE*sizeof(GLfloat), v );
|
||||
glVertexPointer( 3, GL_FLOAT, sizeof(glvk_vtx_t), v );
|
||||
glTexCoordPointer( 2, GL_FLOAT, 0, tex );
|
||||
glDrawArrays( GL_TRIANGLE_FAN, 0, p->numverts );
|
||||
|
||||
|
|
|
@ -178,7 +178,7 @@ R_SubdividePolygon(int numverts, float *verts, msurface_t *warpface)
|
|||
}
|
||||
|
||||
/* add a point in the center to help keep warp valid */
|
||||
poly = Hunk_Alloc(sizeof(mpoly_t) + ((numverts - 4) + 2) * VERTEXSIZE * sizeof(float));
|
||||
poly = Hunk_Alloc(sizeof(mpoly_t) + ((numverts - 4) + 2) * sizeof(glvk_vtx_t));
|
||||
poly->next = warpface->polys;
|
||||
warpface->polys = poly;
|
||||
poly->numverts = numverts + 2;
|
||||
|
@ -305,7 +305,7 @@ R_EmitWaterPolys(msurface_t *fa)
|
|||
glEnableClientState( GL_VERTEX_ARRAY );
|
||||
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
|
||||
|
||||
glVertexPointer( 3, GL_FLOAT, VERTEXSIZE*sizeof(GLfloat), v );
|
||||
glVertexPointer( 3, GL_FLOAT, sizeof(glvk_vtx_t), v );
|
||||
glTexCoordPointer( 2, GL_FLOAT, 0, tex );
|
||||
glDrawArrays( GL_TRIANGLE_FAN, 0, p->numverts );
|
||||
|
||||
|
|
|
@ -2,13 +2,15 @@
|
|||
|
||||
/* in memory representation */
|
||||
|
||||
typedef float glvk_vtx_t[VERTEXSIZE];
|
||||
|
||||
typedef struct mpoly_s
|
||||
{
|
||||
struct mpoly_s *next;
|
||||
struct mpoly_s *chain;
|
||||
int numverts;
|
||||
int flags; /* for SURF_UNDERWATER (not needed anymore?) */
|
||||
float verts[4][VERTEXSIZE]; /* variable sized (xyz s1t1 s2t2) */
|
||||
glvk_vtx_t verts[4]; /* variable sized (xyz s1t1 s2t2) */
|
||||
} mpoly_t;
|
||||
|
||||
typedef struct msurface_s
|
||||
|
|
|
@ -264,7 +264,7 @@ calcTexinfoAndFacesSize(const byte *mod_base, const lump_t *fl, const lump_t *tl
|
|||
|
||||
// Vk_SubdivideSurface(out, loadmodel); /* cut up polygon for warps */
|
||||
// for each (pot. recursive) call to R_SubdividePolygon():
|
||||
// sizeof(mpoly_t) + ((numverts - 4) + 2) * VERTEXSIZE*sizeof(float)
|
||||
// sizeof(mpoly_t) + ((numverts - 4) + 2) * sizeof(glvk_vtx_t)
|
||||
|
||||
// this is tricky, how much is allocated depends on the size of the surface
|
||||
// which we don't know (we'd need the vertices etc to know, but we can't load
|
||||
|
@ -276,8 +276,8 @@ calcTexinfoAndFacesSize(const byte *mod_base, const lump_t *fl, const lump_t *tl
|
|||
else
|
||||
{
|
||||
// Vk_BuildPolygonFromSurface(out);
|
||||
// => poly = Hunk_Alloc(sizeof(mpoly_t) + (numverts - 4) * VERTEXSIZE*sizeof(float));
|
||||
int polySize = sizeof(mpoly_t) + (numverts - 4) * VERTEXSIZE*sizeof(float);
|
||||
// => poly = Hunk_Alloc(sizeof(mpoly_t) + (numverts - 4) * sizeof(glvk_vtx_t));
|
||||
int polySize = sizeof(mpoly_t) + (numverts - 4) * sizeof(glvk_vtx_t);
|
||||
polySize = (polySize + 31) & ~31;
|
||||
ret += polySize;
|
||||
}
|
||||
|
@ -340,7 +340,7 @@ calcTexinfoAndQFacesSize(const byte *mod_base, const lump_t *fl, const lump_t *t
|
|||
|
||||
// Vk_SubdivideSurface(out, loadmodel); /* cut up polygon for warps */
|
||||
// for each (pot. recursive) call to R_SubdividePolygon():
|
||||
// sizeof(mpoly_t) + ((numverts - 4) + 2) * VERTEXSIZE*sizeof(float)
|
||||
// sizeof(mpoly_t) + ((numverts - 4) + 2) * sizeof(glvk_vtx_t)
|
||||
|
||||
// this is tricky, how much is allocated depends on the size of the surface
|
||||
// which we don't know (we'd need the vertices etc to know, but we can't load
|
||||
|
@ -352,8 +352,8 @@ calcTexinfoAndQFacesSize(const byte *mod_base, const lump_t *fl, const lump_t *t
|
|||
else
|
||||
{
|
||||
// Vk_BuildPolygonFromSurface(out);
|
||||
// => poly = Hunk_Alloc(sizeof(mpoly_t) + (numverts - 4) * VERTEXSIZE*sizeof(float));
|
||||
int polySize = sizeof(mpoly_t) + (numverts - 4) * VERTEXSIZE*sizeof(float);
|
||||
// => poly = Hunk_Alloc(sizeof(mpoly_t) + (numverts - 4) * sizeof(glvk_vtx_t));
|
||||
int polySize = sizeof(mpoly_t) + (numverts - 4) * sizeof(glvk_vtx_t);
|
||||
polySize = (polySize + 31) & ~31;
|
||||
ret += polySize;
|
||||
}
|
||||
|
|
|
@ -1143,7 +1143,7 @@ void Vk_BuildPolygonFromSurface(msurface_t *fa, model_t *currentmodel)
|
|||
//
|
||||
// draw texture
|
||||
//
|
||||
poly = Hunk_Alloc (sizeof(mpoly_t) + (lnumverts-4) * VERTEXSIZE * sizeof(float));
|
||||
poly = Hunk_Alloc (sizeof(mpoly_t) + (lnumverts-4) * sizeof(glvk_vtx_t));
|
||||
poly->next = fa->polys;
|
||||
fa->polys = poly;
|
||||
poly->numverts = lnumverts;
|
||||
|
|
|
@ -107,7 +107,7 @@ R_SubdividePolygon(int numverts, float *verts, msurface_t *warpface)
|
|||
}
|
||||
|
||||
// add a point in the center to help keep warp valid
|
||||
poly = Hunk_Alloc (sizeof(mpoly_t) + ((numverts-4)+2) * VERTEXSIZE*sizeof(float));
|
||||
poly = Hunk_Alloc (sizeof(mpoly_t) + ((numverts-4)+2) * sizeof(glvk_vtx_t));
|
||||
poly->next = warpface->polys;
|
||||
warpface->polys = poly;
|
||||
poly->numverts = numverts+2;
|
||||
|
|
Loading…
Reference in a new issue