quadric crashing, when fog enabled

Hi

When i try to draw a sphere trough GLU everything works fine, but when fog is enabled it crashes with :

my fog code :


    public void applyFog()
    {
       if(fog)
        {
            gl.glDepthFunc(GL.GL_LESS);
            gl.glDepthRange(-1,1);
            if(!gl.glIsEnabled(GL.GL_DEPTH_TEST))
                gl.glEnable(GL.GL_DEPTH_TEST);
            gl.glFogi(GL.GL_FOG_MODE, GL.GL_LINEAR);
            gl.glFogf(GL.GL_FOG_DENSITY, fogDensity);
            gl.glFogf(GL.GL_FOG_START, depth/2);
            gl.glFogf(GL.GL_FOG_END  ,  depth);
            gl.glFogfv(GL.GL_FOG_COLOR, background.getRGBOpenGl(), 0);
            if(!gl.glIsEnabled(GL.GL_FOG))
                gl.glEnable(GL.GL_FOG);
            if(gl.glIsEnabled(GL.GL_SMOOTH))
                gl.glDisable(GL.GL_SMOOTH);
        }
        else
        {
            if(gl.glIsEnabled(GL.GL_FOG))
                gl.glDisable(GL.GL_FOG);
        }
    }

I add added test, not to enable.disable something twice, but it still crashes

GLU’s crashing code


      if (!textureFlag) {

        // draw +Z end as a triangle fan

        gl.glBegin(GL.GL_TRIANGLE_FAN);

        gl.glNormal3f(0.0f, 0.0f, 1.0f);

        gl.glVertex3f(0.0f, 0.0f, nsign * radius);

        for (j = 0; j <= slices; j++) {

          theta = (j == slices) ? 0.0f : j * dtheta;

          x = -sin(theta) * sin(drho);

          y = cos(theta) * sin(drho);

          z = nsign * cos(drho);

          if (normals) {

            gl.glNormal3f(x * nsign, y * nsign, z * nsign);

          }

          gl.glVertex3f(x * radius, y * radius, z * radius);

        }

        gl.glEnd();

      }

is there an incompatibility between my fog code et glu’s code ?

Sounds suspicious. Do you have a test case for this?

i just wonderer if “incompatible” opengl commands existed :slight_smile:
i used my own implementation of sphere instead of glu’s and it works fine

but it is not only sphere, cylinder or glutCube too, so maybe it is the GLU.SMOOTH or GLU.OUTSIDE that is incompatible ?

GL_SMOOTH isn’t a state bit which can be enabled. I’d guess that somehow that’s causing the later detection of the GL_INVALID_ENUM.