Agh!
So I've been working on a game as a side project and am finishing up a map editor. Part of the map editor is a map rendering button. You press it, it should render the map, using OpenGL (via NSOpenGLView/Context).
However, the major problem is the fact that for some reason depth isn't working at all!
This is the code from my drawRect: method -
If you'll notice, I commented out the actual map rendering routine and replaced it with a simple square rendering.
wtf is a variable (aptly named for my situation) that basically increases how far the camera is translated "back" on the z axis. I render the square a given color based on wtf so I can get an immediate visual signal of what's going on. DEBUG_OUTPUT2() is just a macro tha spits something out onto stderr.
what *should* happen is that there should be a square that progressively gets further away and brighter as it does so. what *actually* happens is that the entire viewport is whatever color the square is until wtf = -1.0000, at which point the screen goes black and nothing more happens (visually, at least).
I'm relatively certain that I set everything else up correctly (but i guess clearly this means I haven't). Can anyone help?? I'll put up some more code if that'll help figure this out.
So I've been working on a game as a side project and am finishing up a map editor. Part of the map editor is a map rendering button. You press it, it should render the map, using OpenGL (via NSOpenGLView/Context).
However, the major problem is the fact that for some reason depth isn't working at all!
This is the code from my drawRect: method -
Code:
static BOOL firstTime = TRUE;
static GLfloat wtf = 0.0f;
if ( firstTime ) {
[glContext setView:openGLView];
firstTime = FALSE;
}
// clear the buffer
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glLoadIdentity();
// move the origin back
glTranslatef( 0.0f, 0.0f, wtf );
wtf -= .05f;
// render the map
// [mapRenderer drawMap:targetMap];
// test: draw a square
glBegin( GL_QUADS );
glColor3f( -wtf/3, -wtf/3, -wtf/3 );
glVertex3f( 1.0f, 1.0f, 0.0f );
glVertex3f(-1.0f, 1.0f, 0.0f );
glVertex3f(-1.0f,-1.0f, 0.0f );
glVertex3f( 1.0f,-1.0f, 0.0f );
glEnd();
DEBUG_OUTPUT2( "wtf? %f", wtf );
// flush the buffer
[glContext flushBuffer];
If you'll notice, I commented out the actual map rendering routine and replaced it with a simple square rendering.
wtf is a variable (aptly named for my situation) that basically increases how far the camera is translated "back" on the z axis. I render the square a given color based on wtf so I can get an immediate visual signal of what's going on. DEBUG_OUTPUT2() is just a macro tha spits something out onto stderr.
what *should* happen is that there should be a square that progressively gets further away and brighter as it does so. what *actually* happens is that the entire viewport is whatever color the square is until wtf = -1.0000, at which point the screen goes black and nothing more happens (visually, at least).
I'm relatively certain that I set everything else up correctly (but i guess clearly this means I haven't). Can anyone help?? I'll put up some more code if that'll help figure this out.