virtual void Update() { PROFILE("CAppTask::Update()", 1); glClearColor(0.253f, 0.47f, 0.683f, 1); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPolygonMode(GL_FRONT, m_nPolygonMode); if(m_nPolygonMode == GL_FILL) { glDisable(GL_DEPTH_TEST); m_tex.Enable(); m_shader.Enable(); m_shader.SetUniformParameter1i("s3Tex0", 0); } CSRTTransform camera = CCameraTask::GetPtr()->GetCamera(); float fDistance[2]; fDistance[0] = camera.GetPosition().Distance(m_cSphere.GetPosition()); fDistance[1] = camera.GetPosition().Distance(m_cSphere2.GetPosition()); if(fDistance[0] > fDistance[1]) { m_cSphere.Draw(camera, m_tex); m_cSphere2.Draw(camera, m_tex); } else { m_cSphere2.Draw(camera, m_tex); m_cSphere.Draw(camera, m_tex); } glEnable(GL_DEPTH_TEST); m_shader.Disable(); m_tex.Disable(); glPolygonMode(GL_FRONT, GL_FILL); }
virtual void Update() { PROFILE("CAppTask::Update()", 1); glClearColor(0.253f, 0.47f, 0.683f, 1); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPolygonMode(GL_FRONT, m_nPolygonMode); if(m_nPolygonMode == GL_FILL) { glEnable(GL_BLEND); glDepthFunc(GL_ALWAYS); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4f(1, 1, 1, 1); m_tex.Enable(); } CSRTTransform camera = CCameraTask::GetPtr()->GetCamera(); int i, j; #define LEVEL 10 const int nCubes = LEVEL*LEVEL*LEVEL; CProjectedCube cube[nCubes]; float fDistance[nCubes]; for(i=0; i<nCubes; i++) { cube[i].SetPosition(CVector(i/(LEVEL*LEVEL)*2, ((i/LEVEL)%LEVEL)*2, (i%LEVEL)*2)); fDistance[i] = cube[i].GetPosition().Distance(camera.GetPosition()); } int nOrder[nCubes]; for(i=0; i<nCubes; i++) nOrder[i] = i; for(i=0; i<nCubes; i++) { for(j=0; j<nCubes-i-1; j++) { if(fDistance[nOrder[j]] > fDistance[nOrder[j+1]]) { int nTemp = nOrder[j]; nOrder[j] = nOrder[j+1]; nOrder[j+1] = nTemp; } } } for(i=0; i<nCubes; i++) cube[nOrder[nCubes-1-i]].DrawVolume(camera); m_tex.Disable(); glDisable(GL_BLEND); glPolygonMode(GL_FRONT, GL_FILL); }