wonza
10-11-2008, 11:50 AM
Im attempting to get the HUD working for my game, but Im hitting some problems with setting the depth and a few other things. I think really Im getting confused as to what order to put things in etc. Ill post some of my current code which should help explain what Im currently doing and what I need to do.
Setup code:
// Sets up matrices and transforms for OpenGL ES
glEnable(GL_DEPTH_TEST);
glEnable(GL_NORMALIZE);
glMatrixMode(GL_PROJECTION);
glFrustumf(-1.0f, 1.0f, -1.5f, 1.5f, zNear, zFar);
glViewport(0, 0, backingWidth, backingHeight);
glMatrixMode(GL_MODELVIEW);
Draw loop:
[EAGLContext setCurrentContext:context];
glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
customCamera();
shipLoop();
missileLoop();
starLoop();
glFlush ();
glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
[context presentRenderbuffer:GL_RENDERBUFFER_OES];
So to get the HUD working in my draw loop ive tried to disable the depth test after the call to startLoop() function and then drawing some 2d triangles for the HUD... I then enabled depth testing again right before the customeCamera() function. This just doesnt seem to have any affect and Im kind flying blind with it I think. Any advice is greatly appreciated! Thanks!
Setup code:
// Sets up matrices and transforms for OpenGL ES
glEnable(GL_DEPTH_TEST);
glEnable(GL_NORMALIZE);
glMatrixMode(GL_PROJECTION);
glFrustumf(-1.0f, 1.0f, -1.5f, 1.5f, zNear, zFar);
glViewport(0, 0, backingWidth, backingHeight);
glMatrixMode(GL_MODELVIEW);
Draw loop:
[EAGLContext setCurrentContext:context];
glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
customCamera();
shipLoop();
missileLoop();
starLoop();
glFlush ();
glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
[context presentRenderbuffer:GL_RENDERBUFFER_OES];
So to get the HUD working in my draw loop ive tried to disable the depth test after the call to startLoop() function and then drawing some 2d triangles for the HUD... I then enabled depth testing again right before the customeCamera() function. This just doesnt seem to have any affect and Im kind flying blind with it I think. Any advice is greatly appreciated! Thanks!