I had assumed that if I draw an object, then translate, then draw the next object based on their stored local positions they would be drawn at their respective distances.
Any hints? I know I probably seem completely ignorant but I'm going out of my mind with the repeated suggestions of gluLookAt which I cannot use due to the lack of glut on the platform I'm working in.
Greatly appreciate any guidance.
overall DRAWVIEW call
[EAGLContext setCurrentContext:context]; glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClearDepthf(1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnableClientState(GL_VERTEX_ARRAY); GLfloat triVertices[40*3*2]; // draw static grid as background int index = 0; int lCount = 0; for ( float i = -0.8f; i <= 0.9f; i += 0.1f) { triVertices[index] = -0.9f; triVertices[index + 1] = i; triVertices[index + 2] = 0.0f; triVertices[index + 3] = 0.9f; triVertices[index + 4] = i; triVertices[index + 5] = 0.0f; triVertices[index + 6] = i; triVertices[index + 7] = -0.9f; triVertices[index + 8] = 0.0f; triVertices[index + 9] = i; triVertices[index + 10] = 0.9f; triVertices[index + 11] = 0.0f; index += 12; lCount += 4; } glVertexPointer(3, GL_FLOAT, 0, triVertices); glDrawArrays(GL_LINES, 0, lCount); // draw 3D objects glEnable(GL_DEPTH_TEST); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glFrustumf(-1.6f, 1.6, -2.4, 2.4, -10, 10); glMatrixMode(GL_MODELVIEW); // enable GL states for textures glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); // cubes have slightly transparent texture glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); [self drawCubes]; glDisable(GL_BLEND); // draw buttons glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrthof(-1.0f, 1.0f, -1.5f, 1.5f, -10.0f, 10.0f); glMatrixMode(GL_MODELVIEW); glEnable(GL_BLEND); // buttons are one texture with transparent center glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); [self drawButtons]; glDisable(GL_BLEND); //disable GL states for texturing glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisable(GL_TEXTURE_2D); glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); [context presentRenderbuffer:GL_RENDERBUFFER_OES];
drawCubes
{ const GLfloat cubeTexCoords[8] = { 1, 0, 1, 1, 0, 0, 0, 1, }; glBindTexture(GL_TEXTURE_2D, texture[0]); glPushMatrix(); glLoadIdentity(); //glTranslatef( playerShape.x, playerShape.y, playerShape.z ); this seems to be causing problems, perhaps done in wrong order glScalef(kCubeScale, kCubeScale, kCubeScale); glTexCoordPointer(2, GL_FLOAT, 0, cubeTexCoords); for (int f = 0; f < playerShape.num_outer_sides/12; f++) { //glColor4f(cubeColors[f%6][0], cubeColors[f%6][1], cubeColors[f%6][2], cubeColors[f%6][3]); glColor4f(cubeColors[1][0], cubeColors[1][1], cubeColors[1][2], cubeColors[1][3]); glVertexPointer(3, GL_FLOAT, 0, cubeVertices[f]); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); } glPopMatrix(); glBindTexture(GL_TEXTURE_2D, 0);}
[Edited by - Zmaker5 on October 10, 2010 5:12:35 PM]