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

Thread: Back right buffer problem?

  1. #1
    Junior Member Newbie
    Join Date
    May 2007
    Posts
    21

    Back right buffer problem?

    Hi,

    I'm trying to draw something to the GL_BACK_RIGHT buffer, but for some reason it keeps going to my GL_BACK buffer instead - is this right?

    I'm drawing a black square to GL_BACK_RIGHT, and an orange one to GL_BACK, but when I call SwapBuffers(), I see *both* of my squares on the screen. I thought the back right one would still be hidden as it has been drawn to a different buffer...?

    Here's my code:

    // use GL_BACK_RIGHT buffer
    glDrawBuffer(GL_BACK_RIGHT);

    glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);

    glLoadIdentity();
    glTranslatef(0.0f,0.0f,-10.0f);

    // draw a black square
    glColor3b(0,0,0);
    glBegin(GL_POLYGON);
    glVertex3f(1,1,1);
    glVertex3f(-1,1,1);
    glVertex3f(-1,-1,1);
    glVertex3f(1,-1,1);
    glEnd();

    // now switch to GL_BACK buffer
    glDrawBuffer(GL_BACK);

    glLoadIdentity();
    glTranslatef(0.0f,0.0f,-10.0f);

    // draw an orange square
    glColor3b(100,50,0);
    glBegin(GL_POLYGON);
    glVertex3f(2,2,1);
    glVertex3f(0,2,1);
    glVertex3f(0,0,1);
    glVertex3f(2,0,1);
    glEnd();

    // swap back buffer to front
    SwapBuffers(hDC);


    Many thanks for any help in advance.

    Daz.

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: Back right buffer problem?

    Are you sure you have a stereoscopic rendering context? If not, only the left buffer exists, and activating the right one is an error. Since it's an error, the command is ignored and the active buffer is not changed. That would explain why they both end up in the same buffer.

  3. #3
    Junior Member Newbie
    Join Date
    May 2007
    Posts
    21

    Re: Back right buffer problem?

    I'm not sure. But I've tried rendering to the following buffers: GL_FRONT_LEFT,
    GL_FRONT_RIGHT, GL_BACK_LEFT, GL_BACK_RIGHT, GL_FRONT,
    GL_BACK, GL_LEFT, GL_RIGHT

    And I get the same results, no matter which buffer I draw to. I always get both squares showing. Even if I render to GL_NONE!! o_0

    Seems like it always defaults to GL_BACK, and nothing else...

    Daz

  4. #4
    Junior Member Newbie
    Join Date
    May 2007
    Posts
    21

    Re: Back right buffer problem?

    BTW I'm using NeHe's Tutorial 2 to test this.

    http://nehe.gamedev.net/data/lessons....asp?lesson=02

    All I did was replace the DrawGLScene function with my code above, and I always get both squares showing. :-/

    Many thanks for your help.

    Daz

  5. #5
    Senior Member Frequent Contributor arekkusu's Avatar
    Join Date
    Nov 2003
    Posts
    890

    Re: Back right buffer problem?

    GLint isStereo;
    glGetIntegerv(GL_STEREO, &isStereo);
    if (!isStereo) printf("Your pixel format wasn't created with stereo attributes, or your hardware doesn't support stereo.");

  6. #6
    Junior Member Newbie
    Join Date
    May 2007
    Posts
    21

    Re: Back right buffer problem?

    OK,

    Thanks for that. It seems that neither my laptop nor my pc at work have either stereo or auxilliary buffer support!! Which is real disappointing since I can't do what I want to do now.

    I take it these buffers are very rarely used, if they are not supported that well?? Neither of my machines is more than 2 years old.

    Thanks anyways,

    Daz.

  7. #7
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: Back right buffer problem?

    What is it you want to do then? Asking for a specific solution it not always the best idea. By doing so, you assume that solution is the best solution for the problem you have.

    If you instead tell us what your ultimate goal really is, maybe we can provide a solution you never thought about, which is even better than using the stereoscopic rendering mechanism.

    But then again, for stereoscopic rendering, there aren't many option. However, I do get the impression you don't really know what stereoscopic rendering is about, and you try to get it to do something it can't do.

  8. #8
    Junior Member Newbie
    Join Date
    May 2007
    Posts
    21

    Re: Back right buffer problem?

    OK, after a bit more research, it seems the problem's because I'm using the 'generic' implementation of OpenGL on Windows - which does not support either stereo or auxiliary buffers.

    So I'm wondering, how do I go about using a hardware implementation instead - and is this a wise thing to do?

    Thanks,

    Daz.

  9. #9
    Junior Member Newbie
    Join Date
    May 2007
    Posts
    21

    Re: Back right buffer problem?

    Bob, thanks for your reply. I didn't see it until after I posted my last message.

    I'm using the 'color picking' method. All I want to do is draw a scene to some back buffer that I can read the pixels from using glReadPixels. Every time the user moves the mouse I want it to find out what object the mouse is over.

    Now I could simply draw the scene to GL_BACK every time the use moves the mouse, read the values, then clear the buffer and draw my main scene over it. But that would be very costly and probably halve my frame rate.

    I just want my color picking scene to be stored in a separate buffer so I only need to redraw it when one of the objects in it actually changes position. This is why I was looking at using one of the stereo or auxiliary buffers to store my scene.

    Thanks for your help.

    Daz

  10. #10
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: Back right buffer problem?

    The fast way would be to use FBO for your offscreen rendering :
    http://www.opengl.org/registry/specs...fer_object.txt

    I don't really know if AUX buffers are actually available nowadays ?

Page 1 of 2 12 LastLast

Similar Threads

  1. FBO vs back-buffer?
    By ugluk in forum OpenGL: GLSL
    Replies: 7
    Last Post: 01-05-2010, 05:05 AM
  2. Replies: 5
    Last Post: 02-10-2006, 12:56 PM
  3. glReadPixels read the front buffer or the back buffer?
    By s.hu in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 09-16-2004, 11:15 AM
  4. Fast copy from back buffer to back buffer?
    By robosport in forum OpenGL: Advanced Coding
    Replies: 19
    Last Post: 03-04-2004, 10:12 AM
  5. Front or Back buffer problem
    By bumby in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 05-11-2003, 10:25 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