Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 3 123 LastLast
Results 1 to 10 of 24

Thread: FBO and TEXTURE_RECTANGLE_ARB

  1. #1
    Advanced Member Frequent Contributor
    Join Date
    Dec 2005
    Location
    Italy
    Posts
    656

    FBO and TEXTURE_RECTANGLE_ARB

    Hi Guys,


    RenderToBitamp (target bitmap is not square and not power of two): we are switching to the slower glReadPixel in the case GL_TEXTURE_RECTANGLE extension is not present but it is really necessary? FBO cares about NPOTS or not?

    Below the code we use ONLY when *both* FBO and GL_TEXTURE_RECTANGLE are available.


    Thanks,

    Alberto

    Code :
    glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);
     
    DrawScene(...);
     
    glBindTexture(GL_TEXTURE_RECTANGLE_ARB, color_tex);
    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
     
    glGetTexImage(GL_TEXTURE_RECTANGLE_ARB, 0, GL_BGR, GL_UNSIGNED_BYTE, bitmapData);

  2. #2
    Senior Member OpenGL Pro Ilian Dinev's Avatar
    Join Date
    Jan 2008
    Location
    Watford, UK
    Posts
    1,262

    Re: FBO and TEXTURE_RECTANGLE_ARB

    FBO with texture-rectangle is not slower than tex2D, in my experience.

  3. #3
    Advanced Member Frequent Contributor
    Join Date
    Dec 2005
    Location
    Italy
    Posts
    656

    Re: FBO and TEXTURE_RECTANGLE_ARB

    Hi Ilian,

    My question is: if I use GL_TEXTURE2D and target a rectangular texture will it work on all OpenGL implementations? On my ATI FIRE GL it works.

    Thanks,

    Alberto

  4. #4
    Senior Member OpenGL Pro Ilian Dinev's Avatar
    Join Date
    Jan 2008
    Location
    Watford, UK
    Posts
    1,262

    Re: FBO and TEXTURE_RECTANGLE_ARB

    You can safely create an 888x333 GL_TEXTURE_2D if the NPOT extension-string is available. And you can use that texture as a render-target.
    Just think about it: all current-gen games do render-to-texture and then do post-processing on that texture . In DX9/10, there's no texRECT, it's all tex2D.

    But if you mean creation of a GL_TEXTURE_RECTANGLE, and then binding that same texture to a GL_TEXTURE_2D target, then I don't know. Your question is ambiguous imho. (also "a rectangular texture" can mean both a 888x333 GL_TEXTURE_2D and an 888x333 GL_TEXTURE_RECTANGLE, so it can be confusing)

  5. #5
    Senior Member OpenGL Guru
    Join Date
    Mar 2001
    Posts
    3,768

    Re: FBO and TEXTURE_RECTANGLE_ARB

    if I use GL_TEXTURE2D and target a rectangular texture will it work on all OpenGL implementations?
    No. Not if it is a real rectangle textures.

    Rectangle Textures (created with the type GL_TEXTURE_RECTANGLE) are a fundamentally different type from 2D textures. You cannot interchange them with 2D textures.

    I suspect ATi works because they use a regular 2D texture for Rectangle Textures internally. nVidia hardware has special handling for rectangle textures.

    Please note that rectangle textures are different from NPOT textures (which are not new texture types; they're just a modification for the size rules on textures), which is what Ilian is talking about.

  6. #6
    Advanced Member Frequent Contributor
    Join Date
    Dec 2005
    Location
    Italy
    Posts
    656

    Re: FBO and TEXTURE_RECTANGLE_ARB

    Ilian,


    I thought that when you check for existance of the GL_ARB_TEXTURE_RECTANGLE extension you need to target it as GL_TEXTURE_RECTANGLE_ARB.

    By the way here: http://www.opengl.org/registry/specs..._rectangle.txt you find:

    Code :
    3) How is the image of a rectangular texture specified?
     
         Using the standard OpenGL API for specifying a 2D texture
         image: glTexImage2D, glSubTexImage2D, glCopyTexImage2D,
         and glCopySubTexImage2D.  The target for these commands is
         GL_TEXTURE_RECTANGLE_ARB though.
     
         This is similar to how the texture cube map functionality uses the 2D
         texture image specification API though with its own texture target.
     
         The texture target GL_TEXTURE_RECTANGLE_ARB should also
         be used for glGetTexImage, glGetTexLevelParameteriv, and
         glGetTexLevelParameterfv.

    But your observation is right. It works also specifying GL_TEXTURE2D.

    This is the source of my doubts.


    Thanks,

    Alberto

  7. #7
    Advanced Member Frequent Contributor
    Join Date
    Dec 2005
    Location
    Italy
    Posts
    656

    Re: FBO and TEXTURE_RECTANGLE_ARB

    Korval,


    We are talking about getting a bitmap from a OpenGL viewport, docked inside a variable size Windows form: dimension can be all the possible combinations.

    My question is: should I discard the FBO approach if OpenGL extension GL_ARB_texture_rectangle is not available?


    Thanks,

    Alberto

  8. #8
    Senior Member OpenGL Pro Ilian Dinev's Avatar
    Join Date
    Jan 2008
    Location
    Watford, UK
    Posts
    1,262

    Re: FBO and TEXTURE_RECTANGLE_ARB

    So, in conclusion:
    Code :
    CFBO* g_FBO;
    ...
    int texWid=111,texHei=444;
     
    if(extensionFBO){
    	int realTexWid,realTexHei;
    	if(extensionNPOT){
    		realTexWid=texWid;
    		realTexHid=texHid;
    	}else{
    		realTexWid = 128; // = fixupSize(texWid);
    		realTexHei = 512; // = fixupSize(texHei);
    	}
    	g_FBO = createFBO(realTexWid,realTexHei,texWid,texHei); // this uses only GL_TEXTURE_2D
    }else{
    	#if OK_TO_USE_glCopyTexImage2D
    		g_FBO = null;
    	#else
    		msgbox("Sorry, but Radeon9550 or even more ancient silicon is not supported");
    		ExitProcess(0);
    	#endif
    }

  9. #9
    Advanced Member Frequent Contributor
    Join Date
    Dec 2005
    Location
    Italy
    Posts
    656

    Re: FBO and TEXTURE_RECTANGLE_ARB

    Ilian,

    Yes, more or less like you coded but glCopyTexImage2D would need to handle NPOT dimensions, that's why we use glReadPixels.

    Alberto


  10. #10
    Senior Member OpenGL Pro dletozeun's Avatar
    Join Date
    Jan 2006
    Location
    FRANCE
    Posts
    1,370

    Re: FBO and TEXTURE_RECTANGLE_ARB

    Your wording is quite confusing for me. oÔ

    There may be only a "problem" if the ARB_texture_non_power_of_two is not supported and ARB_texture_rectangle is (you say the opposite IMO).

    if ARB_texture_non_power_of_two is supported, you do anything you want.

    Actually, what do you practically need to do? Retrieve image data in a texture or in system memory? glReadPixels and glCopyTexImage2D is not for the same purpose...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •