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 8 of 8

Thread: glutSolidSphere stops the light???

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2004
    Location
    teesside
    Posts
    22

    glutSolidSphere stops the light???

    I am creating my first real game demo and am spending FAR too jmuch time on the lighting. The way it works is that when you fire in the game, one of the bullets in the array is activated and then every bullet in the array is moved forward and rendered at update.

    The thing is I have mada a simple light model (ambient with a bit of specular) but when I press fire (and GlutSolidSphere is called) it turns off the lights. I have removed this line and it is fine, is this a known problem and is there a way around it?

    Cheers for any help,

    BennUK

  2. #2
    Junior Member Regular Contributor
    Join Date
    Mar 2004
    Posts
    143

    Re: glutSolidSphere stops the light???

    Thats unlikley, since all glutSolidSphere() does is this:

    Code :
    static GLUquadricObj *quadObj;
    #define QUAD_OBJ_INIT() { if(!quadObj) initQuadObj(); }
     
    static void
    initQuadObj(void)
    {
      quadObj = gluNewQuadric();
      if (!quadObj)
        __glutFatalError("out of memory.");
    }
     
    void APIENTRY
    glutSolidSphere(GLdouble radius, GLint slices, GLint stacks)
    {
      QUAD_OBJ_INIT();
      gluQuadricDrawStyle(quadObj, GLU_FILL);
      gluQuadricNormals(quadObj, GLU_SMOOTH);
      /* If we ever changed/used the texture or orientation state
         of quadObj, we'd need to change it to the defaults here
         with gluQuadricTexture and/or gluQuadricOrientation. */
      gluSphere(quadObj, radius, slices, stacks);
    }
    So it must be your code. Perhaps you want to show some of it?

  3. #3
    Junior Member Newbie
    Join Date
    Jan 2004
    Location
    teesside
    Posts
    22

    Re: glutSolidSphere stops the light???

    With these parts commented out, it's fine, as soon as I put the glutSolidSphere back, it dies. Hmmmn.


    void CworldModel::renderBullets(void)
    {
    for(int i = 0; i < BULLET_AMOUNT; i ++)
    {
    if (player.getBulletState(i))
    {
    //glLoadIdentity();
    glPushMatrix();
    glTranslatef(player.getBulletPosition(i, 0) + 0.5, 45, player.getBulletPosition(i, 2));
    glEnable(GL_COLOR_MATERIAL);
    //glutSolidSphere(0.1, 16, 16);
    glDisable(GL_COLOR_MATERIAL);
    glPopMatrix();


    }
    }
    }

    Thanks

    BennUK

  4. #4
    Junior Member Regular Contributor
    Join Date
    Mar 2004
    Posts
    143

    Re: glutSolidSphere stops the light???

    Have you changed your matrixmode to
    Code :
    glMatrixMode(GL_MODELVIEW);
    otherwise you are still doing everything in the projection matrix mode, which wont work (the projection matrix mode only has a depth of two stack entries).

  5. #5
    Intern Contributor
    Join Date
    Jul 2003
    Location
    Rhode Island
    Posts
    55

    Re: glutSolidSphere stops the light???

    I remember something similiar to this hapenning to me... I recall it having to do something with GL_COLOR_MATERIAL but I don't exactly know... Try taking those glEnable and glDisable lines out and just draw the sphere and see what it does...

    Hope it works, I don't exactly remember

  6. #6
    Junior Member Newbie
    Join Date
    Jan 2004
    Location
    teesside
    Posts
    22

    Re: glutSolidSphere stops the light???

    Tried both the above and no joy Thanks for your help though guys, guess I will just have to pull my code to bits and see if i can get to the bottom of it that way.

    BennUK

  7. #7
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,453

    Re: glutSolidSphere stops the light???

    The enable color material call will set the materials to the current color. The default is front_and_back, ambient_and_diffuse. The glutSolidSphere has no colors. If your color was black before, you're screwed.
    It's one of OpenGL pitfalls described in the so-named doc on the main page: http://www.opengl.org/resources/feat...es/oglpitfall/ see #14.

    This is one of the reasons why it's clever to set parameters first and call enable as last.

  8. #8
    Junior Member Newbie
    Join Date
    Mar 2004
    Posts
    18

    Re: glutSolidSphere stops the light???

    I think if you do a glPushAttrib(GL_ALL_ATTRIB_BITS), draw your glut sphere, and then pop them off again it might work... I had a similar problem before.

Posting Permissions

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