开发者

Texturing Quadrics in JOGL

开发者 https://www.devze.com 2023-03-03 15:53 出处:网络
I can\'t manage to texture a glu Quadric (gluSphere): What i get instead of the texture, is an average color of the texture.

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);

sunTe开发者_开发问答xture.enable();
sunTexture.bind();
    GLUquadric sun = glu.gluNewQuadric();
    glu.gluQuadricTexture(sun, true);
    glu.gluSphere(sun, 5, DETAIL, DETAIL);
sunTexture.disable();


As GLU generates texture coordinates itsself and transmits them as glTexCoord, I think, there is no need to enable texcoord generation (GL_TEXTURE_GEN_S/T). I suppose the GLU-generated texCoords get overwritten with the ones from texgen.

I also see, that you submit an array of three floats to glMaterial, which expects RGBA (4 floats). But since I work with C++, I maybe wrong and this works in JoGL.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消