i'm trying to get some gl stuff to work, but i'm not able to work with the depth.
basically if i draw something far away after drawing something close, the further away object is still allways in front of the closer one.

i'm not sure if i can fix this with proper initialisation, or if i have to write a depth sort algorithm.

heres the code:

Code:
#include <stdio.h>
#include <GL/glut.h>
#include <GL/glu.h>
#include <GL/gl.h>

int g_mainWindow;		/* global identifier for the main window */

void initGL&#40;int, int, int*, char**&#41;;
int createMainWindow&#40;int, int, char*&#41;;
void RenderScene&#40;&#41;;

int main&#40;int argc, char **argv&#41;
&#123;
	initGL&#40;800, 600, &argc, argv&#41;;
	
	g_mainWindow = createMainWindow&#40;800, 600, "Final Doom&#58; The Connect4 Saga..."&#41;;
	printf&#40;"Window created, g_mainWindow = %d\n", g_mainWindow&#41;;

	glutShowWindow&#40;&#41;;
	
	while&#40;1&#41;
		RenderScene&#40;&#41;;

	printf&#40;"Render scene called\n"&#41;;
	
	getchar&#40;&#41;;

	glutDestroyWindow&#40;g_mainWindow&#41;;
	return 0;
&#125;

void initGL&#40;int width, int height, int *argc, char **argv&#41;
&#123;
	glutInitWindowSize&#40;width, height&#41;;
	glutInitWindowPosition&#40;0, 0&#41;;

	glutInit&#40;argc, argv&#41;;
	glutInitDisplayMode&#40;GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH&#41;;
	glEnable&#40;GL_DEPTH_TEST&#41;;
	glDepthMask&#40;GL_TRUE&#41;;
	/* init with double buffer and rgba flags for animation */

	return;
&#125;

int createMainWindow&#40;int width, int height, char *windowName&#41;
&#123;
	int win;

	win = glutCreateWindow&#40;windowName&#41;;
	glutSetWindow&#40;win&#41;;

	glViewport&#40;0, 0, width, height&#41;;
	glMatrixMode&#40;GL_PROJECTION&#41;;
	glLoadIdentity&#40;&#41;;

	gluPerspective&#40;45.0f,&#40;GLfloat&#41;width/&#40;GLfloat&#41;height, 1 ,150.0f&#41;;

	glMatrixMode&#40;GL_MODELVIEW&#41;;
	glLoadIdentity&#40;&#41;;

	return win;
&#125;


void drawToken&#40;GLUquadricObj *pToken&#41;
&#123;

	glPushMatrix&#40;&#41;;
		glTranslatef&#40;0,0,0.1f&#41;;
		glColor3ub&#40;0, 255, 0&#41;;
		gluDisk&#40;pToken, 0, 1, 40, 4&#41;;
		glPopMatrix&#40;&#41;;

	glColor3ub&#40;255, 255, 0&#41;;
	gluDisk&#40;pToken, 0, 1, 40, 4&#41;;
	
	gluCylinder&#40;pToken, 1, 1, 0.1f, 40, 2&#41;;

	return;
&#125;


void RenderScene&#40;&#41;
&#123;
	static float theta = 0.0f;

	glClear&#40;GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT&#41;;

	glLoadIdentity&#40;&#41;;

	gluLookAt&#40;	0,0,6,		/* position */
			0,0,0,		/* view */
			0,1,0&#41;;		/* up vector */

	
	GLUquadricObj *pToken = gluNewQuadric&#40;&#41;;
	gluQuadricTexture&#40;pToken, GL_FALSE&#41;;

	gluQuadricDrawStyle&#40;pToken, GLU_FILL&#41;;


	glPushMatrix&#40;&#41;;
		glTranslatef&#40;-1.5f, 0, 0&#41;;
		glRotatef&#40;theta, 0.0f, 1.0f, 0.0f&#41;;
		drawToken&#40;pToken&#41;;
		glPopMatrix&#40;&#41;;

	glPushMatrix&#40;&#41;;
		glTranslatef&#40;1.5f, 0, 0&#41;;
		glRotatef&#40;theta, 0.0f, 1.0f, 0.0f&#41;;
		drawToken&#40;pToken&#41;;
		glPopMatrix&#40;&#41;;

	glutSwapBuffers&#40;&#41;;

	gluDeleteQuadric&#40;pToken&#41;;

	theta += 1.0f;
	return;
&#125;
basically it draws two spinning tokens, which should each have a yellow side and a green side.
but, because the yellow disc is drawn last, it is allways in front of the green one, even though it should be behind at times.

any help would be greatly appreciated