PDA

View Full Version : Please help with Nurbs and Texture



Maurizio78
07-17-2003, 02:53 AM
Hi,
I've a problem with Nurbs texturing, please note that I've done already a search on this forum but I didn't find
the answer.
In init routine I do:
glMap2f(GL_MAP2_TEXTURE_COORD_2, 0, 1, 2, 2, 0, 1, 4, 2, &texpts[0][0][0]); //where texpts is GLfloat texpts[2][2][2] = {{{0.0, 0.0}, {0.0, 1.0}},{{1.0, 0.0}, {1.0, 1.0}}};
glEnable(GL_MAP2_TEXTURE_COORD_2);
glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, imageWidth, imageHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, image); //image is my bmp image in pixel values

And as Red book said in display routine I do:
GluBeginSurface(nurb);
void gluNurbsSurface( GLUnurbs* nurb,GLint sKnotCount,GLfloat* sKnots,GLint tKnotCount,GLfloat* tKnots,GLint sStride, GLint tStride,GLfloat* control,GLint sOrder,GLint tOrder,
GL_MAP2_TEXTURE_COORD_2)
void gluNurbsSurface( GLUnurbs* nurb,GLint sKnotCount,GLfloat* sKnots,GLint tKnotCount,GLfloat* tKnots,GLint sStride, GLint tStride,GLfloat* control,GLint sOrder,GLint tOrder,
GL_MAP2_VERTEX_4)
GluEndSurface(nurb);

My problem:texture does not display correctly(only a piece of Nurbs surface is textured).

So the question is where I am wrong?
Parameters in gluNurbsSurface(....GL_MAP2_TEXTURE_COORD_2) and gluNurbsSurface(....GL_MAP2_VERTEX_4) are the same?Red book it's not clear at this point/

Thanks in advance.