Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: Counter problems when reading texture from FBO

  1. #1
    Senior Member Regular Contributor
    Join Date
    Aug 2010
    Posts
    114

    Counter problems when reading texture from FBO

    Hi,

    Code :
      /*Read values back*/
    	/*Method 1*/
    	glBindTexture(GL_TEXTURE_RECTANGLE_ARB,textureID);
    	  glGetTexImage(GL_TEXTURE_RECTANGLE_ARB,0,GL_LUMINANCE,GL_UNSIGNED_BYTE,data);
     
    	printf("Texture:\n");
        	for (i=0; i<2048*2048; i++)
            	printf("%c",data[i]);
     
    	printf("\n\n");
     
    	/*Method 2*/
        	glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
        	glReadPixels(0, 0, 2048, 2048, GL_LUMINANCE, GL_UNSIGNED_BYTE, result);
        	printf("Data after roundtrip:\n");
        	for (i=0; i<2048*2048; i++)
            	printf("%c",result[i]);

    I use 2 methods to read my texture. The first method works perfectly and it gives me the exact texture. But I not sure why method 2 give me nothing?My program just end after printing the message "Data after roundtrip". Why?

    Here is the code of FBO:
    Code :
    glGenFramebuffersEXT(1, &amp;fboID); 
    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,fboID);
    glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_RECTANGLE_ARB, textureID, 0);

    Is it the texture fails to attach to FBO?

    I check the status of FBO using the following code:
    Code :
    glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
    if(GL_FRAMEBUFFER_COMPLETE_EXT)
    	{
    		printf("FBO complete!!");
    	}

    And it shows the message "FBO complete!!". So, it means my FBO should be correct. But why I cant read it?

  2. #2
    Senior Member Frequent Contributor
    Join Date
    Mar 2009
    Location
    Karachi, Pakistan
    Posts
    810

    Re: Counter problems when reading texture from FBO

    R u sure that the fbo is bound before the glReadBuffer call?
    Regards,
    Mobeen

  3. #3
    Senior Member Regular Contributor
    Join Date
    Aug 2010
    Posts
    114

    Re: Counter problems when reading texture from FBO

    I check the status already and it shows FBO complete.It means no problems for the FBO right?

  4. #4
    Senior Member OpenGL Lord
    Join Date
    Mar 2015
    Posts
    6,677

    Re: Counter problems when reading texture from FBO

    You still have to bind it to the context.

  5. #5
    Senior Member Regular Contributor
    Join Date
    Aug 2010
    Posts
    114

    Re: Counter problems when reading texture from FBO

    Quote Originally Posted by Alfonse Reinheart
    You still have to bind it to the context.
    Do you means bind the FBO to context?Like this:

    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,fboID);


    I try ade but it still not works. It does not print out anything.

  6. #6
    Senior Member Regular Contributor
    Join Date
    Oct 2009
    Posts
    463

    Re: Counter problems when reading texture from FBO

    Quote Originally Posted by SagoO
    I check the status of FBO using the following code:
    Code :
    glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
    if(GL_FRAMEBUFFER_COMPLETE_EXT)
    	{
    		printf("FBO complete!!");
    	}

    And it shows the message "FBO complete!!". So, it means my FBO should be correct. But why I cant read it?
    This isn't correct, it should be something like:
    Code :
    GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
    if(status == GL_FRAMEBUFFER_COMPLETE_EXT)
    	{
    		printf("FBO complete!!");
    	}

    ps. http://www.songho.ca/opengl/gl_fbo.html has a nice tutorial for FBOs

  7. #7
    Senior Member Regular Contributor
    Join Date
    Aug 2010
    Posts
    114

    Re: Counter problems when reading texture from FBO

    Quote Originally Posted by Dan Bartlett
    GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
    if(status == GL_FRAMEBUFFER_COMPLETE_EXT)
    {
    printf("FBO complete!!");
    }
    I think it should be the same. But I try this code also, it shows FBO complete. What is the problem actually?

  8. #8
    Newbie OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,789

    Re: Counter problems when reading texture from FBO

    Checking "if(GL_FRAMEBUFFER_COMPLETE_EXT)" will always result in the condition being evaluated to true because what is actually being evaluated is "if (0x8CD5 != 0)".

  9. #9
    Senior Member Regular Contributor
    Join Date
    Aug 2010
    Posts
    114

    Re: Counter problems when reading texture from FBO

    Quote Originally Posted by mhagain
    Checking "if(GL_FRAMEBUFFER_COMPLETE_EXT)" will always result in the condition being evaluated to true because what is actually being evaluated is "if (0x8CD5 != 0)".
    Okay..But I had tried to following code and it return the same output.

    Code :
    GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
    if(status == GL_FRAMEBUFFER_COMPLETE_EXT)
    {
    printf("FBO complete!!");

    After I put this code, it gives me FBO complete message also.
    }

  10. #10
    Senior Member Regular Contributor
    Join Date
    Oct 2009
    Posts
    463

    Re: Counter problems when reading texture from FBO

    If your application is terminating unexpectedly, then maybe "result" isn't large enough to store all the data? This would mean that when OpenGL tries to write to "result", it would end up overwriting other application data.

    Have you also tried calling glGetError to see if any OpenGL errors have occurred?

Page 1 of 2 12 LastLast

Similar Threads

  1. Problems starting Counter-Strike
    By in forum OpenGL: User Software
    Replies: 5
    Last Post: 09-06-2005, 02:44 PM
  2. THE SOLUTION TO COUNTER-STRIKE PROBLEMS!!!
    By in forum OpenGL: User Software
    Replies: 0
    Last Post: 10-29-2002, 10:56 PM
  3. Replies: 1
    Last Post: 06-04-2002, 12:51 AM
  4. OpenGL problems in Counter-Strike
    By Deckrin in forum OpenGL: User Software
    Replies: 4
    Last Post: 07-15-2001, 12:27 PM
  5. OpenGL problems on Counter Strike
    By in forum OpenGL: User Software
    Replies: 0
    Last Post: 12-07-2000, 04:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean