OpenGL:模型视图矩阵的多用户向量?
有没有办法让OpenGL转换一个通用向量,我用当前的模型视图矩阵给它并得到结果?
最明显的方法是查询模型视图矩阵并自己进行乘法,但是 我几乎确信应该有一种方法可以让 OpenGL 为我做到这一点。
Is there a way to make OpenGL transform a general vector I give it with the current modelview matrix and get the result back?
The obvious way is to query the modelview matrix and do the multiplication myself but
I am almost sure there should be a way to make OpenGL do this for me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
你是对的,你必须自己获取模型视图矩阵并变换向量。
如需确认,请参阅第 9.120 段的此链接。
You are right, you have to get the modelview matrix and transform the vector yourself.
For a confirm, see this link at paragraph 9.120.
最好在 OpenGL 之外进行计算。 矩阵和四元数常见问题解答是学习如何执行计算的良好资源,如果您已经不知道了。 您可以按如下方式获取 4x4 模型视图矩阵
It is best to do the calculation outside of OpenGL. The Matrix and Quaternions FAQ is a good resource for learning how to perform the calculations if you do not know already. You fetch the 4x4 model-view matrix as follows
最好在 CPU 端进行转换。 我能想到的唯一其他方法是使用 EXT_transform_feedback 加上仅执行模型视图转换的顶点着色器。
It's probably best to do the transformations on the CPU side. The only other way I can think of is to use EXT_transform_feedback plus a vertex shader that does only the modelview transformations.
opengl 可能不会为您执行此操作的原因是因为计算不是渲染管道的一部分。 而opengl(大多数情况下)仅在显示循环期间执行计算。 所以提供这类同步接口是没有意义的。
The reason why opengl probably won't just do this for you is because the calculation isn't part of the rendering pipeline. and opengl (for the most part) only performs calculations during the display loop. So it doesn't make sense to provide these kind of synchronous interfaces.