我最近一直在 OS X 上使用 OpenGL(tl;博士:我是 OpenGL 菜鸟)并且得到了一些可以绘制立方体的代码。但是,我没有看到任何面孔(除了前面),因为我的视图没有被翻译。我尝试使用该gluLookAt
函数进行此翻译,但出现GL_INVALID_OPERATION
错误。这就是我的渲染方式:
// Activate and lock context
[_glView.openGLContext makeCurrentContext];
CGLLockContext(_glView.openGLContext.CGLContextObj);
// Update camera position
gluLookAt(0, 2.0, 0, 0, 0, 0, 0, 1, 0);
gl_GetError();
// Update viewport and render
glViewport(0, 0, _glView.frame.size.width, _glView.frame.size.height);
[_renderer doRender:time];
// Unlock and flush context
CGLUnlockContext(_glView.openGLContext.CGLContextObj);
[_glView.openGLContext flushBuffer];
当我注释掉gluLookAt
调用时,这段代码有效,从我从文档中收集到的信息来看,这个错误是由在 and 之间执行引起gluLookAt
的。我不知道这些是否在哪里被调用,因为我自己不调用它们,并且将调用包装起来并不能解决问题。glBegin
glEnd
gluLookAt
glBegin
glEnd
如果它有所作为,我使用的是 OpenGL 3.2 Core Profile。