I've been getting into OpenGL on OS X lately (tl;dr: I'm a OpenGL noob) and got some code working that draws a cube. However, I don't see any of the faces (besides the front) since my view isn't translated. I try to use the gluLookAt
function to do this translation, but I get an GL_INVALID_OPERATION
error. This is how I do my rendering:
// 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];
This code works when I comment out the gluLookAt
call, and from what I can gather from the docs, this error is caused by executing gluLookAt
between glBegin
and glEnd
. I don't know if where these are getting called, as I do not call those myself, and wrapping the call to gluLookAt
in glBegin
and glEnd
does not solve the issue.
If it makes a difference, I'm using OpenGL 3.2 Core Profile.