Results 1 to 3 of 3

Thread: Turning off glMaterial ??

  1. #1

    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);

    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.

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Feb 2000

    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

    Re: Turning off glMaterial ??


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

Similar Threads

  1. glMaterial & GL_LIGHT
    By scubasteve in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 10-15-2014, 01:29 PM
  2. glmaterial
    By Ali S. Alfaraj in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 10-01-2010, 02:12 AM
  3. glMaterial
    By chign in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 06-04-2010, 03:32 AM
  4. Values for glMaterial
    By FabianW in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 11-03-2008, 10:07 AM
  5. how to undo glMaterial()?
    By jyoung77 in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 05-21-2003, 04:49 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