Search code examples
opengltexturesjoglglu

Texturing Quadrics in JOGL


I can't manage to texture a glu Quadric (gluSphere): What i get instead of the texture, is an average color of the texture.

gl.glEnable(GL.GL_DEPTH_TEST);
gl.glEnable(GL.GL_BLEND);
gl.glEnable(GL.GL_TEXTURE_GEN_S); 
gl.glEnable(GL.GL_TEXTURE_GEN_T); 

sunTexture = TextureIO.newTexture(new File("sun.jpg"),false);

float[] rgba = {1f, 1f, 1f};
gl.glMaterialfv(GL.GL_FRONT, GL.GL_AMBIENT, rgba, 0);
gl.glMaterialfv(GL.GL_FRONT, GL.GL_SPECULAR, rgba, 0);
gl.glMaterialf(GL.GL_FRONT, GL.GL_SHININESS, 0.5f);

sunTexture.enable();
sunTexture.bind();
    GLUquadric sun = glu.gluNewQuadric();
    glu.gluQuadricTexture(sun, true);
    glu.gluSphere(sun, 5, DETAIL, DETAIL);
sunTexture.disable();

Solution

  • I found the problem: i had set gl.glFrustum(-20, 20, -20, 20, 0.1, 400);

    after setting gl.glFrustum(-20, 20, -20, 20, 1, 400);

    it appears ok.