使用 Pyglet 进行 OpenGL 拾取
我正在尝试使用 Pyglet 的 OpenGL 包装器实现选取,但在转换 C 教程< /a> 到 Python。具体如下部分。
#define BUFSIZE 512 GLuint selectBuf[BUFSIZE] void startPicking(int cursorX, int cursorY) { GLint viewport[4]; glSelectBuffer(BUFSIZE,selectBuf); glRenderMode(GL_SELECT); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glGetIntegerv(GL_VIEWPORT,viewport); gluPickMatrix(cursorX,viewport[3]-cursorY, 5,5,viewport); gluPerspective(45,ratio,0.1,1000); glMatrixMode(GL_MODELVIEW); glInitNames(); }
我不知道如何转声明 GLuint 或 GLint 数组,以便 glSelectBuffer 和 glPickMatrix 工作。有谁知道如何使用 Pyglet 在 Python 中做到这一点?谢谢。
I'm trying to implement picking using Pyglet's OpenGL wrapper, but I'm having trouble converting a C tutorial to Python. Specifically the part below.
#define BUFSIZE 512 GLuint selectBuf[BUFSIZE] void startPicking(int cursorX, int cursorY) { GLint viewport[4]; glSelectBuffer(BUFSIZE,selectBuf); glRenderMode(GL_SELECT); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glGetIntegerv(GL_VIEWPORT,viewport); gluPickMatrix(cursorX,viewport[3]-cursorY, 5,5,viewport); gluPerspective(45,ratio,0.1,1000); glMatrixMode(GL_MODELVIEW); glInitNames(); }
I'm not sure how to turn declare arrays of GLuint or GLint such that glSelectBuffer and glPickMatrix work. Does anyone know how to do this in Python with Pyglet? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我还没有尝试过你的特定示例,但声明数组的正常方法是在 ctypes 文档中。本质上你会创建一个像这样的数组类型:
I haven't tried your particular example, but the normal way to declare arrays is in the ctypes documentation. Essentially you would create an array type like this:
我在 PyOpenGL 方面运气很好。
http://pyopengl.sourceforge.net/
这非常简单,使用 C 教程会更容易它,我相信。
I've had good luck with PyOpenGL.
http://pyopengl.sourceforge.net/
It's pretty straightforward, and using a C tutorial would be easier with it, I believe.
您究竟遇到了什么样的麻烦? Pyglet 的 OpenGL 实现是对 DLL 的薄包装,并且几乎一对一地映射 C 调用。很难想象还有任何其他库可以更好地遵循 C 教程。
例如,此介绍与 C 语言的等效内容几乎相同OpenGL 调用:
Exactly what sort of trouble are you having? Pyglet's OpenGL implementation is a thin wrapper over the DLL and pretty much maps the C calls one-for-one. It's hard to imagine there would be any other library that could be better in terms of following a C tutorial.
For example, this introduction is pretty much identical to the C equivalent when it comes to the OpenGL calls: