Quick FBO and GLUT Question

Recommended Posts

im using GLUT 3.7.6 and for some reason it crashes when i call glGenFramebuffersEXT. when i put the same line in a program which uses windows to create the window and rendering contexts it works fine. does my version of glut not support FBOs? does GLUT flat out, not support FBOs?

Share on other sites
GLUT has nothing to do with OpenGL extensions (like FBO). Most probably you have not initializes glGenFramebuffersEXT function and it is NULL or points to some random memory. You must yourself initialize extension function pointers with correct values (on Windows by calling wglGetProcAddress). Alternatively you can use libraries like GLee or GLEW which sets up extension function pointers for you.

Share on other sites
im using glew for the extensions. i have successfully been able to use GLSL shaders. i searched through the glew file and found the framebuffer extensions. glew is initializing them. ive also tried getting the latest drivers from ati, and im using an x850.

Share on other sites
wow i had a seriously blonde moment. when i was using shaders, i was calling glewInit in the init function of my shader object.

i have a new question. i have the fbo working okay, except for the aspect ratio of the texture. i have a cube that rotates and is rendered into the fbo and then i bind that texture to a simple quad. the texture comes out scaled down on the x axis. my resolution is 1680x1050, but the texture i render to is supposed to be 512x512. heres how i have setup the code:

glLoadIdentity();	glClearColor(0, 0, 0, 1);	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);	glColor3f(1,1,1);		//setup FBO	glViewport(0, 0, 512, 512);	glBindTexture(GL_TEXTURE_2D, 0);	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);	glClearColor(0.5, 0.5, 0.5, 1);	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);	glLoadIdentity();	//draw scene into FBO	static GLfloat rot = 0;	rot += 0.05;	glPushMatrix();		glTranslatef(0, 0, -5);		glColor4f(1,1,1,1);		glRotatef(rot, 1, 0.5, 0);		glutSolidCube(3);	glPopMatrix();	//framebuffer render pass	glEnable(GL_TEXTURE_2D);	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);	glBindTexture(GL_TEXTURE_2D, depth_tex);	glClearColor(0, 0, 0, 1);	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);	glViewport(0, 0, 1680, 1050);	glLoadIdentity();	glPushMatrix();		glTranslatef(0, 0, -5);		glColor4f(1,1,1,1);		glBegin(GL_QUADS);			glTexCoord2f(0, 0); glVertex3f(-3,-3, 0);			glTexCoord2f(0, 1); glVertex3f(-3, 3, 0);			glTexCoord2f(1, 1); glVertex3f( 3, 3, 0);			glTexCoord2f(1, 0); glVertex3f( 3,-3, 0);		glEnd();	glPopMatrix();	glTranslatef(-cameraPosition.x, -cameraPosition.y, -cameraPosition.z);

Create an account

Register a new account

• Forum Statistics

• Total Topics
627719
• Total Posts
2978789

• 9
• 21
• 14
• 12
• 42