In my OpenGL program I want to render everything in memory. I don’t want to render data to a window/screen. So I created a Frame Buffer. Next thing I want to do is to render a 3d model to that Frame Buffer.
I’ve downloaded the Assimp library to handle the loading of the models. I’m just not sure how to work with this. It looks like it is expecting you to draw everything directly to a window?
All I want to do right now is to load and draw that model to my Frame Buffer. That’s basically all.
Any tips/advice on how to do this easily? Tips for another library (which may suit my needs better) are welcome too.
My code, where I want to draw to my frame buffer:
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo); // Bind our frame buffer for rendering
glPushAttrib(GL_VIEWPORT_BIT | GL_ENABLE_BIT); // Push our glEnable and glViewport states
glViewport(0, 0, window_width, window_height); // Set the size of the frame buffer view port
glClearColor (0.0f, 1.0f, 0.0f, 1.0f); // Set the clear colour
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear the depth and colour buffers
glLoadIdentity(); // Reset the modelview matrix
// RENDER 3D MODEL HERE....
// TEAPOT AS EXAMPLE
glTranslatef(0.0f, 0.0f, -5.0f); // Translate back 5 units
glRotatef(rotation_degree, 1.0f, 1.0f, 0.0f); // Rotate according to our rotation_degree value
//glFrontFace(GL_CW);
glutSolidTeapot(1.0f); // Render a teapot
//glFrontFace(GL_CCW);
int r = glGetError();
int s = glCheckFramebufferStatus(GL_FRAMEBUFFER);
glPopAttrib(); // Restore our glEnable and glViewport states
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); // Unbind our texture
The assimp library is just a loader; it doesn’t care whether you draw to an off-screen framebuffer or a window’s backbuffer.
Try checking the return codes from glGetError and glCheckFramebufferStatus.