Question

glGenTextures(1, &texName[0]);
glBindTexture(GL_TEXTURE_2D, texName[0]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, widthImage , widthImage, 
    0, GL_RGB, GL_UNSIGNED_BYTE, image);

I try to map the texture to the nurbs surface.

gluBeginSurface(theNurbs);

gluNurbsSurface(theNurbs, numOfKnots, knots, numOfKnots, knots, ctrNum*3, 3, &tCtrPoint[0][0][0],order, order,GL_MAP2_TEXTURE_COORD_2);

gluNurbsSurface(theNurbs, numOfKnots2, knots2, numOfKnots2, knots2, ctrNum2*3, 3, &ctrPoint[0][0][0], order2, order2, GL_MAP2_VERTEX_3);

gluEndSurface(theNurbs);

The problem is that the texture looks mapping all the area of the surface, however, the photo only appears in the lower left small grid(white grid). The other part is black.

I want to map the photo to the whole surface. But I cannot figure out how to do that.

Was it helpful?

Solution

After spending many hours, I finally find the problem.

When I calculate the coordinates of the control points, I use code like tCtrPoint[i][j][1] =j/(num-1); The problem is that the dividend and divisor are integer types. So the division\ did not get the correct value. I made this type of mistake before.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top