Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: how to unbind a texture which is attach to framebuffer as a rendertarget.

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2014
    Posts
    9

    Red face how to unbind a texture which is attach to framebuffer as a rendertarget.

    in directx, if i set a rendertarget which is still bind as a shader resource texture, it will cause a render error.
    so, if we want to use that surface as a rendertarget, we must unbind this texture, like directx api:
    DX9->SetTexture(i, NULL);

    i want to know, is there any same question in opengl, if i create a texture2d and attach to a framebuffer, and then render something on it.
    next step i use this texture as a normal texture, if it is still bind when the next frame, is it cause any errors? may be cause glClear failure by Invalid Operation?

  2. #2
    Member Regular Contributor Agent D's Avatar
    Join Date
    Sep 2011
    Location
    Innsbruck, Austria
    Posts
    260
    Quote Originally Posted by sczybt View Post
    if i create a texture2d and attach to a framebuffer, and then render something on it.
    next step i use this texture as a normal texture, if it is still bind when the next frame, is it cause any errors?
    If you try to use a texture that is attached to the framebuffer object you are rendering to, you will get undefined behaviour (i.e. depends on your implementation).
    It might work as expected, it might not.

    If you want to unbind the texture in order to render to it, call glBindTexture( <binding>, 0 )

    Quote Originally Posted by sczybt View Post
    may be cause glClear failure by Invalid Operation?
    The 3.x/4.x man pages don't indicate an invalid operation error for glClear, however if you are using compatibillity profile or an older GL version and calling glClear within a begin/end block, GL_INVALID_OPERATION is generated.
    Last edited by Agent D; 03-03-2014 at 09:18 AM.

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2014
    Posts
    9
    Quote Originally Posted by Agent D View Post
    If you try to use a texture that is attached to the framebuffer object you are rendering to, you will get undefined behaviour (i.e. depends on your implementation).
    It might work as expected, it might not.

    If you want to unbind the texture in order to render to it, call glBindTexture( <binding>, 0 )


    The 3.x/4.x man pages don't indicate an invalid operation error for glClear, however if you are using compatibillity profile or an older GL version and calling glClear within a begin/end block, GL_INVALID_OPERATION is generated.
    thank you very much.

Posting Permissions

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