Sign in to follow this  
pmangalvedkar

Problem with FBO and Fragment Shader

Recommended Posts

Hi, I am trying to use a triangle strip texture to draw a cylinder. I use a fragment shader to calculate the points for the triangles. The results are stored in FBOs. Then I copy it to a PBO and render it as usual. But I am not able to get the result I expect. If I dont use the shader and just use the CPU to do the calculations, I can see the cylinders.I dont know where I am going wrong. Can anybody help me? The code is as follows: //******** render to FBO **************** //******** bind the buffer ************** glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, fb_handle); GLenum dbuffers[] = {GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT}; glDrawBuffers(2, dbuffers); //******** render the buffer using quad*************** glDisable (GL_DEPTH_TEST); glDepthMask (GL_FALSE); glDisable (GL_CULL_FACE); glEnable (GL_TEXTURE_2D); glActiveTextureARB (GL_TEXTURE0_ARB); glBindTexture (GL_TEXTURE_2D, tex_handle); glActiveTextureARB (GL_TEXTURE1_ARB); glBindTexture (GL_TEXTURE_2D, treedata_handle); cgGLEnableProfile (CG_PROFILE_ARBFP1); cgGLBindProgram (fragmentprogram); cgGLEnableTextureParameter (treedata); // This contains my dataset cgGLEnableTextureParameter (texture_data); // This contains the texture cgSetParameter1f (GPUindex, (float)(2*i+1)/(float)(2*arraysize)); glMatrixMode (GL_PROJECTION); glPushMatrix (); glLoadIdentity (); gluOrtho2D (0.0, 2.0, 0.0, 56.0); glMatrixMode (GL_MODELVIEW); glPushMatrix (); glLoadIdentity (); int viewport[4]; glGetIntegerv (GL_VIEWPORT, viewport); glViewport (0, 0, 2, 56); glClampColorARB (GL_CLAMP_VERTEX_COLOR_ARB, GL_FALSE); glBegin (GL_QUADS); glColor3f (0.0, 1.0, 0.0); glTexCoord2f (0.0, 0.0); glVertex2f (0.0, 0.0); glTexCoord2f (1.0, 0.0); glVertex2f (2.0, 0.0); glTexCoord2f (1.0, 1.0); glVertex2f (2.0, 56.0); glTexCoord2f (0.0, 1.0); glVertex2f (0.0, 56.0); glEnd (); glDisable (GL_TEXTURE_2D); cgGLDisableTextureParameter (treedata); cgGLDisableTextureParameter (texture_data); cgGLDisableProfile (CG_PROFILE_ARBFP1); //*********copy from FBO to PBO*********************** glReadBuffer (GL_COLOR_ATTACHMENT0_EXT); glBindBufferARB (GL_PIXEL_PACK_BUFFER_EXT, vbo_vertices_handle); glReadPixels (0, 0, 2, 56, GL_RGBA, GL_FLOAT, 0); glReadBuffer (GL_COLOR_ATTACHMENT1_EXT); glBindBufferARB (GL_PIXEL_PACK_BUFFER_EXT, vbo_normals_handle); glReadPixels (0, 0, 2, 56, GL_RGBA, GL_FLOAT, 0); glReadBuffer (GL_NONE); glBindBufferARB (GL_PIXEL_PACK_BUFFER_EXT, 0); glViewport (viewport[0],viewport[1],viewport[2],viewport[3]); glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0); glDrawBuffer (GL_BACK); glEnable (GL_DEPTH_TEST); glDepthMask (GL_TRUE); glEnable (GL_CULL_FACE); glPopMatrix (); glMatrixMode (GL_PROJECTION); glPopMatrix (); glMatrixMode (GL_MODELVIEW); //******** render the VBO as usual ************ /* ------------- -------------- -------------- */ [Edited by - pmangalvedkar on May 10, 2007 1:57:11 PM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this