渲染后的 OpenGL 点位置(3d -> 2d)

发布于 2024-10-04 17:12:04 字数 114 浏览 0 评论 0原文

我有一个 OpenGL 场景,上面有一些图形。你能告诉我在“渲染”之后我需要做什么来计算图形顶点位置吗?我知道我可能需要手动乘以一些矩阵,但我不知道其中哪些矩阵以及如何乘法。

预先感谢您的任何帮助!

I've got an OpenGL scene with some figures on it. Can you tell me what I need to do to calculate figures apexes positions after "rendering"? I know I probably need to manual multiply some matrices, but I don't know which of them and how.

Thanks in advance for any help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我一向站在原地 2024-10-11 17:12:04

看一下 gluProject() 函数。

编辑:也可在 OpenGL 常见问题解答中找到:
9.100 如何找到给定对象空间坐标的屏幕坐标?
(不过,答案相同。)

Take a look at the gluProject() function.

Edit: Also found in the OpenGL FAQ:
9.100 How can I find the screen coordinates for a given object-space coordinate?
(Same answer, though.)

关于从前 2024-10-11 17:12:04

您想知道屏幕上的最大像素范围吗?

如果是这样,最简单的方法是为所有顶点调用 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

}

Do you want to know the maximum extents on your screen in pixles?

If so, the simplest way to go is to call gluProject for all your vertices and store the maximum and minimum x and y positions.

Could look like this:

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

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文