im learning to use openGL and iv been told that because my wheel arches are concave i have to tessellate them. So here is my code for the front wheel arch...
GLdouble car[7][2] = { {-1.93,0.3}, {-1.95,0.4}, {-2.2,0.6}, {-2.6,0.6}, {-2.82,0.4}, {-2.8,0.3}, {-2.78,0.0} };
GLUtesselator *tess = gluNewTess(); // create a tessellator
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, textureLib[textureindex]);
glBegin(GL_POLYGON);
glTexCoord2f( 0.0 , 0.0 ); glVertex2f(-1.0 , 0.0 );
glTexCoord2f(-0.97, 0.0 ); glVertex2f(-1.97, 0.0 );
// Wheel arch
gluTessBeginContour(tess);
{
gluTessVertex(tess, car[0], car[0]);
gluTessVertex(tess, car[1], car[1]);
gluTessVertex(tess, car[2], car[2]);
gluTessVertex(tess, car[3], car[3]);
gluTessVertex(tess, car[4], car[4]);
gluTessVertex(tess, car[5], car[5]);
gluTessVertex(tess, car[6], car[6]);
}
gluTessEndContour(tess);
And the car looks like this:
{i know the texturing is wrong atm too) but as you can see the front wheel arch hasnt changed even with the tessellation, so i guess im tessellating wrong.. or need to tessellate more of it.. or something? if someone could please help me with this massive problem im having with the wheel arches and rectify it i would be eternally gratefully as i have been struggling to get past this point for a while. thanks :)
The whole drawBody function code can be found here: http://pastebin.com/s9RpzMsd
Update: Thanks for all the help: my object now looks like this thanks to the tessellation help. Now just to texture :)
Update 2: Ok so I used the same code roughly as PeterT suggested and this is what it ended up (had to make changes for it to compile. Point it out if its wrong)
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, textureLib[textureindex]);
GLUtesselator *tess = gluNewTess(); // create a tessellator
gluTessCallback(tess, GLU_TESS_VERTEX,
(void (__stdcall *) ()) &putvertex);
gluTessCallback(tess, GLU_TESS_BEGIN,
(void (__stdcall *) ()) &glBegin);
gluTessCallback(tess, GLU_TESS_END,
(void (__stdcall *) ()) &glEnd);
gluTessBeginPolygon(tess, NULL);
gluTessBeginContour(tess);
for(int i=0; i<29;i++)
gluTessVertex(tess, car[i], car[i]);
//call gluTessVertex for EVERY vertex in the polygon here
gluTessEndContour(tess);
gluTessEndPolygon(tess);
glDisable(GL_TEXTURE_2D);
With the putvertex code being:
void CALLBACK putvertex(GLdouble *verts)
{
//filled according to you texture coordinates:
GLdouble scalefacx = 1.0;
GLdouble scalefacy = 1.0;
GLdouble offsetx = -1.0;
GLdouble offsety = 0.0;
glVertex2dv(verts);
glTexCoord2d(verts[0]*scalefacx - offsetx,verts[1]*scalefacy - offsety);
}
It then looks like this:
Have i gone wrong somewhere? :/
Thanks for all your help, the final image looks like this:
Again thanks for all your help! Especially PeterT :)