使用 opengl 的 Eigen 数学库时出现问题

发布于 2024-09-18 09:19:38 字数 229 浏览 1 评论 0原文

我目前正在尝试将 Eigen 数学库与 Opengl 一起使用。我有一些来自 Eigen 的 Vector3f 的 typedef,比如 Vec3,这样我就可以用它作为我的顶点的坐标。我还有一个带有坐标(vec3)、法线(vec3)和颜色(vec4)的顶点结构。当我尝试使用顶点数组时(一旦使顶点数组正常工作,我将使用 VBO),OpenGL 将 Eigen 的 Vector3f 处理为坐标似乎存在问题......你们中有人处理过这些问题吗?

I'm currently trying to use Eigen math library with Opengl. I've some typedefs for Vector3f from Eigen, say Vec3, so that I can use it as a coord for my vertices. I also have a structure for a vertex with coord (vec3), normal (vec3) and color(vec4). When I try to use vertex arrays (I'll use VBOs once I make vertex arrays work properly) it seems there is a problem with OpenGL processing Eigen's Vector3f as coords... Has any of you dealed with these issues??

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

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

发布评论

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

评论(2

空城之時有危險 2024-09-25 09:19:38

在 Eigen 中,向量是矩阵(参见 http://bitbucket.org/ eigen/eigen/src/e17630a40408/doc/AsciiQuickReference.txt 第 12 行)

我怀疑 Matrices 不仅拥有数据,还拥有附加信息,例如其大小。更重要的是,它的包装可能很奇怪。

那么, sizeof(Eigen::Vector3f) 返回什么?如果是 3xsizeof(float) = 12,则问题出在其他地方。

顺便问一下,你如何设置和绘制你的数组?

In Eigen, Vectors are Matrices (cf http://bitbucket.org/eigen/eigen/src/e17630a40408/doc/AsciiQuickReference.txt line 12)

I suspect Matrices to own not only the data, but only additional information, like its size. What's more, it packing may be weird.

So, what does sizeof(Eigen::Vector3f) returns ? If it's 3xsizeof(float) = 12, the problem is elsewhere.

How do you setup and draw your array, by the way ?

葵雨 2024-09-25 09:19:38

Eigen3 现在实际上有 OpenGL 的包装。这似乎是获得你想要的东西的最干净的方式。

Eigen3 actually has wrappers for OpenGL now. This seems to be the cleanest way getting what you want.

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