I’ve drawn a circle using the following code:
glBegin(GL_TRIANGLES);
for(int i=0;i<=360;i++)
{
double angle=(float)(((double)i)/57.29577957795135);
double x2=x+(radius*(float)sin((double)angle));
double y2=y+(radius*(float)cos((double)angle));
glTexCoord2f(x, y);glVertex2d(x,y);
glTexCoord2f(x1, y1);glVertex2d(x1s,y1s);
glTexCoord2f(x2, y2);glVertex2d(x2,y2);*/
y1=y2;
x1=x2;
}
glEnd();
And I have a texture that I want to cover the circle. I can get this to work if I set all the variables (x, y, x1, y1, x2, y2, radius) to 0.5 because then it is sitting perfectly inside the texture map (which goes from 0-1 in both directions).
However this is very small on screen so I want to make the radius larger, but when I do this the code doesn’t work because it’s going outside the texture map.
All I need to do is use some kind of scaling equation that simply shrinks it to fit in the texture map. I thought all I would need is to divide the variable (either x1, y1, x2, or y2) by the radius and add 0.5 to it. (I’m keeping the center of the circle at 0.5, 0.5). However this doesn’t work. Any pointers as to what I’m doing wrong - I know its something really stupid but I still cant work it out.
Thanks.