Does anyone knows a generic way to apply glTexCoord2f to generic polygons? For circles, triangles and quads, it was quite intuitive, but polygons is kind a mess.
For example, my equilateral triangle render is:
void Triangulo::RenderizaPontos(){
glColor3f(red, green, blue);
glLineWidth(grafite);
glBegin(GL_TRIANGLES);
glTexCoord2f(0.0f, 0.0f); glVertex2f(cantoesq.x, cantoesq.y);
glTexCoord2f(0.5f, 1.0f); glVertex2f(cantoesq.x + base , altura + cantoesq.y);
glTexCoord2f(1.0f, 0.0f); glVertex2f(cantoesq.x + 2*base, cantoesq.y);
glEnd();
}
The problem is for the generic polygon. His class is below:
Poligno::Poligno(std::deque<Ponto> pontos):
ponto(pontos)
{
prox = NULL;
grafite = 1.0;
}
void Poligno::RenderizaPontos(){
int tamanho, i;
tamanho = ponto.size();
glColor3f(red, green, blue);
glLineWidth(grafite);
glBegin(GL_POLYGON);
for(i = 0; i < tamanho; i++)
glVertex2f(ponto[i].x, ponto[i].y);
glEnd();
}
Any idea?