纹理未映射整个 nurbs 表面
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);
我尝试将纹理映射到 nurbs 表面。
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);
问题是纹理看起来映射了表面的所有区域,但是照片仅出现在左下小网格(白色网格)中。另一部分是黑色的。
我想将照片映射到整个表面。但我不知道该怎么做。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
花了很多时间,我终于找到了问题所在。
当我计算控制点的坐标时,我使用类似 tCtrPoint[i][j][1] =j/(num-1); 的代码 问题是被除数和除数是整数类型。所以除法
\
没有得到正确的值。我以前也犯过这样的错误。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.