OpenGL 选择缓冲区 - 使用指向对象的指针而不是无符号整数?
我正在尝试使用 glSelectBuffer(GLsizei size, GLuint * buffer) 方法以稍微不同的方式选择对象,我相信 OpenGL 3.1 的 C++ 支持该方法。如果我按照网上指定的方式执行所有操作,那么选择效果会很好。
我希望在选择缓冲区中实际存储指向图形对象本身的指针,而不是 GLuint*。这将使我能够根据包含指向该对象的指针的选择轻松发出信号。当 GLuint 的大小和指向我的对象 (x86) 的指针的大小对齐时,这似乎可以正常工作,但当它们不对齐 (x64) 时,它似乎会中断。
我可以通过另一个步骤来完成此操作,但我宁愿不必排列选择 ID ->对象指针(如果 OpenGL 将支持这种选择其他数据类型的机制)。
我正在尝试使用 OpenGL 的选择机制来实现这一点吗? (最好在 OpenGL 3.1 中,但未来的版本也适用。)
我的问题有意义吗?我的解释中遗漏了什么吗?到目前为止,我尝试使选择缓冲区采用长整型而不是整数,并且收到类型检查错误(正如预期的那样)。另外,我没有看到 glSelectBuffer() 的任何重载方法,这让我认为这种方法是不可能的。我查看了 gl.h 以查看 typedef 并更多地了解 OpenGL 的类型。我也在 Stack Overflow 上查看了类似的问题 - 如果有人问了同样的问题而我错过了,我深表歉意。
I am attempting to use the glSelectBuffer(GLsizei size, GLuint * buffer) method to select objects in a slightly different way then I believe is supported in C++ for OpenGL 3.1. Selection works great if I do everything as is specified online.
Instead of a GLuint*, I would like to actually store pointers to my graphical objects themselves in the selection buffer. This will allow me to easily emit signals based on selection which contain a pointer to that object. This seems like it will work OK when the size of a GLuint and the size of a pointer to my object (x86) line up, but seems like it will break when they do not (x64.)
I can accomplish this with another step, but I would rather not have to line up the selection ID -> object pointer if OpenGL will support this mechanism of selection with other data types.
Is what I am trying to do possible using OpenGL's selection mechanism? (Preferably in OpenGL 3.1, but future versions are applicable as well.)
Does my question make sense? Am I missing something in my explanation? So far, I have tried to make the selection buffer take longs instead of ints, and I receive a type checking error (as is expected.) Also, I did not see any overloaded methods for glSelectBuffer(), which makes me think this approach is not possible. I looked at gl.h to see the typedefs and to understand OpenGL's types more. I have also looked over similar questions on Stack Overflow - I apologize if the same question has been asked and I missed it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
选择模式已从 OpenGL-3 核心及更高版本中删除。 OpenGL 用于绘图,选择模式无论如何都会退回到软件模式,即不是硬件加速的。
只是我的建议:不要使用它。
Selection mode has been removed from OpenGL-3 core and later versions. OpenGL is meant for drawing, and selection mode uses to fall back into software mode anyway, i.e. is not HW accelerated.
Just my suggestion: Don't use it.