I'm running on XCode and using OpenGL ES 1.1 and I have two classes one that is textured and the other one is just triangles with color data and they render fine until I render my textured triangles that work but then the others also become textured with odd parts of my sprite atlas and they dont have any texture coord's at all
-(void) renderWithUpdate {
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//Translate
glTranslatef(tranlation.x, tranlation.y, tranlation.z);
//Scale
glScalef(scale.x, scale.y, scale.z);
//Rotate
glRotatef( angleGeo, 1.0, 1.0, 0.0);
angleGeo = angleGeo + 0.5;
//NSLog(@"Rotation Angle:%F", (float)angleGeo );
glVertexPointer(vertexSize, GL_FLOAT, 0, self.vertexes );
glEnableClientState(GL_VERTEX_ARRAY);
glColorPointer(4, GL_FLOAT, 0, self.colors);
glEnableClientState(GL_COLOR_ARRAY);
//Render with Texturing
if (materialKey != nil) {
[[MaterialController sharedMaterialController] bindMaterial:materialKey];
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 0, uvCoordinates);
}
//Render
glDrawArrays( renderStyle, 0, self.vertexCount);
}
and if I disable texture corded arrays in their rendering method they vanish completly all wile my textured objets work fine
is it something to do with glEnable(GL_TEXTURE_2D)
?
After rendering the textured objects you have to disable texturing by calling
glDisable(GL_TEXTURE_2D)
(I guess yourMaterialController
'sbindMaterial
method callsglEnable(GL_TEXTURE_2D)
). Just disabling the texture coordinate array (withglDisableClientState(GL_TEXTURE_COORD_ARRAY)
) is not enough (though you should do this, too, after rendering the textured geometry):Always keep in mind, that OpenGL is a state machine and every state you change (like enabling texturing) keeps its value until you change it again. So you should always be aware what parts of your application change what OpenGL states (like the
bindMaterial
method) and set every state you need immediately before rendering.