I have made a half circle with a Triangle fan, here's the code:
marco.bind();
gl.glPushMatrix();
gl.glTranslated(-3.5,2,10.51);
gl.glBegin(gl.GL_TRIANGLE_FAN);
for(int i = 1; i <= 9; i++){
double x = 0.7 * Math.cos(angulo);
double y = 0.7 * Math.sin(angulo);
System.out.println ("Valor de X:" + x + " Valor de Y:" + y);
gl.glTexCoord2d(x, y);gl.glVertex3d(x, y, -0.5);
angulo += inc_angle;
But i haven't achieved the visual effect that i want, my real texture looks like this:
Instead i got something like this:
Now I got this
Is there something wrong with my image? i think that the corners need to be cut.
Texture coordinates are in range (0,0) - (1,1)
your object coordinates are in range (-0.7,-0.7) - (0.7,0.7)
. You need to transform your object coordinates to correct coordinates on your texture.
For example:
double x = Math.cos(angulo);
double y = Math.sin(angulo);
gl.glTexCoord2d(x*0.5+0.5, 1.0-y);
gl.glVertex3d(x*0.7, y*0.7, -0.5);