mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-12 11:10:39 +00:00
Polymer: store map data in a single buffer with a unified vertex type.
git-svn-id: https://svn.eduke32.com/eduke32@5294 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
868afddbc3
commit
8212aa11c6
2 changed files with 319 additions and 216 deletions
|
@ -201,11 +201,25 @@ typedef struct s_prrt {
|
||||||
} _prrt;
|
} _prrt;
|
||||||
|
|
||||||
// BUILD DATA
|
// BUILD DATA
|
||||||
|
|
||||||
|
typedef struct s_prvert {
|
||||||
|
GLfloat x;
|
||||||
|
GLfloat y;
|
||||||
|
GLfloat z;
|
||||||
|
GLfloat u;
|
||||||
|
GLfloat v;
|
||||||
|
GLubyte r;
|
||||||
|
GLubyte g;
|
||||||
|
GLubyte b;
|
||||||
|
GLubyte a;
|
||||||
|
} _prvert;
|
||||||
|
|
||||||
typedef struct s_prplane {
|
typedef struct s_prplane {
|
||||||
// geometry
|
// geometry
|
||||||
GLfloat* buffer;
|
_prvert* buffer;
|
||||||
int32_t vertcount;
|
int32_t vertcount;
|
||||||
GLuint vbo;
|
GLuint vbo;
|
||||||
|
int32_t mapvbo_vertoffset;
|
||||||
// attributes
|
// attributes
|
||||||
GLfloat tbn[3][3];
|
GLfloat tbn[3][3];
|
||||||
GLfloat plane[4];
|
GLfloat plane[4];
|
||||||
|
@ -258,7 +272,7 @@ typedef struct s_prwall {
|
||||||
|
|
||||||
// stuff
|
// stuff
|
||||||
GLfloat* bigportal;
|
GLfloat* bigportal;
|
||||||
GLfloat* cap;
|
//GLfloat* cap;
|
||||||
GLuint stuffvbo;
|
GLuint stuffvbo;
|
||||||
|
|
||||||
// build wall data
|
// build wall data
|
||||||
|
@ -360,7 +374,7 @@ static inline int32_t polymer_eligible_for_artmap(int32_t tilenum, const pthtyp
|
||||||
// CORE
|
// CORE
|
||||||
static void polymer_displayrooms(int16_t sectnum);
|
static void polymer_displayrooms(int16_t sectnum);
|
||||||
static void polymer_drawplane(_prplane* plane);
|
static void polymer_drawplane(_prplane* plane);
|
||||||
static inline void polymer_inb4mirror(GLfloat* buffer, GLfloat* plane);
|
static inline void polymer_inb4mirror(_prvert* buffer, GLfloat* plane);
|
||||||
static void polymer_animatesprites(void);
|
static void polymer_animatesprites(void);
|
||||||
static void polymer_freeboard(void);
|
static void polymer_freeboard(void);
|
||||||
// SECTORS
|
// SECTORS
|
||||||
|
@ -418,7 +432,7 @@ static void polymer_initrendertargets(int32_t count);
|
||||||
// DEBUG OUTPUT
|
// DEBUG OUTPUT
|
||||||
void PR_CALLBACK polymer_debugoutputcallback(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam);
|
void PR_CALLBACK polymer_debugoutputcallback(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam);
|
||||||
|
|
||||||
#define INDICE(n) ((p->indices) ? (p->indices[(i+n)%p->indicescount]*5) : (((i+n)%p->vertcount)*5))
|
#define INDICE(n) ((p->indices) ? (p->indices[(i+n)%p->indicescount]) : (((i+n)%p->vertcount)))
|
||||||
|
|
||||||
#define SWITCH_CULL_DIRECTION { culledface = (culledface == GL_FRONT) ? GL_BACK : GL_FRONT; bglCullFace(culledface); }
|
#define SWITCH_CULL_DIRECTION { culledface = (culledface == GL_FRONT) ? GL_BACK : GL_FRONT; bglCullFace(culledface); }
|
||||||
|
|
||||||
|
|
|
@ -68,28 +68,57 @@ GLuint prbasepalmaps[MAXBASEPALS];
|
||||||
// numshades full indirections (32*256) per lookup
|
// numshades full indirections (32*256) per lookup
|
||||||
GLuint prlookups[MAXPALOOKUPS];
|
GLuint prlookups[MAXPALOOKUPS];
|
||||||
|
|
||||||
static const GLfloat vertsprite[4 * 5] =
|
GLuint prmapvbo;
|
||||||
|
const GLsizeiptrARB proneplanesize = sizeof(_prvert) * 4;
|
||||||
|
const GLintptrARB prwalldatasize = sizeof(_prvert)* 4 * 3; // wall, over and mask planes for every wall
|
||||||
|
GLintptrARB prwalldataoffset;
|
||||||
|
|
||||||
|
static const _prvert vertsprite[4] =
|
||||||
|
{
|
||||||
{
|
{
|
||||||
-0.5f, 0.0f, 0.0f,
|
-0.5f, 0.0f, 0.0f,
|
||||||
0.0f, 1.0f,
|
0.0f, 1.0f,
|
||||||
|
0xff, 0xff, 0xff, 0xff,
|
||||||
|
},
|
||||||
|
{
|
||||||
0.5f, 0.0f, 0.0f,
|
0.5f, 0.0f, 0.0f,
|
||||||
1.0f, 1.0f,
|
1.0f, 1.0f,
|
||||||
|
0xff, 0xff, 0xff, 0xff,
|
||||||
|
},
|
||||||
|
{
|
||||||
0.5f, 1.0f, 0.0f,
|
0.5f, 1.0f, 0.0f,
|
||||||
1.0f, 0.0f,
|
1.0f, 0.0f,
|
||||||
|
0xff, 0xff, 0xff, 0xff,
|
||||||
|
},
|
||||||
|
{
|
||||||
-0.5f, 1.0f, 0.0f,
|
-0.5f, 1.0f, 0.0f,
|
||||||
0.0f, 0.0f,
|
0.0f, 0.0f,
|
||||||
|
0xff, 0xff, 0xff, 0xff,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const GLfloat horizsprite[4 * 5] =
|
static const _prvert horizsprite[4] =
|
||||||
|
{
|
||||||
{
|
{
|
||||||
-0.5f, 0.0f, 0.5f,
|
-0.5f, 0.0f, 0.5f,
|
||||||
0.0f, 0.0f,
|
0.0f, 0.0f,
|
||||||
|
0xff, 0xff, 0xff, 0xff,
|
||||||
|
},
|
||||||
|
{
|
||||||
0.5f, 0.0f, 0.5f,
|
0.5f, 0.0f, 0.5f,
|
||||||
1.0f, 0.0f,
|
1.0f, 0.0f,
|
||||||
|
0xff, 0xff, 0xff, 0xff,
|
||||||
|
},
|
||||||
|
{
|
||||||
0.5f, 0.0f, -0.5f,
|
0.5f, 0.0f, -0.5f,
|
||||||
1.0f, 1.0f,
|
1.0f, 1.0f,
|
||||||
|
0xff, 0xff, 0xff, 0xff,
|
||||||
|
},
|
||||||
|
{
|
||||||
-0.5f, 0.0f, -0.5f,
|
-0.5f, 0.0f, -0.5f,
|
||||||
0.0f, 1.0f,
|
0.0f, 1.0f,
|
||||||
|
0xff, 0xff, 0xff, 0xff,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const GLfloat skyboxdata[4 * 5 * 6] =
|
static const GLfloat skyboxdata[4 * 5 * 6] =
|
||||||
|
@ -814,6 +843,7 @@ int32_t polymer_init(void)
|
||||||
// Enable everything.
|
// Enable everything.
|
||||||
bglDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE);
|
bglDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE);
|
||||||
bglDebugMessageCallbackARB(polymer_debugoutputcallback, NULL);
|
bglDebugMessageCallbackARB(polymer_debugoutputcallback, NULL);
|
||||||
|
bglEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -981,6 +1011,14 @@ void polymer_loadboard(void)
|
||||||
|
|
||||||
polymer_freeboard();
|
polymer_freeboard();
|
||||||
|
|
||||||
|
// in the big map buffer, sectors have floor and ceiling vertices for each wall first, then walls
|
||||||
|
prwalldataoffset = numwalls * 2 * sizeof(_prvert);
|
||||||
|
|
||||||
|
bglGenBuffersARB(1, &prmapvbo);
|
||||||
|
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, prmapvbo);
|
||||||
|
bglBufferDataARB(GL_ARRAY_BUFFER_ARB, prwalldataoffset + numwalls * prwalldatasize, NULL, mapvbousage);
|
||||||
|
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while (i < numsectors)
|
while (i < numsectors)
|
||||||
{
|
{
|
||||||
|
@ -1787,8 +1825,8 @@ static void polymer_displayrooms(const int16_t dacursectnum)
|
||||||
|
|
||||||
w = prwalls[sec->wallptr + i];
|
w = prwalls[sec->wallptr + i];
|
||||||
|
|
||||||
if ((w->mask.buffer[(0 * 5) + 1] >= w->mask.buffer[(3 * 5) + 1]) &&
|
if ((w->mask.buffer[0].y >= w->mask.buffer[3].y) &&
|
||||||
(w->mask.buffer[(1 * 5) + 1] >= w->mask.buffer[(2 * 5) + 1]))
|
(w->mask.buffer[1].y >= w->mask.buffer[2].y))
|
||||||
{
|
{
|
||||||
i--;
|
i--;
|
||||||
continue;
|
continue;
|
||||||
|
@ -2112,16 +2150,30 @@ static void polymer_drawplane(_prplane* plane)
|
||||||
|
|
||||||
bglNormal3f((float)(plane->plane[0]), (float)(plane->plane[1]), (float)(plane->plane[2]));
|
bglNormal3f((float)(plane->plane[0]), (float)(plane->plane[1]), (float)(plane->plane[2]));
|
||||||
|
|
||||||
if (plane->vbo && (pr_vbos > 0))
|
GLuint planevbo;
|
||||||
|
GLintptrARB geomfbooffset;
|
||||||
|
|
||||||
|
if (plane->mapvbo_vertoffset != -1)
|
||||||
{
|
{
|
||||||
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, plane->vbo);
|
planevbo = prmapvbo;
|
||||||
bglVertexPointer(3, GL_FLOAT, 5 * sizeof(GLfloat), NULL);
|
geomfbooffset = plane->mapvbo_vertoffset;
|
||||||
bglTexCoordPointer(2, GL_FLOAT, 5 * sizeof(GLfloat), (GLfloat*)(3 * sizeof(GLfloat)));
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
planevbo = plane->vbo;
|
||||||
|
geomfbooffset = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (planevbo && (pr_vbos > 0))
|
||||||
|
{
|
||||||
|
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, planevbo);
|
||||||
|
bglVertexPointer(3, GL_FLOAT, sizeof(_prvert), (GLvoid *)(geomfbooffset));
|
||||||
|
bglTexCoordPointer(2, GL_FLOAT, sizeof(_prvert), (GLvoid *)(geomfbooffset + (3 * sizeof(GLfloat))));
|
||||||
if (plane->indices)
|
if (plane->indices)
|
||||||
bglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, plane->ivbo);
|
bglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, plane->ivbo);
|
||||||
} else {
|
} else {
|
||||||
bglVertexPointer(3, GL_FLOAT, 5 * sizeof(GLfloat), plane->buffer);
|
bglVertexPointer(3, GL_FLOAT, sizeof(_prvert), &plane->buffer->x);
|
||||||
bglTexCoordPointer(2, GL_FLOAT, 5 * sizeof(GLfloat), &plane->buffer[3]);
|
bglTexCoordPointer(2, GL_FLOAT, sizeof(_prvert), &plane->buffer->u);
|
||||||
}
|
}
|
||||||
|
|
||||||
curlight = 0;
|
curlight = 0;
|
||||||
|
@ -2137,7 +2189,7 @@ static void polymer_drawplane(_prplane* plane)
|
||||||
|
|
||||||
if (plane->indices)
|
if (plane->indices)
|
||||||
{
|
{
|
||||||
if (plane->vbo && (pr_vbos > 0))
|
if (planevbo && (pr_vbos > 0))
|
||||||
bglDrawElements(GL_TRIANGLES, plane->indicescount, GL_UNSIGNED_SHORT, NULL);
|
bglDrawElements(GL_TRIANGLES, plane->indicescount, GL_UNSIGNED_SHORT, NULL);
|
||||||
else
|
else
|
||||||
bglDrawElements(GL_TRIANGLES, plane->indicescount, GL_UNSIGNED_SHORT, plane->indices);
|
bglDrawElements(GL_TRIANGLES, plane->indicescount, GL_UNSIGNED_SHORT, plane->indices);
|
||||||
|
@ -2152,7 +2204,7 @@ static void polymer_drawplane(_prplane* plane)
|
||||||
curlight++;
|
curlight++;
|
||||||
} while ((curlight < plane->lightcount) && (curlight < pr_maxlightpasses) && (!depth || mirrors[depth-1].plane));
|
} while ((curlight < plane->lightcount) && (curlight < pr_maxlightpasses) && (!depth || mirrors[depth-1].plane));
|
||||||
|
|
||||||
if (plane->vbo && (pr_vbos > 0))
|
if (planevbo && (pr_vbos > 0))
|
||||||
{
|
{
|
||||||
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
|
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
|
||||||
if (plane->indices)
|
if (plane->indices)
|
||||||
|
@ -2160,14 +2212,14 @@ static void polymer_drawplane(_prplane* plane)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void polymer_inb4mirror(GLfloat* buffer, GLfloat* plane)
|
static inline void polymer_inb4mirror(_prvert* buffer, GLfloat* plane)
|
||||||
{
|
{
|
||||||
float pv;
|
float pv;
|
||||||
float reflectionmatrix[16];
|
float reflectionmatrix[16];
|
||||||
|
|
||||||
pv = buffer[0] * plane[0] +
|
pv = buffer->x * plane[0] +
|
||||||
buffer[1] * plane[1] +
|
buffer->y * plane[1] +
|
||||||
buffer[2] * plane[2];
|
buffer->z * plane[2];
|
||||||
|
|
||||||
reflectionmatrix[0] = 1 - (2 * plane[0] * plane[0]);
|
reflectionmatrix[0] = 1 - (2 * plane[0] * plane[0]);
|
||||||
reflectionmatrix[1] = -2 * plane[0] * plane[1];
|
reflectionmatrix[1] = -2 * plane[0] * plane[1];
|
||||||
|
@ -2238,7 +2290,7 @@ static void polymer_freeboard(void)
|
||||||
if (prwalls[i]->bigportal) Bfree(prwalls[i]->bigportal);
|
if (prwalls[i]->bigportal) Bfree(prwalls[i]->bigportal);
|
||||||
if (prwalls[i]->mask.buffer) Bfree(prwalls[i]->mask.buffer);
|
if (prwalls[i]->mask.buffer) Bfree(prwalls[i]->mask.buffer);
|
||||||
if (prwalls[i]->over.buffer) Bfree(prwalls[i]->over.buffer);
|
if (prwalls[i]->over.buffer) Bfree(prwalls[i]->over.buffer);
|
||||||
if (prwalls[i]->cap) Bfree(prwalls[i]->cap);
|
//if (prwalls[i]->cap) Bfree(prwalls[i]->cap);
|
||||||
if (prwalls[i]->wall.buffer) Bfree(prwalls[i]->wall.buffer);
|
if (prwalls[i]->wall.buffer) Bfree(prwalls[i]->wall.buffer);
|
||||||
if (prwalls[i]->wall.vbo) bglDeleteBuffersARB(1, &prwalls[i]->wall.vbo);
|
if (prwalls[i]->wall.vbo) bglDeleteBuffersARB(1, &prwalls[i]->wall.vbo);
|
||||||
if (prwalls[i]->over.vbo) bglDeleteBuffersARB(1, &prwalls[i]->over.vbo);
|
if (prwalls[i]->over.vbo) bglDeleteBuffersARB(1, &prwalls[i]->over.vbo);
|
||||||
|
@ -2310,9 +2362,9 @@ static int32_t polymer_initsector(int16_t sectnum)
|
||||||
s = (_prsector *)Xcalloc(1, sizeof(_prsector));
|
s = (_prsector *)Xcalloc(1, sizeof(_prsector));
|
||||||
|
|
||||||
s->verts = (GLdouble *)Xcalloc(sec->wallnum, sizeof(GLdouble) * 3);
|
s->verts = (GLdouble *)Xcalloc(sec->wallnum, sizeof(GLdouble) * 3);
|
||||||
s->floor.buffer = (GLfloat *)Xcalloc(sec->wallnum, sizeof(GLfloat) * 5);
|
s->floor.buffer = (_prvert *)Xcalloc(sec->wallnum, sizeof(_prvert));
|
||||||
s->floor.vertcount = sec->wallnum;
|
s->floor.vertcount = sec->wallnum;
|
||||||
s->ceil.buffer = (GLfloat *)Xcalloc(sec->wallnum, sizeof(GLfloat) * 5);
|
s->ceil.buffer = (_prvert *)Xcalloc(sec->wallnum, sizeof(_prvert));
|
||||||
s->ceil.vertcount = sec->wallnum;
|
s->ceil.vertcount = sec->wallnum;
|
||||||
|
|
||||||
bglGenBuffersARB(1, &s->floor.vbo);
|
bglGenBuffersARB(1, &s->floor.vbo);
|
||||||
|
@ -2349,7 +2401,7 @@ static int32_t polymer_updatesector(int16_t sectnum)
|
||||||
int32_t ang, needfloor, wallinvalidate;
|
int32_t ang, needfloor, wallinvalidate;
|
||||||
int16_t curstat, curpicnum, floorpicnum, ceilingpicnum;
|
int16_t curstat, curpicnum, floorpicnum, ceilingpicnum;
|
||||||
char curxpanning, curypanning;
|
char curxpanning, curypanning;
|
||||||
GLfloat* curbuffer;
|
_prvert* curbuffer;
|
||||||
|
|
||||||
if (pr_nullrender >= 3) return 0;
|
if (pr_nullrender >= 3) return 0;
|
||||||
|
|
||||||
|
@ -2373,12 +2425,12 @@ static int32_t polymer_updatesector(int16_t sectnum)
|
||||||
{
|
{
|
||||||
if ((-wal->x != s->verts[(i*3)+2]))
|
if ((-wal->x != s->verts[(i*3)+2]))
|
||||||
{
|
{
|
||||||
s->verts[(i*3)+2] = s->floor.buffer[(i*5)+2] = s->ceil.buffer[(i*5)+2] = -(float)wal->x;
|
s->verts[(i*3)+2] = s->floor.buffer[i].z = s->ceil.buffer[i].z = -(float)wal->x;
|
||||||
needfloor = wallinvalidate = 1;
|
needfloor = wallinvalidate = 1;
|
||||||
}
|
}
|
||||||
if ((wal->y != s->verts[i*3]))
|
if ((wal->y != s->verts[i*3]))
|
||||||
{
|
{
|
||||||
s->verts[i*3] = s->floor.buffer[i*5] = s->ceil.buffer[i*5] = (float)wal->y;
|
s->verts[i*3] = s->floor.buffer[i].x = s->ceil.buffer[i].x = (float)wal->y;
|
||||||
needfloor = wallinvalidate = 1;
|
needfloor = wallinvalidate = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2400,8 +2452,8 @@ static int32_t polymer_updatesector(int16_t sectnum)
|
||||||
while (i < sec->wallnum)
|
while (i < sec->wallnum)
|
||||||
{
|
{
|
||||||
getzsofslope(sectnum, wal->x, wal->y, &ceilz, &florz);
|
getzsofslope(sectnum, wal->x, wal->y, &ceilz, &florz);
|
||||||
s->floor.buffer[(i*5)+1] = -(float)(florz) / 16.0f;
|
s->floor.buffer[i].y = -(float)(florz) / 16.0f;
|
||||||
s->ceil.buffer[(i*5)+1] = -(float)(ceilz) / 16.0f;
|
s->ceil.buffer[i].y = -(float)(ceilz) / 16.0f;
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
wal = &wall[sec->wallptr + i];
|
wal = &wall[sec->wallptr + i];
|
||||||
|
@ -2474,7 +2526,7 @@ static int32_t polymer_updatesector(int16_t sectnum)
|
||||||
|
|
||||||
if ((curstat & (2+64)) == (2+64))
|
if ((curstat & (2+64)) == (2+64))
|
||||||
{
|
{
|
||||||
heidiff = (int32_t)(curbuffer[(i*5)+1] - curbuffer[1]);
|
heidiff = (int32_t)(curbuffer[i].y - curbuffer[0].y);
|
||||||
// don't forget the sign, tey could be negative with concave sectors
|
// don't forget the sign, tey could be negative with concave sectors
|
||||||
if (tey >= 0)
|
if (tey >= 0)
|
||||||
tey = (int32_t)sqrt((double)((tey * tey) + (heidiff * heidiff)));
|
tey = (int32_t)sqrt((double)((tey * tey) + (heidiff * heidiff)));
|
||||||
|
@ -2506,8 +2558,8 @@ static int32_t polymer_updatesector(int16_t sectnum)
|
||||||
else
|
else
|
||||||
ypancoef = 0;
|
ypancoef = 0;
|
||||||
|
|
||||||
curbuffer[(i*5)+3] = ((float)(tex) / (scalecoef * tilesiz[curpicnum].x)) + xpancoef;
|
curbuffer[i].u = ((float)(tex) / (scalecoef * tilesiz[curpicnum].x)) + xpancoef;
|
||||||
curbuffer[(i*5)+4] = ((float)(tey) / (scalecoef * tilesiz[curpicnum].y)) + ypancoef;
|
curbuffer[i].v = ((float)(tey) / (scalecoef * tilesiz[curpicnum].y)) + ypancoef;
|
||||||
|
|
||||||
j--;
|
j--;
|
||||||
}
|
}
|
||||||
|
@ -2524,14 +2576,34 @@ static int32_t polymer_updatesector(int16_t sectnum)
|
||||||
|
|
||||||
attributes:
|
attributes:
|
||||||
if ((pr_vbos > 0) && ((i == -1) || (wallinvalidate)))
|
if ((pr_vbos > 0) && ((i == -1) || (wallinvalidate)))
|
||||||
|
{
|
||||||
|
if (pr_vbos > 0)
|
||||||
{
|
{
|
||||||
if (pr_nullrender < 2)
|
if (pr_nullrender < 2)
|
||||||
{
|
{
|
||||||
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, s->floor.vbo);
|
/*bglBindBufferARB(GL_ARRAY_BUFFER_ARB, s->floor.vbo);
|
||||||
bglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, sec->wallnum * sizeof(GLfloat)* 5, s->floor.buffer);
|
bglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, sec->wallnum * sizeof(GLfloat)* 5, s->floor.buffer);
|
||||||
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, s->ceil.vbo);
|
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, s->ceil.vbo);
|
||||||
bglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, sec->wallnum * sizeof(GLfloat)* 5, s->ceil.buffer);
|
bglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, sec->wallnum * sizeof(GLfloat)* 5, s->ceil.buffer);
|
||||||
|
*/
|
||||||
|
|
||||||
|
GLintptrARB sector_offset = sec->wallptr * 2 * sizeof(_prvert);
|
||||||
|
GLsizeiptrARB cur_sector_size = sec->wallnum * sizeof(_prvert);
|
||||||
|
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, prmapvbo);
|
||||||
|
// floor
|
||||||
|
bglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, sector_offset, cur_sector_size, s->floor.buffer);
|
||||||
|
// ceiling
|
||||||
|
bglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, sector_offset + cur_sector_size, cur_sector_size, s->ceil.buffer);
|
||||||
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
|
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
|
||||||
|
|
||||||
|
s->floor.mapvbo_vertoffset = sector_offset;
|
||||||
|
s->ceil.mapvbo_vertoffset = sector_offset + cur_sector_size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
s->floor.mapvbo_vertoffset = -1;
|
||||||
|
s->ceil.mapvbo_vertoffset = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2790,13 +2862,13 @@ static int32_t polymer_initwall(int16_t wallnum)
|
||||||
w = (_prwall *)Xcalloc(1, sizeof(_prwall));
|
w = (_prwall *)Xcalloc(1, sizeof(_prwall));
|
||||||
|
|
||||||
if (w->mask.buffer == NULL) {
|
if (w->mask.buffer == NULL) {
|
||||||
w->mask.buffer = (GLfloat *)Xmalloc(4 * sizeof(GLfloat) * 5);
|
w->mask.buffer = (_prvert *)Xmalloc(4 * sizeof(_prvert));
|
||||||
w->mask.vertcount = 4;
|
w->mask.vertcount = 4;
|
||||||
}
|
}
|
||||||
if (w->bigportal == NULL)
|
if (w->bigportal == NULL)
|
||||||
w->bigportal = (GLfloat *)Xmalloc(4 * sizeof(GLfloat) * 5);
|
w->bigportal = (GLfloat *)Xmalloc(4 * sizeof(GLfloat) * 5);
|
||||||
if (w->cap == NULL)
|
//if (w->cap == NULL)
|
||||||
w->cap = (GLfloat *)Xmalloc(4 * sizeof(GLfloat) * 3);
|
// w->cap = (GLfloat *)Xmalloc(4 * sizeof(GLfloat) * 3);
|
||||||
|
|
||||||
bglGenBuffersARB(1, &w->wall.vbo);
|
bglGenBuffersARB(1, &w->wall.vbo);
|
||||||
bglGenBuffersARB(1, &w->over.vbo);
|
bglGenBuffersARB(1, &w->over.vbo);
|
||||||
|
@ -2902,7 +2974,7 @@ static void polymer_updatewall(int16_t wallnum)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (w->wall.buffer == NULL) {
|
if (w->wall.buffer == NULL) {
|
||||||
w->wall.buffer = (GLfloat *)Xcalloc(4, sizeof(GLfloat) * 5); // XXX
|
w->wall.buffer = (_prvert *)Xcalloc(4, sizeof(_prvert)); // XXX
|
||||||
w->wall.vertcount = 4;
|
w->wall.vertcount = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2964,10 +3036,10 @@ static void polymer_updatewall(int16_t wallnum)
|
||||||
|
|
||||||
if ((unsigned)wal->nextsector >= (unsigned)numsectors || !ns)
|
if ((unsigned)wal->nextsector >= (unsigned)numsectors || !ns)
|
||||||
{
|
{
|
||||||
Bmemcpy(w->wall.buffer, &s->floor.buffer[(wallnum - sec->wallptr) * 5], sizeof(GLfloat) * 3);
|
Bmemcpy(w->wall.buffer, &s->floor.buffer[wallnum - sec->wallptr], sizeof(GLfloat) * 3);
|
||||||
Bmemcpy(&w->wall.buffer[5], &s->floor.buffer[(wal->point2 - sec->wallptr) * 5], sizeof(GLfloat) * 3);
|
Bmemcpy(&w->wall.buffer[1], &s->floor.buffer[wal->point2 - sec->wallptr], sizeof(GLfloat) * 3);
|
||||||
Bmemcpy(&w->wall.buffer[10], &s->ceil.buffer[(wal->point2 - sec->wallptr) * 5], sizeof(GLfloat) * 3);
|
Bmemcpy(&w->wall.buffer[2], &s->ceil.buffer[wal->point2 - sec->wallptr], sizeof(GLfloat) * 3);
|
||||||
Bmemcpy(&w->wall.buffer[15], &s->ceil.buffer[(wallnum - sec->wallptr) * 5], sizeof(GLfloat) * 3);
|
Bmemcpy(&w->wall.buffer[3], &s->ceil.buffer[wallnum - sec->wallptr], sizeof(GLfloat) * 3);
|
||||||
|
|
||||||
if (wal->nextsector < 0)
|
if (wal->nextsector < 0)
|
||||||
curpicnum = wallpicnum;
|
curpicnum = wallpicnum;
|
||||||
|
@ -3003,10 +3075,10 @@ static void polymer_updatewall(int16_t wallnum)
|
||||||
else
|
else
|
||||||
dist = (float)(xref == 0);
|
dist = (float)(xref == 0);
|
||||||
|
|
||||||
w->wall.buffer[(i * 5) + 3] = ((dist * 8.0f * wal->xrepeat) + wal->xpanning) / (float)(tilesiz[curpicnum].x);
|
w->wall.buffer[i].u = ((dist * 8.0f * wal->xrepeat) + wal->xpanning) / (float)(tilesiz[curpicnum].x);
|
||||||
w->wall.buffer[(i * 5) + 4] = (-(float)(yref + (w->wall.buffer[(i * 5) + 1] * 16)) / ((tilesiz[curpicnum].y * 2048.0f) / (float)(wal->yrepeat))) + ypancoef;
|
w->wall.buffer[i].v = (-(float)(yref + (w->wall.buffer[i].y * 16)) / ((tilesiz[curpicnum].y * 2048.0f) / (float)(wal->yrepeat))) + ypancoef;
|
||||||
|
|
||||||
if (wal->cstat & 256) w->wall.buffer[(i * 5) + 4] = -w->wall.buffer[(i * 5) + 4];
|
if (wal->cstat & 256) w->wall.buffer[i].u = -w->wall.buffer[i].v;
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
@ -3017,21 +3089,21 @@ static void polymer_updatewall(int16_t wallnum)
|
||||||
{
|
{
|
||||||
nnwallnum = wall[nwallnum].point2;
|
nnwallnum = wall[nwallnum].point2;
|
||||||
|
|
||||||
if ((s->floor.buffer[((wallnum - sec->wallptr) * 5) + 1] < ns->floor.buffer[((nnwallnum - nsec->wallptr) * 5) + 1]) ||
|
if ((s->floor.buffer[wallnum - sec->wallptr].y < ns->floor.buffer[nnwallnum - nsec->wallptr].y) ||
|
||||||
(s->floor.buffer[((wal->point2 - sec->wallptr) * 5) + 1] < ns->floor.buffer[((nwallnum - nsec->wallptr) * 5) + 1]))
|
(s->floor.buffer[wal->point2 - sec->wallptr].y < ns->floor.buffer[nwallnum - nsec->wallptr].y))
|
||||||
underwall = 1;
|
underwall = 1;
|
||||||
|
|
||||||
if ((underwall) || (wal->cstat & 16) || (wal->cstat & 32))
|
if ((underwall) || (wal->cstat & 16) || (wal->cstat & 32))
|
||||||
{
|
{
|
||||||
int32_t refwall;
|
int32_t refwall;
|
||||||
|
|
||||||
if (s->floor.buffer[((wallnum - sec->wallptr) * 5) + 1] < ns->floor.buffer[((nnwallnum - nsec->wallptr) * 5) + 1])
|
if (s->floor.buffer[wallnum - sec->wallptr].y < ns->floor.buffer[nnwallnum - nsec->wallptr].y)
|
||||||
Bmemcpy(w->wall.buffer, &s->floor.buffer[(wallnum - sec->wallptr) * 5], sizeof(GLfloat) * 3);
|
Bmemcpy(w->wall.buffer, &s->floor.buffer[wallnum - sec->wallptr], sizeof(GLfloat) * 3);
|
||||||
else
|
else
|
||||||
Bmemcpy(w->wall.buffer, &ns->floor.buffer[(nnwallnum - nsec->wallptr) * 5], sizeof(GLfloat) * 3);
|
Bmemcpy(w->wall.buffer, &ns->floor.buffer[nnwallnum - nsec->wallptr], sizeof(GLfloat) * 3);
|
||||||
Bmemcpy(&w->wall.buffer[5], &s->floor.buffer[(wal->point2 - sec->wallptr) * 5], sizeof(GLfloat) * 3);
|
Bmemcpy(&w->wall.buffer[1], &s->floor.buffer[wal->point2 - sec->wallptr], sizeof(GLfloat) * 3);
|
||||||
Bmemcpy(&w->wall.buffer[10], &ns->floor.buffer[(nwallnum - nsec->wallptr) * 5], sizeof(GLfloat) * 3);
|
Bmemcpy(&w->wall.buffer[2], &ns->floor.buffer[nwallnum - nsec->wallptr], sizeof(GLfloat) * 3);
|
||||||
Bmemcpy(&w->wall.buffer[15], &ns->floor.buffer[(nnwallnum - nsec->wallptr) * 5], sizeof(GLfloat) * 3);
|
Bmemcpy(&w->wall.buffer[3], &ns->floor.buffer[nnwallnum - nsec->wallptr], sizeof(GLfloat) * 3);
|
||||||
|
|
||||||
if (wal->cstat & 2)
|
if (wal->cstat & 2)
|
||||||
refwall = nwallnum;
|
refwall = nwallnum;
|
||||||
|
@ -3065,12 +3137,12 @@ static void polymer_updatewall(int16_t wallnum)
|
||||||
else
|
else
|
||||||
dist = (float)(xref == 0);
|
dist = (float)(xref == 0);
|
||||||
|
|
||||||
w->wall.buffer[(i * 5) + 3] = ((dist * 8.0f * wal->xrepeat) + curxpanning) / (float)(tilesiz[curpicnum].x);
|
w->wall.buffer[i].u = ((dist * 8.0f * wal->xrepeat) + curxpanning) / (float)(tilesiz[curpicnum].x);
|
||||||
w->wall.buffer[(i * 5) + 4] = (-(float)(yref + (w->wall.buffer[(i * 5) + 1] * 16)) / ((tilesiz[curpicnum].y * 2048.0f) / (float)(wal->yrepeat))) + ypancoef;
|
w->wall.buffer[i].v = (-(float)(yref + (w->wall.buffer[i].y * 16)) / ((tilesiz[curpicnum].y * 2048.0f) / (float)(wal->yrepeat))) + ypancoef;
|
||||||
|
|
||||||
if ((!(wal->cstat & 2) && (wal->cstat & 256)) ||
|
if ((!(wal->cstat & 2) && (wal->cstat & 256)) ||
|
||||||
((wal->cstat & 2) && (wall[nwallnum].cstat & 256)))
|
((wal->cstat & 2) && (wall[nwallnum].cstat & 256)))
|
||||||
w->wall.buffer[(i * 5) + 4] = -w->wall.buffer[(i * 5) + 4];
|
w->wall.buffer[i].v = -w->wall.buffer[i].v;
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
@ -3078,33 +3150,33 @@ static void polymer_updatewall(int16_t wallnum)
|
||||||
if (underwall)
|
if (underwall)
|
||||||
w->underover |= 1;
|
w->underover |= 1;
|
||||||
|
|
||||||
Bmemcpy(w->mask.buffer, &w->wall.buffer[15], sizeof(GLfloat) * 5);
|
Bmemcpy(w->mask.buffer, &w->wall.buffer[3], sizeof(GLfloat) * 5);
|
||||||
Bmemcpy(&w->mask.buffer[5], &w->wall.buffer[10], sizeof(GLfloat) * 5);
|
Bmemcpy(&w->mask.buffer[1], &w->wall.buffer[2], sizeof(GLfloat) * 5);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Bmemcpy(w->mask.buffer, &s->floor.buffer[(wallnum - sec->wallptr) * 5], sizeof(GLfloat) * 5);
|
Bmemcpy(w->mask.buffer, &s->floor.buffer[wallnum - sec->wallptr], sizeof(GLfloat) * 5);
|
||||||
Bmemcpy(&w->mask.buffer[5], &s->floor.buffer[(wal->point2 - sec->wallptr) * 5], sizeof(GLfloat) * 5);
|
Bmemcpy(&w->mask.buffer[1], &s->floor.buffer[wal->point2 - sec->wallptr], sizeof(GLfloat) * 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((s->ceil.buffer[((wallnum - sec->wallptr) * 5) + 1] > ns->ceil.buffer[((nnwallnum - nsec->wallptr) * 5) + 1]) ||
|
if ((s->ceil.buffer[wallnum - sec->wallptr].y > ns->ceil.buffer[nnwallnum - nsec->wallptr].y) ||
|
||||||
(s->ceil.buffer[((wal->point2 - sec->wallptr) * 5) + 1] > ns->ceil.buffer[((nwallnum - nsec->wallptr) * 5) + 1]))
|
(s->ceil.buffer[wal->point2 - sec->wallptr].y > ns->ceil.buffer[nwallnum - nsec->wallptr].y))
|
||||||
overwall = 1;
|
overwall = 1;
|
||||||
|
|
||||||
if ((overwall) || (wal->cstat & 16) || (wal->cstat & 32))
|
if ((overwall) || (wal->cstat & 16) || (wal->cstat & 32))
|
||||||
{
|
{
|
||||||
if (w->over.buffer == NULL) {
|
if (w->over.buffer == NULL) {
|
||||||
w->over.buffer = (GLfloat *)Xmalloc(4 * sizeof(GLfloat) * 5);
|
w->over.buffer = (_prvert *)Xmalloc(4 * sizeof(_prvert));
|
||||||
w->over.vertcount = 4;
|
w->over.vertcount = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bmemcpy(w->over.buffer, &ns->ceil.buffer[(nnwallnum - nsec->wallptr) * 5], sizeof(GLfloat) * 3);
|
Bmemcpy(w->over.buffer, &ns->ceil.buffer[nnwallnum - nsec->wallptr], sizeof(GLfloat) * 3);
|
||||||
Bmemcpy(&w->over.buffer[5], &ns->ceil.buffer[(nwallnum - nsec->wallptr) * 5], sizeof(GLfloat) * 3);
|
Bmemcpy(&w->over.buffer[1], &ns->ceil.buffer[nwallnum - nsec->wallptr], sizeof(GLfloat) * 3);
|
||||||
if (s->ceil.buffer[((wal->point2 - sec->wallptr) * 5) + 1] > ns->ceil.buffer[((nwallnum - nsec->wallptr) * 5) + 1])
|
if (s->ceil.buffer[wal->point2 - sec->wallptr].y > ns->ceil.buffer[nwallnum - nsec->wallptr].y)
|
||||||
Bmemcpy(&w->over.buffer[10], &s->ceil.buffer[(wal->point2 - sec->wallptr) * 5], sizeof(GLfloat) * 3);
|
Bmemcpy(&w->over.buffer[2], &s->ceil.buffer[wal->point2 - sec->wallptr], sizeof(GLfloat) * 3);
|
||||||
else
|
else
|
||||||
Bmemcpy(&w->over.buffer[10], &ns->ceil.buffer[(nwallnum - nsec->wallptr) * 5], sizeof(GLfloat) * 3);
|
Bmemcpy(&w->over.buffer[2], &ns->ceil.buffer[nwallnum - nsec->wallptr], sizeof(GLfloat) * 3);
|
||||||
Bmemcpy(&w->over.buffer[15], &s->ceil.buffer[(wallnum - sec->wallptr) * 5], sizeof(GLfloat) * 3);
|
Bmemcpy(&w->over.buffer[3], &s->ceil.buffer[wallnum - sec->wallptr], sizeof(GLfloat) * 3);
|
||||||
|
|
||||||
if ((wal->cstat & 16) || (wal->overpicnum == 0))
|
if ((wal->cstat & 16) || (wal->overpicnum == 0))
|
||||||
curpicnum = wallpicnum;
|
curpicnum = wallpicnum;
|
||||||
|
@ -3146,10 +3218,10 @@ static void polymer_updatewall(int16_t wallnum)
|
||||||
else
|
else
|
||||||
dist = (float)(xref == 0);
|
dist = (float)(xref == 0);
|
||||||
|
|
||||||
w->over.buffer[(i * 5) + 3] = ((dist * 8.0f * wal->xrepeat) + wal->xpanning) / (float)(tilesiz[curpicnum].x);
|
w->over.buffer[i].u = ((dist * 8.0f * wal->xrepeat) + wal->xpanning) / (float)(tilesiz[curpicnum].x);
|
||||||
w->over.buffer[(i * 5) + 4] = (-(float)(yref + (w->over.buffer[(i * 5) + 1] * 16)) / ((tilesiz[curpicnum].y * 2048.0f) / (float)(wal->yrepeat))) + ypancoef;
|
w->over.buffer[i].v = (-(float)(yref + (w->over.buffer[i].y * 16)) / ((tilesiz[curpicnum].y * 2048.0f) / (float)(wal->yrepeat))) + ypancoef;
|
||||||
|
|
||||||
if (wal->cstat & 256) w->over.buffer[(i * 5) + 4] = -w->over.buffer[(i * 5) + 4];
|
if (wal->cstat & 256) w->over.buffer[i].v = -w->over.buffer[i].v;
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
@ -3157,8 +3229,8 @@ static void polymer_updatewall(int16_t wallnum)
|
||||||
if (overwall)
|
if (overwall)
|
||||||
w->underover |= 2;
|
w->underover |= 2;
|
||||||
|
|
||||||
Bmemcpy(&w->mask.buffer[10], &w->over.buffer[5], sizeof(GLfloat) * 5);
|
Bmemcpy(&w->mask.buffer[2], &w->over.buffer[1], sizeof(GLfloat) * 5);
|
||||||
Bmemcpy(&w->mask.buffer[15], &w->over.buffer[0], sizeof(GLfloat) * 5);
|
Bmemcpy(&w->mask.buffer[3], &w->over.buffer[0], sizeof(GLfloat) * 5);
|
||||||
|
|
||||||
if ((wal->cstat & 16) || (wal->cstat & 32))
|
if ((wal->cstat & 16) || (wal->cstat & 32))
|
||||||
{
|
{
|
||||||
|
@ -3197,10 +3269,10 @@ static void polymer_updatewall(int16_t wallnum)
|
||||||
else
|
else
|
||||||
dist = (float)(xref == 0);
|
dist = (float)(xref == 0);
|
||||||
|
|
||||||
w->mask.buffer[(i * 5) + 3] = ((dist * 8.0f * wal->xrepeat) + wal->xpanning) / (float)(tilesiz[curpicnum].x);
|
w->mask.buffer[i].u = ((dist * 8.0f * wal->xrepeat) + wal->xpanning) / (float)(tilesiz[curpicnum].x);
|
||||||
w->mask.buffer[(i * 5) + 4] = (-(float)(yref + (w->mask.buffer[(i * 5) + 1] * 16)) / ((tilesiz[curpicnum].y * 2048.0f) / (float)(wal->yrepeat))) + ypancoef;
|
w->mask.buffer[i].v = (-(float)(yref + (w->mask.buffer[i].y * 16)) / ((tilesiz[curpicnum].y * 2048.0f) / (float)(wal->yrepeat))) + ypancoef;
|
||||||
|
|
||||||
if (wal->cstat & 256) w->mask.buffer[(i * 5) + 4] = -w->mask.buffer[(i * 5) + 4];
|
if (wal->cstat & 256) w->mask.buffer[i].v = -w->mask.buffer[i].v;
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
@ -3208,25 +3280,26 @@ static void polymer_updatewall(int16_t wallnum)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Bmemcpy(&w->mask.buffer[10], &s->ceil.buffer[(wal->point2 - sec->wallptr) * 5], sizeof(GLfloat) * 5);
|
Bmemcpy(&w->mask.buffer[2], &s->ceil.buffer[wal->point2 - sec->wallptr], sizeof(GLfloat) * 5);
|
||||||
Bmemcpy(&w->mask.buffer[15], &s->ceil.buffer[(wallnum - sec->wallptr) * 5], sizeof(GLfloat) * 5);
|
Bmemcpy(&w->mask.buffer[3], &s->ceil.buffer[wallnum - sec->wallptr], sizeof(GLfloat) * 5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// make sure shade color handling is correct below XXX
|
||||||
if (wal->nextsector < 0)
|
if (wal->nextsector < 0)
|
||||||
Bmemcpy(w->mask.buffer, w->wall.buffer, sizeof(GLfloat) * 4 * 5);
|
Bmemcpy(w->mask.buffer, w->wall.buffer, sizeof(_prvert) * 4);
|
||||||
|
|
||||||
Bmemcpy(w->bigportal, &s->floor.buffer[(wallnum - sec->wallptr) * 5], sizeof(GLfloat) * 3);
|
Bmemcpy(w->bigportal, &s->floor.buffer[wallnum - sec->wallptr], sizeof(GLfloat) * 3);
|
||||||
Bmemcpy(&w->bigportal[5], &s->floor.buffer[(wal->point2 - sec->wallptr) * 5], sizeof(GLfloat) * 3);
|
Bmemcpy(&w->bigportal[5], &s->floor.buffer[wal->point2 - sec->wallptr], sizeof(GLfloat) * 3);
|
||||||
Bmemcpy(&w->bigportal[10], &s->ceil.buffer[(wal->point2 - sec->wallptr) * 5], sizeof(GLfloat) * 3);
|
Bmemcpy(&w->bigportal[10], &s->ceil.buffer[wal->point2 - sec->wallptr], sizeof(GLfloat) * 3);
|
||||||
Bmemcpy(&w->bigportal[15], &s->ceil.buffer[(wallnum - sec->wallptr) * 5], sizeof(GLfloat) * 3);
|
Bmemcpy(&w->bigportal[15], &s->ceil.buffer[wallnum - sec->wallptr], sizeof(GLfloat) * 3);
|
||||||
|
|
||||||
Bmemcpy(&w->cap[0], &s->ceil.buffer[(wallnum - sec->wallptr) * 5], sizeof(GLfloat) * 3);
|
//Bmemcpy(&w->cap[0], &s->ceil.buffer[wallnum - sec->wallptr], sizeof(GLfloat) * 3);
|
||||||
Bmemcpy(&w->cap[3], &s->ceil.buffer[(wal->point2 - sec->wallptr) * 5], sizeof(GLfloat) * 3);
|
//Bmemcpy(&w->cap[3], &s->ceil.buffer[wal->point2 - sec->wallptr], sizeof(GLfloat) * 3);
|
||||||
Bmemcpy(&w->cap[6], &s->ceil.buffer[(wal->point2 - sec->wallptr) * 5], sizeof(GLfloat) * 3);
|
//Bmemcpy(&w->cap[6], &s->ceil.buffer[wal->point2 - sec->wallptr], sizeof(GLfloat) * 3);
|
||||||
Bmemcpy(&w->cap[9], &s->ceil.buffer[(wallnum - sec->wallptr) * 5], sizeof(GLfloat) * 3);
|
//Bmemcpy(&w->cap[9], &s->ceil.buffer[wallnum - sec->wallptr], sizeof(GLfloat) * 3);
|
||||||
w->cap[7] += 1048576; // this number is the result of 1048574 + 2
|
//w->cap[7] += 1048576; // this number is the result of 1048574 + 2
|
||||||
w->cap[10] += 1048576; // this one is arbitrary
|
//w->cap[10] += 1048576; // this one is arbitrary
|
||||||
|
|
||||||
if (w->underover & 1)
|
if (w->underover & 1)
|
||||||
polymer_computeplane(&w->wall);
|
polymer_computeplane(&w->wall);
|
||||||
|
@ -3238,19 +3311,32 @@ static void polymer_updatewall(int16_t wallnum)
|
||||||
{
|
{
|
||||||
if (pr_nullrender < 2)
|
if (pr_nullrender < 2)
|
||||||
{
|
{
|
||||||
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, w->wall.vbo);
|
const GLintptrARB thiswalloffset = prwalldataoffset + (prwalldatasize * wallnum);
|
||||||
bglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, 4 * sizeof(GLfloat)* 5, w->wall.buffer);
|
const GLintptrARB thisoveroffset = thiswalloffset + proneplanesize;
|
||||||
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, w->over.vbo);
|
const GLintptrARB thismaskoffset = thisoveroffset + proneplanesize;
|
||||||
|
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, prmapvbo);
|
||||||
|
bglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, thiswalloffset, proneplanesize, w->wall.buffer);
|
||||||
|
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, prmapvbo);
|
||||||
if (w->over.buffer)
|
if (w->over.buffer)
|
||||||
bglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, 4 * sizeof(GLfloat)* 5, w->over.buffer);
|
bglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, thisoveroffset, proneplanesize, w->over.buffer);
|
||||||
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, w->mask.vbo);
|
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, prmapvbo);
|
||||||
bglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, 4 * sizeof(GLfloat)* 5, w->mask.buffer);
|
bglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, thismaskoffset, proneplanesize, w->mask.buffer);
|
||||||
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, w->stuffvbo);
|
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, w->stuffvbo);
|
||||||
bglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, 4 * sizeof(GLfloat)* 5, w->bigportal);
|
bglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, 4 * sizeof(GLfloat)* 5, w->bigportal);
|
||||||
bglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 4 * sizeof(GLfloat)* 5, 4 * sizeof(GLfloat)* 3, w->cap);
|
//bglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 4 * sizeof(GLfloat)* 5, 4 * sizeof(GLfloat)* 3, w->cap);
|
||||||
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
|
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
|
||||||
|
|
||||||
|
w->wall.mapvbo_vertoffset = thiswalloffset;
|
||||||
|
w->over.mapvbo_vertoffset = thisoveroffset;
|
||||||
|
w->mask.mapvbo_vertoffset = thismaskoffset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
w->wall.mapvbo_vertoffset = -1;
|
||||||
|
w->over.mapvbo_vertoffset = -1;
|
||||||
|
w->mask.mapvbo_vertoffset = -1;
|
||||||
|
}
|
||||||
|
|
||||||
w->flags.empty = 0;
|
w->flags.empty = 0;
|
||||||
w->flags.uptodate = 1;
|
w->flags.uptodate = 1;
|
||||||
|
@ -3310,27 +3396,27 @@ static void polymer_drawwall(int16_t sectnum, int16_t wallnum)
|
||||||
polymer_drawplane(&w->mask);
|
polymer_drawplane(&w->mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!searchit && (sector[sectnum].ceilingstat & 1) &&
|
//if (!searchit && (sector[sectnum].ceilingstat & 1) &&
|
||||||
((wall[wallnum].nextsector < 0) ||
|
// ((wall[wallnum].nextsector < 0) ||
|
||||||
!(sector[wall[wallnum].nextsector].ceilingstat & 1)))
|
// !(sector[wall[wallnum].nextsector].ceilingstat & 1)))
|
||||||
{
|
//{
|
||||||
bglColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
// bglColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
||||||
|
|
||||||
if (pr_vbos)
|
// if (pr_vbos)
|
||||||
{
|
// {
|
||||||
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, w->stuffvbo);
|
// bglBindBufferARB(GL_ARRAY_BUFFER_ARB, w->stuffvbo);
|
||||||
bglVertexPointer(3, GL_FLOAT, 0, (const GLvoid*)(4 * sizeof(GLfloat) * 5));
|
// bglVertexPointer(3, GL_FLOAT, 0, (const GLvoid*)(4 * sizeof(GLfloat) * 5));
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
bglVertexPointer(3, GL_FLOAT, 0, w->cap);
|
// bglVertexPointer(3, GL_FLOAT, 0, w->cap);
|
||||||
|
|
||||||
bglDrawArrays(GL_QUADS, 0, 4);
|
// bglDrawArrays(GL_QUADS, 0, 4);
|
||||||
|
|
||||||
if (pr_vbos)
|
// if (pr_vbos)
|
||||||
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
|
// bglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
|
||||||
|
|
||||||
bglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
// bglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||||
}
|
//}
|
||||||
|
|
||||||
if (pr_verbosity >= 3) OSD_Printf("PR : Finished drawing wall %i...\n", wallnum);
|
if (pr_verbosity >= 3) OSD_Printf("PR : Finished drawing wall %i...\n", wallnum);
|
||||||
}
|
}
|
||||||
|
@ -3340,7 +3426,7 @@ static void polymer_computeplane(_prplane* p)
|
||||||
{
|
{
|
||||||
GLfloat vec1[5], vec2[5], norm, r;// BxN[3], NxT[3], TxB[3];
|
GLfloat vec1[5], vec2[5], norm, r;// BxN[3], NxT[3], TxB[3];
|
||||||
int32_t i;
|
int32_t i;
|
||||||
GLfloat* buffer;
|
_prvert* buffer;
|
||||||
GLfloat* plane;
|
GLfloat* plane;
|
||||||
|
|
||||||
if (p->indices && (p->indicescount < 3))
|
if (p->indices && (p->indicescount < 3))
|
||||||
|
@ -3352,17 +3438,17 @@ static void polymer_computeplane(_prplane* p)
|
||||||
i = 0;
|
i = 0;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
vec1[0] = buffer[(INDICE(1)) + 0] - buffer[(INDICE(0)) + 0]; //x1
|
vec1[0] = buffer[(INDICE(1))].x - buffer[(INDICE(0))].x; //x1
|
||||||
vec1[1] = buffer[(INDICE(1)) + 1] - buffer[(INDICE(0)) + 1]; //y1
|
vec1[1] = buffer[(INDICE(1))].y - buffer[(INDICE(0))].y; //y1
|
||||||
vec1[2] = buffer[(INDICE(1)) + 2] - buffer[(INDICE(0)) + 2]; //z1
|
vec1[2] = buffer[(INDICE(1))].z - buffer[(INDICE(0))].z; //z1
|
||||||
vec1[3] = buffer[(INDICE(1)) + 3] - buffer[(INDICE(0)) + 3]; //s1
|
vec1[3] = buffer[(INDICE(1))].u - buffer[(INDICE(0))].u; //s1
|
||||||
vec1[4] = buffer[(INDICE(1)) + 4] - buffer[(INDICE(0)) + 4]; //t1
|
vec1[4] = buffer[(INDICE(1))].v - buffer[(INDICE(0))].v; //t1
|
||||||
|
|
||||||
vec2[0] = buffer[(INDICE(2)) + 0] - buffer[(INDICE(1)) + 0]; //x2
|
vec2[0] = buffer[(INDICE(2))].x - buffer[(INDICE(1))].x; //x2
|
||||||
vec2[1] = buffer[(INDICE(2)) + 1] - buffer[(INDICE(1)) + 1]; //y2
|
vec2[1] = buffer[(INDICE(2))].y - buffer[(INDICE(1))].y; //y2
|
||||||
vec2[2] = buffer[(INDICE(2)) + 2] - buffer[(INDICE(1)) + 2]; //z2
|
vec2[2] = buffer[(INDICE(2))].z - buffer[(INDICE(1))].z; //z2
|
||||||
vec2[3] = buffer[(INDICE(2)) + 3] - buffer[(INDICE(1)) + 3]; //s2
|
vec2[3] = buffer[(INDICE(2))].u - buffer[(INDICE(1))].u; //s2
|
||||||
vec2[4] = buffer[(INDICE(2)) + 4] - buffer[(INDICE(1)) + 4]; //t2
|
vec2[4] = buffer[(INDICE(2))].v - buffer[(INDICE(1))].v; //t2
|
||||||
|
|
||||||
polymer_crossproduct(vec2, vec1, plane);
|
polymer_crossproduct(vec2, vec1, plane);
|
||||||
|
|
||||||
|
@ -3380,7 +3466,7 @@ static void polymer_computeplane(_prplane* p)
|
||||||
plane[0] *= norm;
|
plane[0] *= norm;
|
||||||
plane[1] *= norm;
|
plane[1] *= norm;
|
||||||
plane[2] *= norm;
|
plane[2] *= norm;
|
||||||
plane[3] = -(plane[0] * buffer[0] + plane[1] * buffer[1] + plane[2] * buffer[2]);
|
plane[3] = -(plane[0] * buffer->x + plane[1] * buffer->y + plane[2] * buffer->z);
|
||||||
|
|
||||||
// calculate T and B
|
// calculate T and B
|
||||||
r = 1.0 / (vec1[3] * vec2[4] - vec2[3] * vec1[4]);
|
r = 1.0 / (vec1[3] * vec2[4] - vec2[3] * vec1[4]);
|
||||||
|
@ -3509,16 +3595,14 @@ static inline int32_t polymer_planeinfrustum(_prplane *plane, float* frustum)
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
int32_t ii = i << 2;
|
int32_t ii = i * 4;
|
||||||
j = k = plane->vertcount - 1;
|
j = k = plane->vertcount - 1;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
uint32_t jj = j + (j << 2);
|
k -= ((frustum[ii + 0] * plane->buffer[j].x +
|
||||||
|
frustum[ii + 1] * plane->buffer[j].y +
|
||||||
k -= ((frustum[ii + 0] * plane->buffer[jj + 0] +
|
frustum[ii + 2] * plane->buffer[j].z +
|
||||||
frustum[ii + 1] * plane->buffer[jj + 1] +
|
|
||||||
frustum[ii + 2] * plane->buffer[jj + 2] +
|
|
||||||
frustum[ii + 3]) < 0.f);
|
frustum[ii + 3]) < 0.f);
|
||||||
}
|
}
|
||||||
while (j--);
|
while (j--);
|
||||||
|
@ -3558,7 +3642,7 @@ void polymer_updatesprite(int32_t snum)
|
||||||
tspritetype *tspr = tspriteptr[snum];
|
tspritetype *tspr = tspriteptr[snum];
|
||||||
float xratio, yratio, ang, f;
|
float xratio, yratio, ang, f;
|
||||||
float spos[3];
|
float spos[3];
|
||||||
const GLfloat *inbuffer;
|
const _prvert *inbuffer;
|
||||||
uint8_t flipu, flipv;
|
uint8_t flipu, flipv;
|
||||||
_prsprite *s;
|
_prsprite *s;
|
||||||
|
|
||||||
|
@ -3576,8 +3660,10 @@ void polymer_updatesprite(int32_t snum)
|
||||||
{
|
{
|
||||||
prsprites[tspr->owner] = (_prsprite *)Xcalloc(sizeof(_prsprite), 1);
|
prsprites[tspr->owner] = (_prsprite *)Xcalloc(sizeof(_prsprite), 1);
|
||||||
|
|
||||||
prsprites[tspr->owner]->plane.buffer = (GLfloat *)Xcalloc(4, sizeof(GLfloat) * 5); // XXX
|
prsprites[tspr->owner]->plane.buffer = (_prvert *)Xcalloc(4, sizeof(_prvert)); // XXX
|
||||||
prsprites[tspr->owner]->plane.vertcount = 4;
|
prsprites[tspr->owner]->plane.vertcount = 4;
|
||||||
|
|
||||||
|
prsprites[tspr->owner]->plane.mapvbo_vertoffset = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((tspr->cstat & 48) && (pr_vbos > 0) && !prsprites[tspr->owner]->plane.vbo)
|
if ((tspr->cstat & 48) && (pr_vbos > 0) && !prsprites[tspr->owner]->plane.vbo)
|
||||||
|
@ -3586,7 +3672,7 @@ void polymer_updatesprite(int32_t snum)
|
||||||
{
|
{
|
||||||
bglGenBuffersARB(1, &prsprites[tspr->owner]->plane.vbo);
|
bglGenBuffersARB(1, &prsprites[tspr->owner]->plane.vbo);
|
||||||
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, prsprites[tspr->owner]->plane.vbo);
|
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, prsprites[tspr->owner]->plane.vbo);
|
||||||
bglBufferDataARB(GL_ARRAY_BUFFER_ARB, 4 * sizeof(GLfloat)* 5, NULL, mapvbousage);
|
bglBufferDataARB(GL_ARRAY_BUFFER_ARB, 4 * sizeof(_prvert), NULL, mapvbousage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3729,7 +3815,7 @@ void polymer_updatesprite(int32_t snum)
|
||||||
bglGetFloatv(GL_MODELVIEW_MATRIX, spritemodelview);
|
bglGetFloatv(GL_MODELVIEW_MATRIX, spritemodelview);
|
||||||
bglPopMatrix();
|
bglPopMatrix();
|
||||||
|
|
||||||
Bmemcpy(s->plane.buffer, inbuffer, sizeof(GLfloat) * 4 * 5);
|
Bmemcpy(s->plane.buffer, inbuffer, sizeof(_prvert) * 4);
|
||||||
|
|
||||||
if (flipu || flipv)
|
if (flipu || flipv)
|
||||||
{
|
{
|
||||||
|
@ -3737,18 +3823,18 @@ void polymer_updatesprite(int32_t snum)
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (flipu)
|
if (flipu)
|
||||||
s->plane.buffer[(i * 5) + 3] =
|
s->plane.buffer[i].u =
|
||||||
(s->plane.buffer[(i * 5) + 3] - 1.0f) * -1.0f;
|
(s->plane.buffer[i].u - 1.0f) * -1.0f;
|
||||||
if (flipv)
|
if (flipv)
|
||||||
s->plane.buffer[(i * 5) + 4] =
|
s->plane.buffer[i].v =
|
||||||
(s->plane.buffer[(i * 5) + 4] - 1.0f) * -1.0f;
|
(s->plane.buffer[i].v - 1.0f) * -1.0f;
|
||||||
}
|
}
|
||||||
while (++i < 4);
|
while (++i < 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
do
|
do
|
||||||
polymer_transformpoint(&inbuffer[i * 5], &s->plane.buffer[i * 5], spritemodelview);
|
polymer_transformpoint(&inbuffer[i].x, &s->plane.buffer[i].x, spritemodelview);
|
||||||
while (++i < 4);
|
while (++i < 4);
|
||||||
|
|
||||||
polymer_computeplane(&s->plane);
|
polymer_computeplane(&s->plane);
|
||||||
|
@ -3758,7 +3844,7 @@ void polymer_updatesprite(int32_t snum)
|
||||||
if (alignmask && (pr_vbos > 0))
|
if (alignmask && (pr_vbos > 0))
|
||||||
{
|
{
|
||||||
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, s->plane.vbo);
|
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, s->plane.vbo);
|
||||||
bglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, 4 * sizeof(GLfloat)* 5, s->plane.buffer);
|
bglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, 4 * sizeof(_prvert), s->plane.buffer);
|
||||||
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
|
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
|
||||||
}
|
}
|
||||||
else if (s->plane.vbo) // clean up the vbo if a wall/floor sprite becomes a face sprite
|
else if (s->plane.vbo) // clean up the vbo if a wall/floor sprite becomes a face sprite
|
||||||
|
@ -5554,8 +5640,8 @@ static int32_t polymer_planeinlight(_prplane* plane, _prlight* light)
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (plane->buffer[(j * 5) + i] > (lightpos[i] + light->range)) k++;
|
if ((&plane->buffer[j].x)[i] > (lightpos[i] + light->range)) k++;
|
||||||
if (plane->buffer[(j * 5) + i] < (lightpos[i] - light->range)) l++;
|
if ((&plane->buffer[j].x)[i] < (lightpos[i] - light->range)) l++;
|
||||||
}
|
}
|
||||||
while (++j < plane->vertcount);
|
while (++j < plane->vertcount);
|
||||||
|
|
||||||
|
@ -5759,8 +5845,8 @@ static inline void polymer_culllight(int16_t lighti)
|
||||||
if (wallvisible(light->x, light->y, sec->wallptr + i) &&
|
if (wallvisible(light->x, light->y, sec->wallptr + i) &&
|
||||||
(j == 2 || polymer_planeinlight(&w->mask, light))) {
|
(j == 2 || polymer_planeinlight(&w->mask, light))) {
|
||||||
if ((w->mask.vertcount == 4) &&
|
if ((w->mask.vertcount == 4) &&
|
||||||
(w->mask.buffer[(0 * 5) + 1] >= w->mask.buffer[(3 * 5) + 1]) &&
|
(w->mask.buffer[0].y >= w->mask.buffer[3].y) &&
|
||||||
(w->mask.buffer[(1 * 5) + 1] >= w->mask.buffer[(2 * 5) + 1]))
|
(w->mask.buffer[1].y >= w->mask.buffer[2].y))
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
continue;
|
continue;
|
||||||
|
@ -5998,7 +6084,10 @@ void PR_CALLBACK polymer_debugoutputcallback(GLenum source,GLenum type,GLuint
|
||||||
UNREFERENCED_PARAMETER(length);
|
UNREFERENCED_PARAMETER(length);
|
||||||
UNREFERENCED_PARAMETER(userParam);
|
UNREFERENCED_PARAMETER(userParam);
|
||||||
|
|
||||||
|
if (type == GL_DEBUG_TYPE_ERROR_ARB)
|
||||||
|
{
|
||||||
OSD_Printf("PR : Received OpenGL debug message: %s\n", message);
|
OSD_Printf("PR : Received OpenGL debug message: %s\n", message);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue