Results 1 to 5 of 5

Thread: Help! what does this actually do?

  1. #1
    Guest

    Help! what does this actually do?

    In sample program, they use glPushAttrib(GL_ENABLE_BIT); or glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT);

    then the draw code, then
    glPopAttrib()

    If I comment out the push/pop Attrib lines, it don't change program that I can see, so what do those lines do, and is there a reason to use them?
    I look at some docs, but they don't really explain in clearly enough, or maybe I am just not understand them.

    Ideas what it really do?

  2. #2
    Junior Member Newbie
    Join Date
    Apr 2002
    Location
    Grande Prairie, Alberta, Canada
    Posts
    9

    Re: Help! what does this actually do?

    Someone else might be able to explain this better, but basically, they push the variables specified in the glPushAttrib() function onto the stack; that way, if you change a setting, when glPopAttrib() is called, the old settings are restored. If you aren't changing anything, then those calls shouldn't really matter. However, its just there so that you don't have to save all the current settings to restore after you do you drawing.

    Someone please correct me if i'm wrong.

  3. #3
    Guest

    Re: Help! what does this actually do?

    yes, I know that much, but I don't know what the actual paramaters do. (GL_ENABLE_BIT) and so on..

    Sorry for confusion.

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Jun 2000
    Location
    Shreveport, LA, USA
    Posts
    1,502

    Re: Help! what does this actually do?

    The argument specifies which OpenGL attributes (or state variables) to push onto the stack.

  5. #5
    Senior Member OpenGL Pro
    Join Date
    Feb 2002
    Location
    Bonn, Germany
    Posts
    1,633

    Re: Help! what does this actually do?

    If you have the OpenGL spec - well, you should - there's a large table in section 6.2, where all OpenGL state is listed. This state is partitioned into different sections, check the 'attribute' field of the table to see what I mean.

    Eg, COLOR_CLEAR_VALUE (as set by glClearColor) belongs to the 'color-buffer' category, so it can be pushed by calling glPushAttrib(GL_COLOR_BUFFER_BIT). At the same time, all other state falling into the 'color-buffer' category will be pushed as well.

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