Search code examples
javajogllightingvertex-bufferglu

I have written a CAD program in JOGL that works great until I put in a glu quadric, then the lighting is off


I wrote CAD software (Protocase Designer) and it was working great. Except on ATI cards where it crashes all the time. On the theory that display lists are deprecated and maybe ATI cards don't fully support them I decided to replace the display lists with Vertex Buffer Objects. I have that mostly working, but when I put in the following code, the lighting gets all messed up for some reason. Anyone know why? It doesn't matter if I put the code before or after the rendering of the vertex buffer objects.

        gl.glPushMatrix();
        gl.glTranslated(sX, sY, sZ);
        // -- sphere --
        GLU glu = new GLU();
        GLUquadric quad = glu.gluNewQuadric();
        glu.gluQuadricDrawStyle(quad, GLU.GLU_FILL);
        glu.gluQuadricNormals(quad, GLU.GLU_FLAT);
        glu.gluQuadricOrientation(quad, GLU.GLU_OUTSIDE);
        glu.gluSphere(quad, .1, 16, 16);

        glu.gluCylinder(quad, .05, .05, .5, 16, 2);

        glu.gluDeleteQuadric(quad);
        gl.glPopMatrix();

Any ideas why? This did not mess things up with the display list version. What I am rendering is an enclosure with holes using glu's tessellator.

Thank you!


Solution

  • I knew it was going to be a stupid separate issue. I had enabled vertex arrays but not color or normal arrays:

                gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
    
                //-- forgot these --
                gl.glEnableClientState(GL.GL_NORMAL_ARRAY);
                gl.glEnableClientState(GL.GL_COLOR_ARRAY);
    

    I had done this because the normals and colors were interleaved in the same array as the vertices so I thought I only needed the one enable, which of course was dead wrong.