Lighting does not work with gluSphere

Posted by badcodenotreat on Stack Overflow See other posts from Stack Overflow or by badcodenotreat
Published on 2010-04-15T17:11:58Z Indexed on 2010/04/15 17:23 UTC
Read the original article Hit count: 309

Filed under:
|
|

This is a simple issue that I'm somewhat ashamed to ask for help on.

I'm making a simple call to gluSphere to render a sphere, however, it does not light properly even though I'm pretty sure I added the normals and lighting correctly. If, however, I add a texture, the model lights normally, except it seems to be always SMOOTH, and I cannot change it to flat.

This is the lighting code in my init() function:

    gl.glLightfv( GL.GL_LIGHT0, GL.GL_AMBIENT , AMBIENT_LIGHT, 0 );
    gl.glLightfv( GL.GL_LIGHT0, GL.GL_DIFFUSE , DIFFUSE_LIGHT, 0 );
    gl.glLightfv( GL.GL_LIGHT0, GL.GL_POSITION, light_pos    , 0 );
    gl.glEnable ( GL.GL_LIGHT0 );
    gl.glEnable ( GL.GL_LIGHTING );

this is my sphere code in my display() function:

    gl.glColor3d(1.0, 1.0, 1.0);
    glu.gluQuadricDrawStyle  (quad, GLU.GLU_FILL);
    glu.gluQuadricNormals    (quad, GLU.GLU_FLAT);
    glu.gluQuadricOrientation(quad, GLU.GLU_OUTSIDE);

    glu.gluSphere(quad, 1.0, lat, lon);

Please advise.

© Stack Overflow or respective owner

Related posts about opengl

Related posts about jogl