*** empty log message ***
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@936 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
+1
-1
@@ -82,7 +82,7 @@ extern int lastmillis; // last time
|
||||
extern int curtime; // current frame time
|
||||
extern int gamemode, nextmode;
|
||||
extern int xtraverts;
|
||||
extern bool minimap, reflecting;
|
||||
extern bool minimap, reflecting, refracting;
|
||||
extern bool demoplayback;
|
||||
extern bool intermission;
|
||||
extern bool arenajoin;
|
||||
|
||||
+1
-1
@@ -77,7 +77,7 @@ extern void render_square(int wtex, float floor1, float floor2, float ceil1, flo
|
||||
extern void render_tris(int x, int y, int size, bool topleft, sqr *h1, sqr *h2, sqr *s, sqr *t, sqr *u, sqr *v);
|
||||
extern void setwatercolor(char *r = "", char *g = "", char *b = "", char *a = "");
|
||||
extern void addwaterquad(int x, int y, int size);
|
||||
extern int renderwater(float hf, GLuint tex);
|
||||
extern int renderwater(float hf, GLuint reflecttex, GLuint refracttex);
|
||||
extern void resetcubes();
|
||||
extern void setupstrips();
|
||||
extern void renderstripssky();
|
||||
|
||||
+33
-17
@@ -387,8 +387,8 @@ inline void vertw(int v1, float v2, int v3, float t, int tex)
|
||||
float v = cosf(angle);
|
||||
if(tex>0)
|
||||
{
|
||||
glColor4f(1, 1, 1, 0.15f + max(v, 0)*0.15f);
|
||||
glTexCoord3f(v1+v*0.3f, v2+h*0.3f, v3+v*0.3f);
|
||||
if(tex>1) glColor4f(1, 1, 1, 0.15f + max(v, 0)*0.15f);
|
||||
}
|
||||
else glColor4ub(hdr.watercolor[0], hdr.watercolor[1], hdr.watercolor[2], (uchar)(hdr.watercolor[3] + (max(v, 0) - 0.5f)*51.0f));
|
||||
}
|
||||
@@ -413,27 +413,32 @@ void renderwaterstrips(float hf, int tex, float t)
|
||||
}
|
||||
}
|
||||
|
||||
int renderwater(float hf, GLuint tex)
|
||||
int renderwater(float hf, GLuint reflecttex, GLuint refracttex)
|
||||
{
|
||||
if(wx1<0) return nquads;
|
||||
|
||||
glDepthMask(GL_FALSE);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
wx1 &= ~(watersubdiv-1);
|
||||
wy1 &= ~(watersubdiv-1);
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
float t = lastmillis/300.0f;
|
||||
|
||||
if(tex)
|
||||
if(!refracttex)
|
||||
{
|
||||
glColor4ubv(hdr.watercolor);
|
||||
renderwaterstrips(hf, 0, t);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glEnable(GL_BLEND);
|
||||
glDepthMask(GL_FALSE);
|
||||
}
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
if(reflecttex)
|
||||
{
|
||||
if(!refracttex)
|
||||
{
|
||||
glColor4ubv(hdr.watercolor);
|
||||
renderwaterstrips(hf, 0, t);
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
GLfloat pm[16], mm[16];
|
||||
glGetFloatv(GL_PROJECTION_MATRIX, pm);
|
||||
@@ -446,13 +451,24 @@ int renderwater(float hf, GLuint tex)
|
||||
glMultMatrixf(pm);
|
||||
glMultMatrixf(mm);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, tex);
|
||||
glBindTexture(GL_TEXTURE_2D, refracttex ? refracttex : reflecttex);
|
||||
}
|
||||
|
||||
renderwaterstrips(hf, tex ? 1 : -1, t);
|
||||
|
||||
if(tex)
|
||||
if(refracttex)
|
||||
{
|
||||
glColor3f(1, 1, 1);
|
||||
renderwaterstrips(hf, 1, t);
|
||||
glEnable(GL_BLEND);
|
||||
glDepthMask(GL_FALSE);
|
||||
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
glBindTexture(GL_TEXTURE_2D, reflecttex);
|
||||
}
|
||||
renderwaterstrips(hf, reflecttex ? 2 : -1, t);
|
||||
|
||||
if(reflecttex)
|
||||
{
|
||||
if(refracttex) glDepthFunc(GL_LESS);
|
||||
glLoadIdentity();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
@@ -461,7 +477,7 @@ int renderwater(float hf, GLuint tex)
|
||||
glDisable(GL_BLEND);
|
||||
glDepthMask(GL_TRUE);
|
||||
|
||||
return nquads;
|
||||
return nquads + (reflecttex ? nquads : 0);
|
||||
}
|
||||
|
||||
void addwaterquad(int x, int y, int size) // update bounding rect that contains water
|
||||
|
||||
+62
-21
@@ -253,50 +253,65 @@ void genclipmatrix(float a, float b, float c, float d, GLfloat matrix[16])
|
||||
matrix[14] = clip[3]*scale;
|
||||
}
|
||||
|
||||
bool reflecting = false;
|
||||
GLuint reflecttex = 0;
|
||||
bool reflecting = false, refracting = false;
|
||||
GLuint reflecttex = 0, refracttex = 0;
|
||||
int reflectlastsize = 0;
|
||||
|
||||
VARP(reflectres, 6, 7, 10);
|
||||
VAR(reflectclip, 0, 3, 100);
|
||||
VARP(waterreflect, 0, 1, 1);
|
||||
VARP(waterrefract, 0, 0, 1);
|
||||
|
||||
void drawreflection(float hf, int w, int h, float changelod)
|
||||
void drawreflection(float hf, int w, int h, float changelod, bool refract)
|
||||
{
|
||||
reflecting = true;
|
||||
refracting = refract;
|
||||
|
||||
int size = 1<<reflectres;
|
||||
while(size > w || size > h) size /= 2;
|
||||
if(size!=reflectlastsize)
|
||||
{
|
||||
glDeleteTextures(1, &reflecttex);
|
||||
reflecttex = 0;
|
||||
if(reflecttex) glDeleteTextures(1, &reflecttex);
|
||||
if(refracttex) glDeleteTextures(1, &refracttex);
|
||||
reflecttex = refracttex = 0;
|
||||
}
|
||||
if(!reflecttex)
|
||||
if(!reflecttex || (waterrefract && !refracttex))
|
||||
{
|
||||
glGenTextures(1, &reflecttex);
|
||||
createtexture(reflecttex, size, size, NULL, 3, false, GL_RGB);
|
||||
if(!reflecttex)
|
||||
{
|
||||
glGenTextures(1, &reflecttex);
|
||||
createtexture(reflecttex, size, size, NULL, 3, false, GL_RGB);
|
||||
}
|
||||
if(!refracttex)
|
||||
{
|
||||
glGenTextures(1, &refracttex);
|
||||
createtexture(refracttex, size, size, NULL, 3, false, GL_RGB);
|
||||
}
|
||||
reflectlastsize = size;
|
||||
}
|
||||
|
||||
resetcubes();
|
||||
|
||||
render_world(camera1->o.x, camera1->o.y, hf, changelod,
|
||||
(int)camera1->yaw, -(int)camera1->pitch, (float)fov, size, size);
|
||||
render_world(camera1->o.x, camera1->o.y, refract ? camera1->o.z : hf, changelod,
|
||||
(int)camera1->yaw, (refract ? 1 : -1)*(int)camera1->pitch, (float)fov, size, size);
|
||||
|
||||
setupstrips();
|
||||
|
||||
glCullFace(GL_BACK);
|
||||
if(!refract) glCullFace(GL_BACK);
|
||||
glViewport(0, 0, size, size);
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
transplayer();
|
||||
glTranslatef(0, 2*hf, 0);
|
||||
glScalef(1, -1, 1);
|
||||
if(!refract)
|
||||
{
|
||||
glTranslatef(0, 2*hf, 0);
|
||||
glScalef(1, -1, 1);
|
||||
}
|
||||
|
||||
GLfloat clipmat[16];
|
||||
genclipmatrix(0, 1, 0, 0.1f-hf, clipmat);
|
||||
genclipmatrix(0, refract ? -1 : 1, 0, refract ? 0.1f*reflectclip+hf : 0.1f*reflectclip-hf, clipmat);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
glLoadMatrixf(clipmat);
|
||||
@@ -309,7 +324,7 @@ void drawreflection(float hf, int w, int h, float changelod)
|
||||
glRotatef(camera1->pitch, -1, 0, 0);
|
||||
glRotatef(camera1->yaw, 0, 1, 0);
|
||||
glRotatef(90, 1, 0, 0);
|
||||
glScalef(1, 1, -1);
|
||||
if(!refract) glScalef(1, 1, -1);
|
||||
glColor3f(1, 1, 1);
|
||||
glDisable(GL_FOG);
|
||||
glDepthFunc(GL_GREATER);
|
||||
@@ -326,19 +341,41 @@ void drawreflection(float hf, int w, int h, float changelod)
|
||||
|
||||
overbright(1);
|
||||
|
||||
render_particles(0);
|
||||
|
||||
if(refract) glLoadIdentity();
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
if(refract)
|
||||
{
|
||||
glLoadIdentity();
|
||||
glOrtho(0, 1, 0, 1, -1, 1);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glColor4ubv(hdr.watercolor);
|
||||
glBegin(GL_QUADS);
|
||||
glVertex2i(0, 1);
|
||||
glVertex2i(1, 1);
|
||||
glVertex2i(1, 0);
|
||||
glVertex2i(0, 0);
|
||||
glEnd();
|
||||
glDisable(GL_BLEND);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
glPopMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
glCullFace(GL_FRONT);
|
||||
if(!refract) glCullFace(GL_FRONT);
|
||||
glViewport(0, 0, w, h);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, reflecttex);
|
||||
glBindTexture(GL_TEXTURE_2D, refract ? refracttex : reflecttex);
|
||||
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, size, size);
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
reflecting = false;
|
||||
reflecting = refracting = false;
|
||||
}
|
||||
|
||||
bool minimap = false, minimapdirty = true;
|
||||
@@ -413,7 +450,7 @@ void drawminimap(int w, int h)
|
||||
overbright(1);
|
||||
|
||||
float hf = hdr.waterlevel-0.3f;
|
||||
renderwater(hf, 0);
|
||||
renderwater(hf, 0, 0);
|
||||
|
||||
minimap = false;
|
||||
|
||||
@@ -530,7 +567,11 @@ void gl_drawframe(int w, int h, float changelod, float curfps)
|
||||
else if(waterreflect)
|
||||
{
|
||||
extern int wx1;
|
||||
if(wx1>=0) drawreflection(hf, w, h, changelod);
|
||||
if(wx1>=0)
|
||||
{
|
||||
drawreflection(hf, w, h, changelod, false);
|
||||
if(waterrefract) drawreflection(hf, w, h, changelod, true);
|
||||
}
|
||||
}
|
||||
|
||||
glClear((outsidemap(camera1) ? GL_COLOR_BUFFER_BIT : 0) | GL_DEPTH_BUFFER_BIT);
|
||||
@@ -591,7 +632,7 @@ void gl_drawframe(int w, int h, float changelod, float curfps)
|
||||
render_particles(curtime);
|
||||
|
||||
glDisable(GL_CULL_FACE);
|
||||
int nquads = renderwater(hf, !waterreflect || underwater ? 0 : reflecttex);
|
||||
int nquads = renderwater(hf, !waterreflect || underwater ? 0 : reflecttex, !waterreflect || !waterrefract || underwater ? 0 : refracttex);
|
||||
|
||||
glDisable(GL_FOG);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
@@ -259,6 +259,6 @@ void renderclients()
|
||||
{
|
||||
playerent *d;
|
||||
loopv(players) if((d = players[i]) && (!demoplayback || i!=democlientnum)) renderclient(d);
|
||||
if(player1->state==CS_DEAD || reflecting) renderclient(player1);
|
||||
if(player1->state==CS_DEAD || (reflecting && !refracting)) renderclient(player1);
|
||||
}
|
||||
|
||||
|
||||
@@ -183,8 +183,9 @@ void render_particles(int time)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(lastmillis-p->millis>p->fade)
|
||||
|
||||
if(!time) pp = &p->next;
|
||||
else if(lastmillis-p->millis>p->fade)
|
||||
{
|
||||
*pp = p->next;
|
||||
p->next = parempty;
|
||||
|
||||
Reference in New Issue
Block a user