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: Turning off glMaterial ??

  1. #1
    Guest

    Turning off glMaterial ??

    Once you've made a call to glMaterialfv(...) is there a way to return to the state before this call was made?
    I've written a program for exploring what an object (a sphere) will look like as I change the RGBA reflection coeffecients. Code in question looks something like this:

    if (mat_amb_cb == 1) glMaterialfv(GL_FRONT, GL_AMBIENT, matAmb);
    if (mat_dif_cb == 1) glMaterialfv(GL_FRONT, GL_DIFFUSE, matDif);
    ...
    drawSphere();
    ...

    The if statments are not excuted till I check the appropriate check box. Once they are unchecked, and those lines are not longer executed in the rendering routine the sphere will still retain those material properties.
    Why???

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

    Re: Turning off glMaterial ??

    glPush/PopAttrib will save and restore states. However, I have a feeling you can't use it in this case, so I suppose you have to save the material before changing it. Either keep it yourself in a variable or get it from OpenGL with glGetMaterial.

  3. #3
    Guest

    Re: Turning off glMaterial ??

    Bob,

    Using glPushAttrib(GL_LIGHTING) & glPopAttrib() does exactly what I asked for, thanks.

Posting Permissions

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