I’m a newbie and trying to display a sprite on my iPhone screen using OpenGL ES.
I know its far simpler and easier to do it with cocos2d but now I’m trying to code directly on OpenGL.
Is there any simple yet efficient way to load and display sprites in OpenGL ES. What I’ve found until now is much much complex. 🙁
I’m a newbie and trying to display a sprite on my iPhone screen using
Share
Here is some code to load a png from bundle:
Here is some code to create a texture with that image data.
And an example of how to render this:
Here you need to find the values of vertices, normals and textureCoords that fit your needs.
Update 1
Remember to set the right states like this:
If you use
glOrthof(See below) to set a 2D projection in your app, you can use these values:Update 2
This is how I sat the projection mode when using the above code to render sprites:
And this is how i set my blending function. This allows for transparency in the png files: