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

Thread: glBlitFramebuffer() not working as expected??

  1. #1
    Member Contributor
    Join Date
    Oct 2011
    Posts
    67

    glBlitFramebuffer() not working as expected??

    Hello I'm creating a game using OpenGL for the vertexes and texturing them with SDL_Surfaces with images loaded in them and because of that I'm using SDL

    Code :
                glReadBuffer(GL_FRONT_AND_BACK);
     
                glDrawBuffer(GL_FRONT_AND_BACK);
     
                 glBlitFramebuffer(640, 480, 640,480,
                640, 480,640, 480,
                (GL_COLOR_BUFFER_BIT,GL_DEPTH_BUFFER_BIT,GL_STENCIL_BUFFER_BIT),GL_NEAREST);


    It doesn't seem to work as expected which is that it should Blit the framebuffer too the other framebuffer which I setup with glReadBuffer(GL_FRONT); and glDrawBuffer(GL_BACK); when I switch the buffers with this function SDL_GL_SwapBuffers(); it just shows the black back framebuffer instead of the front buffer onto the framebuffer.

    I'm Using OpenGL 3.3 and SDL 1.2

    Could someone tell me if I'm doing it wrong or doing it the right way but missing a step also how to do so thank you?.

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,135

    Re: glBlitFramebuffer() not working as expected??

    The above code shouldn't even compile since the mask isn't ORed together but seperated by commas. Furthermore, why would you blit the the front and back buffers anyway? Why even bother with the front buffer? In a double buffered setting, the front buffer is merely used for displaying the last frame while the current frame is being rendered to the back buffer. The content of the back buffer is automatically copied to the front buffer on swap. Add to that, you're blitting the buffers to themselves.

    I really don't think you need framebuffer blitting. Are you working with framebuffer objects or just the default framebuffer?

    I just realized that you've probably never had a good look at the spec or the API reference page. Can you tell me how you would copy an area determined by (640, 480) to (640, 480)? Add to that, the ref page states: "If the source and destination rectangles overlap or are the same, and the read and draw buffers are the same, the result of the operation is undefined." So your above code will never, ever, work.

  3. #3
    Member Contributor
    Join Date
    Oct 2011
    Posts
    67

    Re: glBlitFramebuffer() not working as expected??

    and I'm just doing it how any other knew person would do it. "stupidly"

    so how do I do it the right way can you give me a code sample that works?



  4. #4
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,135

    Re: glBlitFramebuffer() not working as expected??

    You simply don't blit. You don't need to blit the back buffer to the front buffer. The window system does that for you.

  5. #5
    Member Contributor
    Join Date
    Oct 2011
    Posts
    67

    Re: glBlitFramebuffer() not working as expected??

    so how do I update the SDL version of OpenGL context without using SDL_GL_SwapBuffers();? because that's What I read glBlitFramebuffer(); does.

    heres the link glBlitFramebuffer()

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

    Re: glBlitFramebuffer() not working as expected??

    It doesn't seem to work as expected which is that it should Blit the framebuffer too the other framebuffer which I setup with glReadBuffer(GL_FRONT); and glDrawBuffer(GL_BACK); when I switch the buffers with this function SDL_GL_SwapBuffers(); it just shows the black back framebuffer instead of the front buffer onto the framebuffer.
    I don't understand what you're saying here.

    The way rendering generally works is that you render to the back buffer. Then you swap the back and front buffers, so that the user can actually see what you rendered. This is done with an OS-dependent call, which SDL_GL_SwapBuffers() calls for you.

    In short, for common rendering, you don't need framebuffer blitting. The system handles that for you.

    The above code shouldn't even compile since the mask isn't ORed together but seperated by commas.
    Why shouldn't it compile? The comma operator is well-defined in both C and C++.

    It doesn't OR the components together, but the statement is well-defined and has a predictable result. Not the one that the user wants, but a predictable one none-the-less.

    and I'm just doing it how any other knew person would do it.
    Generally, most new people would look up the reference for `glBlitFramebuffer` and see how it works. At the very least, they'd get the rectangle part right.

  7. #7
    Member Contributor
    Join Date
    Oct 2011
    Posts
    67

    Re: glBlitFramebuffer() not working as expected??

    What do I need to "do" too update the opengl Context

  8. #8
    Senior Member OpenGL Lord
    Join Date
    Mar 2015
    Posts
    6,671

    Re: glBlitFramebuffer() not working as expected??

    Did you not read this line:

    Quote Originally Posted by me
    This is done with an OS-dependent call, which SDL_GL_SwapBuffers() calls for you.
    So just call that.

  9. #9
    Member Contributor
    Join Date
    Oct 2011
    Posts
    67

    Re: glBlitFramebuffer() not working as expected??

    when I call that it swaps the buffer updates the screen and the background that was already on the buffer will be gone and will show a blank screen with the vertex ontop on the backbuffer which is not what I want

    What I want is to SDL_GL_SwapBuffer(); and still have the contents of the frontbuffer on the backbuffer with the knew vertex "not a blank screen with the vertex".

    if thats not possible with SDL_GL_SwapBuffers() which I assume it is from testing it then how?

  10. #10
    Senior Member OpenGL Lord
    Join Date
    Mar 2015
    Posts
    6,671

    Re: glBlitFramebuffer() not working as expected??

    Just redraw the background just like everyone else.

Page 1 of 2 12 LastLast

Similar Threads

  1. glBlitFramebuffer of GL_DEPTH_STENCIL_ATTACHMENT is not working
    By saski in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 02-28-2017, 05:58 AM
  2. Projection not working as expected
    By Vorril in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 07-27-2014, 04:57 PM
  3. Alternative to glBlitFramebuffer()
    By AdamB in forum OpenGL: Advanced Coding
    Replies: 22
    Last Post: 01-22-2011, 11:37 AM
  4. glBlitFramebuffer tip
    By skynet in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 04-25-2010, 07:25 AM
  5. Rotation and translation not working as expected
    By squirrel in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 04-01-2006, 10:13 AM

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