예제 #1
0
void CBaseWater::DeleteOldWater(CBaseWater *water) {
	if(water->oldwater) {
		DeleteOldWater(water->oldwater);
		delete water->oldwater;
		water->oldwater=NULL;
	}
}
예제 #2
0
void CDynWater::UpdateWater(CGame* game)
{
	DeleteOldWater(this);

	if ((!mapInfo->water.forceRendering && readmap->currMinHeight > 1.0f) || mapInfo->map.voidWater)
		return;

	glDisable(GL_DEPTH_TEST);
	glDepthMask(0);
	glDisable(GL_BLEND);
	glDisable(GL_ALPHA_TEST);

	DrawHeightTex();

	if(firstDraw){
		firstDraw=false;
		DrawDetailNormalTex();
	}
	glEnable(GL_DEPTH_TEST);
	glDepthMask(1);

	glPushAttrib(GL_FOG_BIT);
	DrawRefraction(game);
	DrawReflection(game);
	FBO::Unbind();
	glPopAttrib();
}
예제 #3
0
파일: AdvWater.cpp 프로젝트: achoum/spring
void CAdvWater::UpdateWater(CGame* game)
{
    DeleteOldWater(this);

    if ((!mapInfo->water.forceRendering && readmap->currMinHeight > 1.0f) || mapInfo->map.voidWater)
        return;

    glViewport(0,0,128,128);

    glClearColor(0.0f,0.0f,0.0f,1);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glColorMask(1,1,1,0);

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0,1,0,1,-1,1);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, rawBumpTexture[0]);
    glEnable(GL_BLEND);
    glBlendFunc(GL_ONE,GL_ONE);

    glColor3f(1,1,1);
    glBegin(GL_QUADS);
    /*	glColor3f(0.49f,0.49f,0.49f);
    	glTexCoord2f(0,0+gs->frameNum*0.01f);glVertex3f(0,0,0);
    	glTexCoord2f(0,2+gs->frameNum*0.01f);glVertex3f(0,1,0);
    	glTexCoord2f(1,2+gs->frameNum*0.01f);glVertex3f(1,1,0);
    	glTexCoord2f(1,0+gs->frameNum*0.01f);glVertex3f(1,0,0);
    /*
    	glColor3f(0.32f,0.32f,0.32f);
    	glTexCoord2f(0,0-gs->frameNum*0.037f);glVertex3f(0,0,0);
    	glTexCoord2f(0,2-gs->frameNum*0.037f);glVertex3f(0,1,0);
    	glTexCoord2f(1,2-gs->frameNum*0.037f);glVertex3f(1,1,0);
    	glTexCoord2f(1,0-gs->frameNum*0.037f);glVertex3f(1,0,0);
    	glEnd();

    	glBindTexture(GL_TEXTURE_2D, rawBumpTexture[0]);

    	glColor3f(1,1,1);
    	glBegin(GL_QUADS);
    	glColor3f(0.45f,0.45f,0.45f);
    	glTexCoord2f(0+gs->frameNum*0.02f,0);glVertex3f(0,0,0);
    	glTexCoord2f(1+gs->frameNum*0.02f,0);glVertex3f(0,1,0);
    	glTexCoord2f(1+gs->frameNum*0.02f,1);glVertex3f(1,1,0);
    	glTexCoord2f(0+gs->frameNum*0.02f,1);glVertex3f(1,0,0);

    	glColor3f(0.29f,0.29f,0.29f);
    	glTexCoord2f(0-gs->frameNum*0.021f,0);glVertex3f(0,0,0);
    	glTexCoord2f(1-gs->frameNum*0.021f,0);glVertex3f(0,1,0);
    	glTexCoord2f(1-gs->frameNum*0.021f,1);glVertex3f(1,1,0);
    	glTexCoord2f(0-gs->frameNum*0.021f,1);glVertex3f(1,0,0);
    	glEnd();
    /*/
    glColor3f(0.2f,0.2f,0.2f);
    glTexCoord2f(0,0+gs->frameNum*0.0046f);
    glVertex3f(0,0,0);
    glTexCoord2f(0,2+gs->frameNum*0.0046f);
    glVertex3f(0,1,0);
    glTexCoord2f(2,2+gs->frameNum*0.0046f);
    glVertex3f(1,1,0);
    glTexCoord2f(2,0+gs->frameNum*0.0046f);
    glVertex3f(1,0,0);

    glColor3f(0.2f,0.2f,0.2f);
    glTexCoord2f(0,0+gs->frameNum*0.0026f);
    glVertex3f(0,0,0);
    glTexCoord2f(0,4+gs->frameNum*0.0026f);
    glVertex3f(0,1,0);
    glTexCoord2f(2,4+gs->frameNum*0.0026f);
    glVertex3f(1,1,0);
    glTexCoord2f(2,0+gs->frameNum*0.0026f);
    glVertex3f(1,0,0);

    glTexCoord2f(0,0+gs->frameNum*0.0012f);
    glVertex3f(0,0,0);
    glTexCoord2f(0,8+gs->frameNum*0.0012f);
    glVertex3f(0,1,0);
    glTexCoord2f(2,8+gs->frameNum*0.0012f);
    glVertex3f(1,1,0);
    glTexCoord2f(2,0+gs->frameNum*0.0012f);
    glVertex3f(1,0,0);
    glEnd();

    glBindTexture(GL_TEXTURE_2D, rawBumpTexture[1]);
    glBegin(GL_QUADS);
    glColor3f(0.2f,0.2f,0.2f);
    glTexCoord2f(0,0+gs->frameNum*0.0036f);
    glVertex3f(0,0,0);
    glTexCoord2f(0,1+gs->frameNum*0.0036f);
    glVertex3f(0,1,0);
    glTexCoord2f(1,1+gs->frameNum*0.0036f);
    glVertex3f(1,1,0);
    glTexCoord2f(1,0+gs->frameNum*0.0036f);
    glVertex3f(1,0,0);
    glEnd();

    glBindTexture(GL_TEXTURE_2D, rawBumpTexture[2]);
    glBegin(GL_QUADS);
    glColor3f(0.2f,0.2f,0.2f);
    glTexCoord2f(0,0+gs->frameNum*0.0082f);
    glVertex3f(0,0,0);
    glTexCoord2f(0,1+gs->frameNum*0.0082f);
    glVertex3f(0,1,0);
    glTexCoord2f(1,1+gs->frameNum*0.0082f);
    glVertex3f(1,1,0);
    glTexCoord2f(1,0+gs->frameNum*0.0082f);
    glVertex3f(1,0,0);
    glEnd();
    /**/
    glBindTexture(GL_TEXTURE_2D, bumpTexture);
    glCopyTexSubImage2D(GL_TEXTURE_2D,0,0,0,0,0,128,128);

//	CCamera *realCam = camera;
//	camera = new CCamera(*realCam);
    char realCam[sizeof(CCamera)];
    new (realCam) CCamera(*camera); // anti-crash workaround for multithreading

    camera->up.x=0;
    camera->up.y=1;
    camera->up.z=0;
    camera->forward.y*=-1;
    camera->pos.y*=-1;
    camera->Update(false);

    glViewport(0,0,512,512);

    glClearColor(0.2f,0.4f,0.2f,1);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    game->SetDrawMode(CGame::reflectionDraw);

    sky->Draw();

    glEnable(GL_CLIP_PLANE2);
    double plane[4]= {0,1,0,0};
    glClipPlane(GL_CLIP_PLANE2 ,plane);
    drawReflection=true;

    readmap->GetGroundDrawer()->Draw(true);
    unitDrawer->Draw(true);
    featureHandler->Draw();
    ph->Draw(true);
    eventHandler.DrawWorldReflection();

    game->SetDrawMode(CGame::normalDraw);

    drawReflection=false;
    glDisable(GL_CLIP_PLANE2);

    glColorMask(1,1,1,1);
    glBindTexture(GL_TEXTURE_2D, reflectTexture);
    glCopyTexSubImage2D(GL_TEXTURE_2D,0,0,0,0,0,512,512);

    glViewport(gu->viewPosX,0,gu->viewSizeX,gu->viewSizeY);
    glClearColor(mapInfo->atmosphere.fogColor[0],mapInfo->atmosphere.fogColor[1],mapInfo->atmosphere.fogColor[2],1);

//	delete camera;
//	camera = realCam;
    camera->~CCamera();
    new (camera) CCamera(*(CCamera *)realCam);

    camera->Update(false);
}
예제 #4
0
void CBasicWater::UpdateWater(CGame* game) {
	DeleteOldWater(this);
}
예제 #5
0
CBaseWater::~CBaseWater(void)
{
	DeleteOldWater(this);
}