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); }
virtual void Update() { PROFILE("CAppTask::Update()", 1); if(m_bHDR && m_fb.IsValid()) { m_fb.EnableFrameBuffer(); if(m_bHDRSquare) glViewport(0, 0, 1024, 1024); } glClearColor(0.25f, 0.25f, 0.25f, 0.25f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPolygonMode(GL_FRONT, m_nPolygonMode); CMatrix4 mModel = m_srtModel.BuildModelMatrix(); glPushMatrix(); glMultMatrixf(mModel); glBegin(GL_TRIANGLES); glColor3f(1.0f,0.0f,0.0f); glVertex3f(0.0f, 1.0f, 0.0f); glColor3f(0.0f,1.0f,0.0f); glVertex3f(-1.0f,-1.0f, 0.0f); glColor3f(0.0f,0.0f,1.0f); glVertex3f(1.0f,-1.0f, 0.0f); glEnd(); glPopMatrix(); glPolygonMode(GL_FRONT, GL_FILL); if(m_bHDR && m_fb.IsValid()) { m_fb.DisableFrameBuffer(); if(m_bHDRSquare) glViewport(0, 0, CVideoTask::GetPtr()->GetWidth(), CVideoTask::GetPtr()->GetHeight()); CVideoTask::GetPtr()->GetFont().Begin(); m_fb.EnableTexture(); m_shHDR.Enable(); m_shHDR.SetUniformParameter1f("fExposure", m_fExposure); m_shHDR.SetUniformParameter1i("s2Test", 0); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glBegin(GL_QUADS); { if(m_bHDRSquare) { glTexCoord2f(0, 0); glVertex2i(10, CVideoTask::GetPtr()->GetHeight()-10); glTexCoord2f(1, 0); glVertex2i(CVideoTask::GetPtr()->GetWidth()-10, CVideoTask::GetPtr()->GetHeight()-10); glTexCoord2f(1, 1); glVertex2i(CVideoTask::GetPtr()->GetWidth()-10, 10); glTexCoord2f(0, 1); glVertex2i(10, 10); } else { glTexCoord2f(0, 0); glVertex2i(10, CVideoTask::GetPtr()->GetHeight()-10); glTexCoord2f(CVideoTask::GetPtr()->GetWidth(), 0); glVertex2i(CVideoTask::GetPtr()->GetWidth()-10, CVideoTask::GetPtr()->GetHeight()-10); glTexCoord2f(CVideoTask::GetPtr()->GetWidth(), CVideoTask::GetPtr()->GetHeight()); glVertex2i(CVideoTask::GetPtr()->GetWidth()-10, 10); glTexCoord2f(0, CVideoTask::GetPtr()->GetHeight()); glVertex2i(10, 10); } } glEnd(); m_shHDR.Disable(); m_fb.DisableTexture(); char szBuffer[256]; CVideoTask::GetPtr()->GetFont().SetPosition(0, 15); sprintf(szBuffer, "Exposure (+/-): %-2.2f", m_fExposure); CVideoTask::GetPtr()->GetFont().Print(szBuffer); CVideoTask::GetPtr()->GetFont().End(); } }