exu*_*ero 2 python opengl pyglet picking
我正在尝试使用Pyglet的OpenGL包装器实现拾取,但是我在将C教程转换为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中执行此操作?谢谢.
我没有尝试过您的特定示例,但声明数组的常规方法是在ctypes文档中.基本上你会创建一个这样的数组类型:
FourGLints = GLint * 4
viewport = FourGLints(0, 1, 2, 3)
Run Code Online (Sandbox Code Playgroud)