我有一个带有一些图形的OpenGL场景。你能告诉我在“渲染”后计算图形顶点位置需要做什么吗?我知道我可能需要手动乘以一些矩阵,但我不知道哪些矩阵和如何操作。
非常感谢您提前的帮助!
我有一个带有一些图形的OpenGL场景。你能告诉我在“渲染”后计算图形顶点位置需要做什么吗?我知道我可能需要手动乘以一些矩阵,但我不知道哪些矩阵和如何操作。
非常感谢您提前的帮助!
您想知道屏幕上以像素为单位的最大范围吗?
如果是这样,最简单的方法就是对所有顶点调用gluProject,并存储最大和最小的x和y位置。
可能看起来像这样:
GLdouble modelview[16], projection[16]
GLint viewport[4];
glGetDoublev(GL_MODELVIEW_MATRIX, *modelView);
glGetDoublev(GL_PROJECTION_MATRIX, *projection);
glGetIntegerv(GL_VIEWPORT, *viewport);
double tx, ty, tz;
for(i = 0; i < VertexCount; i++)
{
glProject(vertices[i].x, vertices[i].y, vertices[i].z,
modelview, projection, viewport,
*tx, *ty, *tz);
// now, the 2d position of the ith Vertex is stored in tx, ty, tz.
// you can now use these values to determine the 2d-extends on your screen
}