PDA

View Full Version : EVALUATORS & TEXTURE COORDINATES



VinceDeNice
04-07-2005, 01:18 AM
Hello,
I want to draw a road, considering that the two side lines are parallel.
I've got 3 control points, for the mid-line Bezier curve. I just want to translate this curve on the left and on the right.
I want to put a texture too:
Here's my code, can I do it (put a glTexCoord2f before a glEvalCoord1f) ?
Anyone understand what I'm trying to do ?
Thanks.



void drawTwoParallelBezierCurvesWithTexture()
{
glEnable(GL_TEXTURE_2D);
mat->Utilise(); // mat is the material

tex->utilise(); // tex is the texture

glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 4, 3, *points_controle); // points_controle is the control points array
glEnable(GL_MAP1_VERTEX_3);

for(GLfloat i = 0.0; i <= 1.05; i+=0.05f)
{
glNormal3f(0.0, 0.0, 1.0);
glBegin(GL_QUADS);
glPushMatrix();
glTranslatef((points[2]->m_x-points[3]->m_x)/2, 0.0, 0.0); // x translation value can be considerate as a constant value
glTexCoord2f(1.0, 1.0);
glEvalCoord1f(i);
glPopMatrix();

glPushMatrix();
glTranslatef(-(points[2]->m_x-points[3]->m_x)/2, 0.0, 0.0); // x translation value can be considerate as a constant value
glTexCoord2f(0.0, 1.0);
glEvalCoord1f(i);
glPopMatrix();

glPushMatrix();
glTranslatef(-(points[2]->m_x-points[3]->m_x)/2, 0.0, 0.0); // x translation value can be considerate as a constant value
glTexCoord2f(0.0, 0.0);
glEvalCoord1f(i+0.05);
glPopMatrix();

glPushMatrix();
glTranslatef((points[2]->m_x-points[3]->m_x)/2, 0.0, 0.0); // x translation value can be considerate as a constant value
glTexCoord2f(1.0, 0.0);
glEvalCoord1f(i+0.05);
glPopMatrix();
glEnd();
}

glDisable(GL_MAP1_VERTEX_3);

glDisable(GL_TEXTURE_2D);
}