PDA

View Full Version : Framebuffer object not rendering?



Adrian Hooper
03-25-2009, 07:50 AM
I've setup a framebuffer object to render something and put it somewhere in my 3D world, and it is setting up without an issue, and would seem that the texture is generating properly in that when I clear the buffer for it the colour I've specified for clearing actually works, in that what I've textured with the fbo changes colour, yet whatever I then try to render doesn't appear on the texture? Please help


gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, fbo[0]);
gl.glPushAttrib(GL.GL_VIEWPORT_BIT);
gl.glViewport(0, 0, 14, 14);

gl.glClearColor(1.0f, 0.0f, 1.0f, 1.0f);
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
gl.glLoadIdentity();

gl.glBegin(GL.GL_QUADS);
// Front Face
gl.glColor4f(0.0f,1.0f,0.0f,1.0f);
gl.glVertex3f(-0.5f, -0.5f, 0.5f);
gl.glVertex3f( 0.5f, -0.5f, 0.5f);
gl.glVertex3f( 0.5f, 0.5f, 0.5f);
gl.glVertex3f(-0.5f, 0.5f, 0.5f);
// Back Face
gl.glColor4f(1.0f,0.0f,0.0f,1.0f);
gl.glVertex3f(-0.5f, -0.5f, -0.5f);
gl.glVertex3f(-0.5f, 0.5f, -0.5f);
gl.glVertex3f( 0.5f, 0.5f, -0.5f);
gl.glVertex3f( 0.5f, -0.5f, -0.5f);
// Top Face
gl.glColor4f(0.0f,0.0f,1.0f,1.0f);
gl.glVertex3f(-0.5f, 0.5f, -0.5f);
gl.glVertex3f(-0.5f, 0.5f, 0.5f);
gl.glVertex3f( 0.5f, 0.5f, 0.5f);
gl.glVertex3f( 0.5f, 0.5f, -0.5f);
// Bottom Face
gl.glColor4f(0.0f,1.0f,1.0f,1.0f);
gl.glVertex3f(-0.5f, -0.5f, -0.5f);
gl.glVertex3f( 0.5f, -0.5f, -0.5f);
gl.glVertex3f( 0.5f, -0.5f, 0.5f);
gl.glVertex3f(-0.5f, -0.5f, 0.5f);
// Right face
gl.glColor4f(1.0f,1.0f,0.0f,1.0f);
gl.glVertex3f( 0.5f, -0.5f, -0.5f);
gl.glVertex3f( 0.5f, 0.5f, -0.5f);
gl.glVertex3f( 0.5f, 0.5f, 0.5f);
gl.glVertex3f( 0.5f, -0.5f, 0.5f);
// Left Face
gl.glColor4f(1.0f,1.0f,1.0f,1.0f);
gl.glVertex3f(-0.5f, -0.5f, -0.5f);
gl.glVertex3f(-0.5f, -0.5f, 0.5f);
gl.glVertex3f(-0.5f, 0.5f, 0.5f);
gl.glVertex3f(-0.5f, 0.5f, -0.5f);
gl.glEnd();

gl.glPopAttrib();
gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, 0);

Adrian Hooper
03-25-2009, 08:20 AM
no worries. Got it working :)