mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-12 03:00:38 +00:00
THE FUTURE IS THE PAST
git-svn-id: https://svn.eduke32.com/eduke32@699 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
65d095f88a
commit
7c7b1c6590
2 changed files with 170 additions and 251 deletions
|
@ -90,9 +90,8 @@ typedef struct s_prwall {
|
||||||
GLfloat* bigportal;
|
GLfloat* bigportal;
|
||||||
// attributes
|
// attributes
|
||||||
GLfloat wallcolor[4], overcolor[4], maskcolor[4];
|
GLfloat wallcolor[4], overcolor[4], maskcolor[4];
|
||||||
GLfloat wallglpic, overglpic, wallfbglpic, overfbglpic, maskglpic;
|
GLuint wallglpic, overglpic, wallfbglpic, overfbglpic, maskglpic;
|
||||||
// build wall data# ifdef POLYMER_C
|
// build wall data
|
||||||
|
|
||||||
short cstat, nwallcstat;
|
short cstat, nwallcstat;
|
||||||
short picnum, overpicnum, nwallpicnum;
|
short picnum, overpicnum, nwallpicnum;
|
||||||
signed char shade;
|
signed char shade;
|
||||||
|
@ -132,7 +131,8 @@ extern int globalposx, globalposy, globalposz, globalhoriz;
|
||||||
|
|
||||||
// CORE
|
// CORE
|
||||||
static void polymer_displayrooms(short sectnum);
|
static void polymer_displayrooms(short sectnum);
|
||||||
static void polymer_inb4mirror(short sectnum);
|
static void polymer_drawplane(short sectnum, short wallnum, GLuint glpic, GLfloat* color, GLfloat* buffer, GLushort* indices, int indicecount, GLdouble* plane);
|
||||||
|
static void polymer_inb4mirror(GLfloat* buffer, GLdouble* plane);
|
||||||
static void polymer_animatesprites(void);
|
static void polymer_animatesprites(void);
|
||||||
// SECTORS
|
// SECTORS
|
||||||
static int polymer_initsector(short sectnum);
|
static int polymer_initsector(short sectnum);
|
||||||
|
@ -145,7 +145,7 @@ static void polymer_drawsector(short sectnum);
|
||||||
// WALLS
|
// WALLS
|
||||||
static int polymer_initwall(short wallnum);
|
static int polymer_initwall(short wallnum);
|
||||||
static void polymer_updatewall(short wallnum);
|
static void polymer_updatewall(short wallnum);
|
||||||
static void polymer_drawwall(short wallnum);
|
static void polymer_drawwall(short sectnum, short wallnum);
|
||||||
// HSR
|
// HSR
|
||||||
static void polymer_buffertoplane(GLfloat* buffer, GLushort* indices, GLdouble* plane);
|
static void polymer_buffertoplane(GLfloat* buffer, GLushort* indices, GLdouble* plane);
|
||||||
static void polymer_crossproduct(GLfloat* in_a, GLfloat* in_b, GLdouble* out);
|
static void polymer_crossproduct(GLfloat* in_a, GLfloat* in_b, GLdouble* out);
|
||||||
|
|
|
@ -49,7 +49,9 @@ GLdouble *curmodelviewmatrix;
|
||||||
GLdouble projectionmatrix[16];
|
GLdouble projectionmatrix[16];
|
||||||
|
|
||||||
int updatesectors = 1;
|
int updatesectors = 1;
|
||||||
|
|
||||||
int depth;
|
int depth;
|
||||||
|
int mirrorfrom[10]; // -3: no mirror; -2: floor; -1: ceiling; >=0: wallnum
|
||||||
|
|
||||||
GLUtesselator* prtess;
|
GLUtesselator* prtess;
|
||||||
|
|
||||||
|
@ -161,9 +163,6 @@ void polymer_glinit(void)
|
||||||
|
|
||||||
bglEnable(GL_CULL_FACE);
|
bglEnable(GL_CULL_FACE);
|
||||||
bglCullFace(GL_BACK);
|
bglCullFace(GL_BACK);
|
||||||
|
|
||||||
// this probably shouldn't be here
|
|
||||||
depth = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void polymer_loadboard(void)
|
void polymer_loadboard(void)
|
||||||
|
@ -247,7 +246,7 @@ void polymer_drawrooms(int daposx, int daposy, int daposz, short
|
||||||
while (i < numwalls)
|
while (i < numwalls)
|
||||||
{
|
{
|
||||||
polymer_updatewall(i);
|
polymer_updatewall(i);
|
||||||
polymer_drawwall(i);
|
polymer_drawwall(sectorofwall(i), i);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
viewangle = daang;
|
viewangle = daang;
|
||||||
|
@ -273,6 +272,8 @@ void polymer_drawrooms(int daposx, int daposy, int daposz, short
|
||||||
}
|
}
|
||||||
|
|
||||||
// GO!
|
// GO!
|
||||||
|
depth = 0;
|
||||||
|
mirrorfrom[0] = -3; // no mirror
|
||||||
polymer_displayrooms(dacursectnum);
|
polymer_displayrooms(dacursectnum);
|
||||||
|
|
||||||
viewangle = daang;
|
viewangle = daang;
|
||||||
|
@ -321,13 +322,7 @@ void polymer_drawmaskwall(int damaskwallcnt)
|
||||||
|
|
||||||
w = prwalls[maskwall[damaskwallcnt]];
|
w = prwalls[maskwall[damaskwallcnt]];
|
||||||
|
|
||||||
bglBindTexture(GL_TEXTURE_2D, w->maskglpic);
|
polymer_drawplane(-1, -3, w->maskglpic, w->maskcolor, w->portal, NULL, 0, NULL);
|
||||||
|
|
||||||
bglColor4f(w->maskcolor[0], w->maskcolor[1], w->maskcolor[2], w->maskcolor[3]);
|
|
||||||
|
|
||||||
bglVertexPointer(3, GL_FLOAT, 5 * sizeof(GLfloat), w->portal);
|
|
||||||
bglTexCoordPointer(2, GL_FLOAT, 5 * sizeof(GLfloat), &w->portal[3]);
|
|
||||||
bglDrawArrays(GL_QUADS, 0, 4);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void polymer_drawsprite(int snum)
|
void polymer_drawsprite(int snum)
|
||||||
|
@ -460,15 +455,10 @@ void polymer_drawsprite(int snum)
|
||||||
if (tspr->cstat & 8)
|
if (tspr->cstat & 8)
|
||||||
bglScalef(1.0f, -1.0f, 1.0f);
|
bglScalef(1.0f, -1.0f, 1.0f);
|
||||||
|
|
||||||
bglBindTexture(GL_TEXTURE_2D, glpic);
|
|
||||||
bglColor4f(color[0], color[1], color[2], color[3]);
|
|
||||||
|
|
||||||
if ((tspr->cstat & 64) && (((tspr->cstat>>4) & 3) == 1))
|
if ((tspr->cstat & 64) && (((tspr->cstat>>4) & 3) == 1))
|
||||||
bglEnable(GL_CULL_FACE);
|
bglEnable(GL_CULL_FACE);
|
||||||
|
|
||||||
bglVertexPointer(3, GL_FLOAT, 5 * sizeof(GLfloat), curspritedata);
|
polymer_drawplane(-1, -3, glpic, color, curspritedata, NULL, 0, NULL);
|
||||||
bglTexCoordPointer(2, GL_FLOAT, 5 * sizeof(GLfloat), &curspritedata[3]);
|
|
||||||
bglDrawArrays(GL_QUADS, 0, 4);
|
|
||||||
|
|
||||||
if ((tspr->cstat & 64) && (((tspr->cstat>>4) & 3) == 1))
|
if ((tspr->cstat & 64) && (((tspr->cstat>>4) & 3) == 1))
|
||||||
bglDisable(GL_CULL_FACE);
|
bglDisable(GL_CULL_FACE);
|
||||||
|
@ -526,10 +516,7 @@ static void polymer_displayrooms(short dacursectnum)
|
||||||
localspritesortcnt = localmaskwallcnt = 0;
|
localspritesortcnt = localmaskwallcnt = 0;
|
||||||
|
|
||||||
polymer_pokesector(dacursectnum);
|
polymer_pokesector(dacursectnum);
|
||||||
if (!depth)
|
|
||||||
polymer_drawsector(dacursectnum);
|
polymer_drawsector(dacursectnum);
|
||||||
else
|
|
||||||
polymer_drawsector(dacursectnum | 8192);
|
|
||||||
polymer_scansprites(dacursectnum, localtsprite, &localspritesortcnt);
|
polymer_scansprites(dacursectnum, localtsprite, &localspritesortcnt);
|
||||||
drawingstate[dacursectnum] = 1;
|
drawingstate[dacursectnum] = 1;
|
||||||
|
|
||||||
|
@ -542,7 +529,8 @@ static void polymer_displayrooms(short dacursectnum)
|
||||||
if (((wallvisible(sec->wallptr + i))) &&
|
if (((wallvisible(sec->wallptr + i))) &&
|
||||||
(polymer_portalinfrustum(sec->wallptr + i, frustum)))
|
(polymer_portalinfrustum(sec->wallptr + i, frustum)))
|
||||||
{
|
{
|
||||||
polymer_drawwall(sec->wallptr + i);
|
if (mirrorfrom[depth] != (sec->wallptr + i))
|
||||||
|
polymer_drawwall(dacursectnum, sec->wallptr + i);
|
||||||
// mask
|
// mask
|
||||||
if ((wal->cstat&48) == 16) localmaskwall[localmaskwallcnt++] = sec->wallptr + i;
|
if ((wal->cstat&48) == 16) localmaskwall[localmaskwallcnt++] = sec->wallptr + i;
|
||||||
|
|
||||||
|
@ -557,6 +545,8 @@ static void polymer_displayrooms(short dacursectnum)
|
||||||
wal = &wall[sec->wallptr + i];
|
wal = &wall[sec->wallptr + i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mirrorfrom[depth] = -3;
|
||||||
|
|
||||||
firstback = back;
|
firstback = back;
|
||||||
|
|
||||||
while (front != back)
|
while (front != back)
|
||||||
|
@ -592,7 +582,7 @@ static void polymer_displayrooms(short dacursectnum)
|
||||||
if ((wallvisible(sec->wallptr + i)) &&
|
if ((wallvisible(sec->wallptr + i)) &&
|
||||||
(polymer_portalinfrustum(sec->wallptr + i, frustum)))
|
(polymer_portalinfrustum(sec->wallptr + i, frustum)))
|
||||||
{
|
{
|
||||||
polymer_drawwall(sec->wallptr + i);
|
polymer_drawwall(sectorqueue[front], sec->wallptr + i);
|
||||||
// mask
|
// mask
|
||||||
if ((wal->cstat&48) == 16) localmaskwall[localmaskwallcnt++] = sec->wallptr + i;
|
if ((wal->cstat&48) == 16) localmaskwall[localmaskwallcnt++] = sec->wallptr + i;
|
||||||
|
|
||||||
|
@ -662,37 +652,154 @@ static void polymer_displayrooms(short dacursectnum)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void polymer_inb4mirror(short sectnum)
|
|
||||||
|
#define OMGDRAWSHIT \
|
||||||
|
bglVertexPointer(3, GL_FLOAT, 5 * sizeof(GLfloat), buffer); \
|
||||||
|
bglTexCoordPointer(2, GL_FLOAT, 5 * sizeof(GLfloat), &buffer[3]); \
|
||||||
|
if (!indices) \
|
||||||
|
bglDrawArrays(GL_QUADS, 0, 4); \
|
||||||
|
else \
|
||||||
|
bglDrawElements(GL_TRIANGLES, indicecount, GL_UNSIGNED_SHORT, indices)
|
||||||
|
|
||||||
|
static void polymer_drawplane(short sectnum, short wallnum, GLuint glpic, GLfloat* color, GLfloat* buffer, GLushort* indices, int indicecount, GLdouble* plane)
|
||||||
|
{
|
||||||
|
|
||||||
|
if ((depth < 1) && (plane != NULL) && 1) // insert mirror condition here
|
||||||
|
{
|
||||||
|
int gx, gy, gz, px, py, pz;
|
||||||
|
float coeff;
|
||||||
|
|
||||||
|
// set the stencil to 1 and clear the area to black where the sector floor is
|
||||||
|
bglDisable(GL_TEXTURE_2D);
|
||||||
|
bglDisable(GL_FOG);
|
||||||
|
bglColor4f(0.0f, 1.0f, 0.0f, 1.0f);
|
||||||
|
bglDepthMask(GL_FALSE);
|
||||||
|
|
||||||
|
bglEnable(GL_STENCIL_TEST);
|
||||||
|
bglStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
|
||||||
|
bglStencilFunc(GL_EQUAL, 0, 0xffffffff);
|
||||||
|
|
||||||
|
OMGDRAWSHIT;
|
||||||
|
bglDepthMask(GL_TRUE);
|
||||||
|
|
||||||
|
// set the depth to 1 where we put the stencil by drawing a screen aligned quad
|
||||||
|
bglStencilFunc(GL_EQUAL, 1, 0xffffffff);
|
||||||
|
bglStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
|
||||||
|
bglDepthFunc(GL_ALWAYS);
|
||||||
|
bglMatrixMode(GL_PROJECTION);
|
||||||
|
bglPushMatrix();
|
||||||
|
bglLoadIdentity();
|
||||||
|
bglMatrixMode(GL_MODELVIEW);
|
||||||
|
bglPushMatrix();
|
||||||
|
bglLoadIdentity();
|
||||||
|
|
||||||
|
bglColor4f(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
bglBegin(GL_QUADS);
|
||||||
|
bglVertex3f(-1.0f, -1.0f, 1.0f);
|
||||||
|
bglVertex3f(1.0f, -1.0f, 1.0f);
|
||||||
|
bglVertex3f(1.0f, 1.0f, 1.0f);
|
||||||
|
bglVertex3f(-1.0f, 1.0f, 1.0f);
|
||||||
|
bglEnd();
|
||||||
|
|
||||||
|
bglMatrixMode(GL_PROJECTION);
|
||||||
|
bglPopMatrix();
|
||||||
|
bglMatrixMode(GL_MODELVIEW);
|
||||||
|
bglPopMatrix();
|
||||||
|
bglDepthFunc(GL_LEQUAL);
|
||||||
|
bglEnable(GL_TEXTURE_2D);
|
||||||
|
bglEnable(GL_FOG);
|
||||||
|
// finally draw the shit
|
||||||
|
bglPushMatrix();
|
||||||
|
bglClipPlane(GL_CLIP_PLANE0, plane);
|
||||||
|
polymer_inb4mirror(buffer, plane);
|
||||||
|
bglCullFace(GL_FRONT);
|
||||||
|
bglEnable(GL_CLIP_PLANE0);
|
||||||
|
|
||||||
|
gx = globalposx;
|
||||||
|
gy = globalposy;
|
||||||
|
gz = globalposz;
|
||||||
|
|
||||||
|
// map the player pos from build to polymer
|
||||||
|
px = globalposy;
|
||||||
|
py = -globalposz / 16;
|
||||||
|
pz = -globalposx;
|
||||||
|
|
||||||
|
// calculate new player position on the other side of the mirror
|
||||||
|
// this way the basic build visibility shit can be used (wallvisible)
|
||||||
|
coeff = -plane[0] * px +
|
||||||
|
-plane[1] * py +
|
||||||
|
-plane[2] * pz +
|
||||||
|
-plane[3];
|
||||||
|
|
||||||
|
coeff /= (float)(plane[0] * plane[0] +
|
||||||
|
plane[1] * plane[1] +
|
||||||
|
plane[2] * plane[2]);
|
||||||
|
|
||||||
|
px = coeff*plane[0]*2 + px;
|
||||||
|
py = coeff*plane[1]*2 + py;
|
||||||
|
pz = coeff*plane[2]*2 + pz;
|
||||||
|
|
||||||
|
// map back from polymer to build
|
||||||
|
globalposx = -pz;
|
||||||
|
globalposy = px;
|
||||||
|
globalposz = -py * 16;
|
||||||
|
|
||||||
|
depth++;
|
||||||
|
mirrorfrom[depth] = wallnum;
|
||||||
|
polymer_displayrooms(sectnum);
|
||||||
|
depth--;
|
||||||
|
|
||||||
|
globalposx = gx;
|
||||||
|
globalposy = gy;
|
||||||
|
globalposz = gz;
|
||||||
|
|
||||||
|
bglDisable(GL_CLIP_PLANE0);
|
||||||
|
bglCullFace(GL_BACK);
|
||||||
|
bglMatrixMode(GL_MODELVIEW);
|
||||||
|
bglPopMatrix();
|
||||||
|
|
||||||
|
bglColor4f(color[0], color[1], color[2], 0.5f);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
bglColor4f(color[0], color[1], color[2], color[3]);
|
||||||
|
|
||||||
|
bglBindTexture(GL_TEXTURE_2D, glpic);
|
||||||
|
OMGDRAWSHIT;
|
||||||
|
|
||||||
|
if ((depth < 1) && (plane != NULL) && 1) // insert mirror condition here
|
||||||
|
{
|
||||||
|
bglDisable(GL_STENCIL_TEST);
|
||||||
|
bglClear(GL_STENCIL_BUFFER_BIT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void polymer_inb4mirror(GLfloat* buffer, GLdouble* plane)
|
||||||
{
|
{
|
||||||
float pv;
|
float pv;
|
||||||
GLdouble *normal;
|
|
||||||
float reflectionmatrix[16];
|
float reflectionmatrix[16];
|
||||||
|
|
||||||
|
pv = buffer[0] * plane[0] +
|
||||||
|
buffer[1] * plane[1] +
|
||||||
|
buffer[2] * plane[2];
|
||||||
|
|
||||||
normal = prsectors[sectnum]->floorplane;
|
reflectionmatrix[0] = 1 - (2 * plane[0] * plane[0]);
|
||||||
|
reflectionmatrix[1] = -2 * plane[0] * plane[1];
|
||||||
pv = prsectors[sectnum]->floorbuffer[0] * normal[0] +
|
reflectionmatrix[2] = -2 * plane[0] * plane[2];
|
||||||
prsectors[sectnum]->floorbuffer[1] * normal[1] +
|
|
||||||
prsectors[sectnum]->floorbuffer[2] * normal[2];
|
|
||||||
|
|
||||||
reflectionmatrix[0] = 1 - (2 * normal[0] * normal[0]);
|
|
||||||
reflectionmatrix[1] = -2 * normal[0] * normal[1];
|
|
||||||
reflectionmatrix[2] = -2 * normal[0] * normal[2];
|
|
||||||
reflectionmatrix[3] = 0;
|
reflectionmatrix[3] = 0;
|
||||||
|
|
||||||
reflectionmatrix[4] = -2 * normal[0] * normal[1];
|
reflectionmatrix[4] = -2 * plane[0] * plane[1];
|
||||||
reflectionmatrix[5] = 1 - (2 * normal[1] * normal[1]);
|
reflectionmatrix[5] = 1 - (2 * plane[1] * plane[1]);
|
||||||
reflectionmatrix[6] = -2 * normal[1] * normal[2];
|
reflectionmatrix[6] = -2 * plane[1] * plane[2];
|
||||||
reflectionmatrix[7] = 0;
|
reflectionmatrix[7] = 0;
|
||||||
|
|
||||||
reflectionmatrix[8] = -2 * normal[0] * normal[2];
|
reflectionmatrix[8] = -2 * plane[0] * plane[2];
|
||||||
reflectionmatrix[9] = -2 * normal[1] * normal[2];
|
reflectionmatrix[9] = -2 * plane[1] * plane[2];
|
||||||
reflectionmatrix[10] = 1 - (2 * normal[2] * normal[2]);
|
reflectionmatrix[10] = 1 - (2 * plane[2] * plane[2]);
|
||||||
reflectionmatrix[11] = 0;
|
reflectionmatrix[11] = 0;
|
||||||
|
|
||||||
reflectionmatrix[12] = 2 * pv * normal[0];
|
reflectionmatrix[12] = 2 * pv * plane[0];
|
||||||
reflectionmatrix[13] = 2 * pv * normal[1];
|
reflectionmatrix[13] = 2 * pv * plane[1];
|
||||||
reflectionmatrix[14] = 2 * pv * normal[2];
|
reflectionmatrix[14] = 2 * pv * plane[2];
|
||||||
reflectionmatrix[15] = 1;
|
reflectionmatrix[15] = 1;
|
||||||
|
|
||||||
bglMultMatrixf(reflectionmatrix);
|
bglMultMatrixf(reflectionmatrix);
|
||||||
|
@ -1067,177 +1174,21 @@ static int polymer_buildfloor(short sectnum)
|
||||||
static void polymer_drawsector(short sectnum)
|
static void polymer_drawsector(short sectnum)
|
||||||
{
|
{
|
||||||
sectortype *sec;
|
sectortype *sec;
|
||||||
walltype *wal;
|
|
||||||
_prsector* s;
|
_prsector* s;
|
||||||
int skipfloor, gx, gy, gz, px, py, pz;
|
|
||||||
float coeff;
|
|
||||||
|
|
||||||
if (pr_verbosity >= 3) OSD_Printf("PR : Drawing sector %i...\n", sectnum);
|
if (pr_verbosity >= 3) OSD_Printf("PR : Drawing sector %i...\n", sectnum);
|
||||||
|
|
||||||
if (sectnum & 8192)
|
|
||||||
{
|
|
||||||
skipfloor = 1;
|
|
||||||
sectnum ^= 8192;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
skipfloor = 0;
|
|
||||||
|
|
||||||
sec = §or[sectnum];
|
sec = §or[sectnum];
|
||||||
wal = &wall[sec->wallptr];
|
|
||||||
s = prsectors[sectnum];
|
s = prsectors[sectnum];
|
||||||
|
|
||||||
if (prsectors[sectnum] == NULL)
|
if (!(sec->floorstat & 1) && (mirrorfrom[depth] != -2))
|
||||||
{
|
polymer_drawplane(sectnum, -2, s->floorglpic, s->floorcolor,
|
||||||
polymer_initsector(sectnum);
|
s->floorbuffer, s->floorindices, s->indicescount,
|
||||||
polymer_updatesector(sectnum);
|
s->floorplane);
|
||||||
}
|
if (!(sec->ceilingstat & 1) && (mirrorfrom[depth] != -1))
|
||||||
|
polymer_drawplane(sectnum, -1, s->ceilglpic, s->ceilcolor,
|
||||||
if (skipfloor)
|
s->ceilbuffer, s->ceilindices, s->indicescount,
|
||||||
goto ceiling;
|
s->ceilplane);
|
||||||
|
|
||||||
if ((depth < 1))
|
|
||||||
{
|
|
||||||
//bglColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
|
||||||
// set the stencil to 1 and clear the area to black where the sector floor is
|
|
||||||
bglDisable(GL_TEXTURE_2D);
|
|
||||||
bglDisable(GL_FOG);
|
|
||||||
bglColor4f(0.0f, 1.0f, 0.0f, 1.0f);
|
|
||||||
bglDepthMask(0);
|
|
||||||
|
|
||||||
bglEnable(GL_STENCIL_TEST);
|
|
||||||
bglStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
|
|
||||||
bglStencilFunc(GL_EQUAL, 0, 0xffffffff);
|
|
||||||
|
|
||||||
bglVertexPointer(3, GL_FLOAT, 5 * sizeof(GLfloat), s->floorbuffer);
|
|
||||||
bglTexCoordPointer(2, GL_FLOAT, 5 * sizeof(GLfloat), &s->floorbuffer[3]);
|
|
||||||
bglDrawElements(GL_TRIANGLES, s->indicescount, GL_UNSIGNED_SHORT, s->floorindices);
|
|
||||||
//bglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
|
||||||
bglDepthMask(1);
|
|
||||||
|
|
||||||
// set the depth to 1 where we put the stencil by drawing a screen aligned quad
|
|
||||||
bglStencilFunc(GL_EQUAL, 1, 0xffffffff);
|
|
||||||
bglStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
|
|
||||||
bglDepthFunc(GL_ALWAYS);
|
|
||||||
bglMatrixMode(GL_PROJECTION);
|
|
||||||
bglPushMatrix();
|
|
||||||
bglLoadIdentity();
|
|
||||||
bglMatrixMode(GL_MODELVIEW);
|
|
||||||
bglPushMatrix();
|
|
||||||
bglLoadIdentity();
|
|
||||||
|
|
||||||
bglColor4f(0.0f, 0.0f, 0.0f, 1.0f);
|
|
||||||
bglBegin(GL_QUADS);
|
|
||||||
bglVertex3f(-1.0f, -1.0f, 1.0f);
|
|
||||||
bglVertex3f(1.0f, -1.0f, 1.0f);
|
|
||||||
bglVertex3f(1.0f, 1.0f, 1.0f);
|
|
||||||
bglVertex3f(-1.0f, 1.0f, 1.0f);
|
|
||||||
bglEnd();
|
|
||||||
|
|
||||||
bglMatrixMode(GL_PROJECTION);
|
|
||||||
bglPopMatrix();
|
|
||||||
bglMatrixMode(GL_MODELVIEW);
|
|
||||||
bglPopMatrix();
|
|
||||||
bglDepthFunc(GL_LEQUAL);
|
|
||||||
bglEnable(GL_TEXTURE_2D);
|
|
||||||
bglEnable(GL_FOG);
|
|
||||||
// finally draw the shit
|
|
||||||
bglPushMatrix();
|
|
||||||
bglClipPlane(GL_CLIP_PLANE0, s->floorplane);
|
|
||||||
polymer_inb4mirror(sectnum);
|
|
||||||
//bglDisable(GL_CULL_FACE);
|
|
||||||
bglCullFace(GL_FRONT);
|
|
||||||
bglEnable(GL_CLIP_PLANE0);
|
|
||||||
|
|
||||||
gx = globalposx;
|
|
||||||
gy = globalposy;
|
|
||||||
gz = globalposz;
|
|
||||||
|
|
||||||
// map the player pos from build to polymer
|
|
||||||
px = globalposy;
|
|
||||||
py = -globalposz / 16;
|
|
||||||
pz = -globalposx;
|
|
||||||
|
|
||||||
// calculate new player position on the other side of the mirror
|
|
||||||
// this way the basic build visibility shit can be used (wallvisible)
|
|
||||||
coeff = -s->floorplane[0] * px +
|
|
||||||
-s->floorplane[1] * py +
|
|
||||||
-s->floorplane[2] * pz +
|
|
||||||
-s->floorplane[3];
|
|
||||||
|
|
||||||
coeff /= (float)(s->floorplane[0] * s->floorplane[0] +
|
|
||||||
s->floorplane[1] * s->floorplane[1] +
|
|
||||||
s->floorplane[2] * s->floorplane[2]);
|
|
||||||
|
|
||||||
px = coeff*s->floorplane[0]*2 + px;
|
|
||||||
py = coeff*s->floorplane[1]*2 + py;
|
|
||||||
pz = coeff*s->floorplane[2]*2 + pz;
|
|
||||||
|
|
||||||
// map back from polymer to build
|
|
||||||
globalposx = -pz;
|
|
||||||
globalposy = px;
|
|
||||||
globalposz = -py * 16;
|
|
||||||
|
|
||||||
depth++;
|
|
||||||
polymer_displayrooms(sectnum);
|
|
||||||
depth--;
|
|
||||||
|
|
||||||
globalposx = gx;
|
|
||||||
globalposy = gy;
|
|
||||||
globalposz = gz;
|
|
||||||
|
|
||||||
bglDisable(GL_CLIP_PLANE0);
|
|
||||||
bglCullFace(GL_BACK);
|
|
||||||
//bglEnable(GL_CULL_FACE);
|
|
||||||
bglMatrixMode(GL_MODELVIEW);
|
|
||||||
bglPopMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
// floor
|
|
||||||
if (sec->floorstat & 1)
|
|
||||||
bglColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
|
||||||
|
|
||||||
bglBindTexture(GL_TEXTURE_2D, s->floorglpic);
|
|
||||||
bglColor4f(s->floorcolor[0], s->floorcolor[1], s->floorcolor[2], (!depth) ? 0.5f : s->floorcolor[3]);
|
|
||||||
bglVertexPointer(3, GL_FLOAT, 5 * sizeof(GLfloat), s->floorbuffer);
|
|
||||||
bglTexCoordPointer(2, GL_FLOAT, 5 * sizeof(GLfloat), &s->floorbuffer[3]);
|
|
||||||
bglDrawElements(GL_TRIANGLES, s->indicescount, GL_UNSIGNED_SHORT, s->floorindices);
|
|
||||||
|
|
||||||
if (s->floorfbglpic)
|
|
||||||
{
|
|
||||||
bglBindTexture(GL_TEXTURE_2D, s->floorfbglpic);
|
|
||||||
bglColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
|
||||||
bglDrawElements(GL_TRIANGLES, s->indicescount, GL_UNSIGNED_SHORT, s->floorindices);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sec->floorstat & 1)
|
|
||||||
bglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
|
||||||
if ((depth < 1))
|
|
||||||
{
|
|
||||||
//bglEnable(GL_DEPTH_TEST);
|
|
||||||
bglDisable(GL_STENCIL_TEST);
|
|
||||||
bglClear(GL_STENCIL_BUFFER_BIT);
|
|
||||||
}
|
|
||||||
|
|
||||||
ceiling:
|
|
||||||
// ceiling
|
|
||||||
if (sec->ceilingstat & 1)
|
|
||||||
bglColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
|
||||||
|
|
||||||
bglBindTexture(GL_TEXTURE_2D, s->ceilglpic);
|
|
||||||
bglColor4f(s->ceilcolor[0], s->ceilcolor[1], s->ceilcolor[2], s->ceilcolor[3]);
|
|
||||||
bglVertexPointer(3, GL_FLOAT, 5 * sizeof(GLfloat), s->ceilbuffer);
|
|
||||||
bglTexCoordPointer(2, GL_FLOAT, 5 * sizeof(GLfloat), &s->ceilbuffer[3]);
|
|
||||||
bglDrawElements(GL_TRIANGLES, s->indicescount, GL_UNSIGNED_SHORT, s->ceilindices);
|
|
||||||
|
|
||||||
if (s->ceilfbglpic)
|
|
||||||
{
|
|
||||||
bglBindTexture(GL_TEXTURE_2D, s->ceilfbglpic);
|
|
||||||
bglColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
|
||||||
bglDrawElements(GL_TRIANGLES, s->indicescount, GL_UNSIGNED_SHORT, s->floorindices);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sec->ceilingstat & 1)
|
|
||||||
bglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
|
||||||
|
|
||||||
if (pr_verbosity >= 3) OSD_Printf("PR : Finished drawing sector %i...\n", sectnum);
|
if (pr_verbosity >= 3) OSD_Printf("PR : Finished drawing sector %i...\n", sectnum);
|
||||||
}
|
}
|
||||||
|
@ -1698,7 +1649,7 @@ static void polymer_updatewall(short wallnum)
|
||||||
if (pr_verbosity >= 3) OSD_Printf("PR : Updated wall %i.\n", wallnum);
|
if (pr_verbosity >= 3) OSD_Printf("PR : Updated wall %i.\n", wallnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void polymer_drawwall(short wallnum)
|
static void polymer_drawwall(short sectnum, short wallnum)
|
||||||
{
|
{
|
||||||
_prwall *w;
|
_prwall *w;
|
||||||
|
|
||||||
|
@ -1706,48 +1657,16 @@ static void polymer_drawwall(short wallnum)
|
||||||
|
|
||||||
w = prwalls[wallnum];
|
w = prwalls[wallnum];
|
||||||
|
|
||||||
if (w->underover & 1)
|
if ((w->underover & 1) && !(w->underover & 4))
|
||||||
{
|
{
|
||||||
if (w->underover & 4)
|
polymer_drawplane(sectnum, wallnum, w->wallglpic, w->wallcolor,
|
||||||
bglColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
w->wallbuffer, NULL, 0, NULL);
|
||||||
|
|
||||||
bglBindTexture(GL_TEXTURE_2D, w->wallglpic);
|
|
||||||
bglColor4f(w->wallcolor[0], w->wallcolor[1], w->wallcolor[2], w->wallcolor[3]);
|
|
||||||
bglVertexPointer(3, GL_FLOAT, 5 * sizeof(GLfloat), w->wallbuffer);
|
|
||||||
bglTexCoordPointer(2, GL_FLOAT, 5 * sizeof(GLfloat), &w->wallbuffer[3]);
|
|
||||||
bglDrawArrays(GL_QUADS, 0, 4);
|
|
||||||
|
|
||||||
if ((w->wallfbglpic) && !(w->underover & 4))
|
|
||||||
{
|
|
||||||
bglBindTexture(GL_TEXTURE_2D, w->wallfbglpic);
|
|
||||||
bglColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
|
||||||
bglDrawArrays(GL_QUADS, 0, 4);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (w->underover & 4)
|
if ((w->underover & 2) && !(w->underover & 8))
|
||||||
bglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (w->underover & 2)
|
|
||||||
{
|
{
|
||||||
if (w->underover & 8)
|
polymer_drawplane(sectnum, wallnum, w->overglpic, w->overcolor,
|
||||||
bglColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
w->overbuffer, NULL, 0, NULL);
|
||||||
|
|
||||||
bglBindTexture(GL_TEXTURE_2D, w->overglpic);
|
|
||||||
bglColor4f(w->overcolor[0], w->overcolor[1], w->overcolor[2], w->overcolor[3]);
|
|
||||||
bglVertexPointer(3, GL_FLOAT, 5 * sizeof(GLfloat), w->overbuffer);
|
|
||||||
bglTexCoordPointer(2, GL_FLOAT, 5 * sizeof(GLfloat), &w->overbuffer[3]);
|
|
||||||
bglDrawArrays(GL_QUADS, 0, 4);
|
|
||||||
|
|
||||||
if ((w->overfbglpic) && !(w->underover & 4))
|
|
||||||
{
|
|
||||||
bglBindTexture(GL_TEXTURE_2D, w->overfbglpic);
|
|
||||||
bglColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
|
||||||
bglDrawArrays(GL_QUADS, 0, 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (w->underover & 8)
|
|
||||||
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);
|
||||||
|
|
Loading…
Reference in a new issue