我无法找到一种方法来渲染一个带有简单God Ray着色器和另一个VBO对象drawS()的立方体。这段代码给了我两个对象具有相同的God Ray效果。我的目标是给drawS()一个自己的效果。有什么想法吗?
void COpenGLRenderer :: Render(float FrameTime) { // bind FBO ---------------------------------------------- -------------------------------------------------- ---------------
if(Blur)
{
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FBO);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, ColorBuffer, 0);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
GL_DEPTH_ATTACHMENT_EXT,
GL_RENDERBUFFER_EXT, depth_rb);
//
// render scene -----------------------------------------------------------------------------------------------------------
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf(&ViewMatrix);
glEnable(GL_DEPTH_TEST);
/*glPushMatrix();
glTranslatef(5.0, 3.0, 5.0);
glColor3f(1.0f, 1.0f, 1.0f);
glutSolidSphere(0.5, 20.0, 12.0);
glPopMatrix();*/
glColor3f(1.0f, 0.0f, 0.0f);
glutSolidCube(5.0);
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf(&ViewMatrix);
glTranslatef(-30.0f, 0.0f, 0.0f);
glEnable(GL_DEPTH_TEST);
drawS();
glDisable(GL_DEPTH_TEST);
//glDrawBuffer(GL_FRONT);
glBindTexture(GL_TEXTURE_2D, 0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
// blur ColorBuffer texture -----------------------------------------------------------------------------------------------
glBindTexture(GL_TEXTURE_2D, ColorBuffer);
//glDisable(GL_DEPTH_TEST);
//if(Blur)
//{
glUseProgram(GodRays);
glBegin(GL_QUADS);
glVertex2f(0.0f, 0.0f);
glVertex2f(1.0f, 0.0f);
glVertex2f(1.0f, 1.0f);
glVertex2f(0.0f, 1.0f);
glEnd();
//glClear(GL_DEPTH_BUFFER_BIT);
//glClear(GL_DEPTH_BUFFER_BIT);
glUseProgram(0);
}
}