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
    Senior Member Regular Contributor Agent D's Avatar
    Join Date
    Sep 2011
    Location
    Innsbruck, Austria
    Posts
    281
    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.

  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.

Similar Threads

  1. Performance: reading rendertarget each frame
    By john_connor in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 01-06-2017, 06:00 AM
  2. Texture "unbind" not working / weird
    By skiwi2 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 02-05-2014, 04:00 AM
  3. Different Blend Mode per RenderTarget
    By Jan in forum OpenGL: General
    Replies: 10
    Last Post: 04-09-2009, 11:20 PM
  4. Different Blend Mode per RenderTarget
    By Jan in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 04-06-2009, 05:35 PM
  5. Bind texture AND attach to framebuffer object
    By soconne in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 03-29-2009, 04:56 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