Okay, I will write a more in depth tutorial later (probably with the GameModel class that I wrote) but I’m currently in Uganda, Africa (for about 6 mos) and net access is a bit spotty so here are a few hints to maybe get those of you who are having trouble started:

Again, my usual disclaimer: I am not an expert, I learned this as I wrote StarSmasher so I can’t promise anything I do is the best way to do it, and as always if you know a better way please let me/everyone know.

My draw script does the following (keep in mind this is part of a class so it refers to self and member data of the class but I think it should be fairly self explanatory):

	//Check that this model isn't already loaded, we don't need to unnecessarily load it.
	if (lastModel != self) {
		//Loads the vertex array into OpenGL ES:
		glVertexPointer(3, GL_FLOAT, 0, facesArray);
		if (hasTexCoords) {
			glBindTexture(GL_TEXTURE_2D, texture[0]); //texture[0] is an OpenGL texture id, loaded by my class during its init method.
			glTexCoordPointer(2, GL_FLOAT, 0, textureCoordsArray);
		}
		lastModel = self;
	}
	//Draw the model:
	glDrawArrays(GL_TRIANGLES, 0, facesCount*3);

Posted on October 17th, 2008 | filed under code::, tutorial | Trackback |

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>