Get familiar with OpenGL ES on the iPhone.
The iPhone SDK's OpenGL ES example is an excellent starting point.
Study texture mapping. Once you are familiar with glTexImage2D, use that to load your image.
The example can be easily extended with the following:
have these defines:
GLuint spriteTexture;
GLubyte *spriteData; // the perlin noise will be here
size_t width, height;
then in the ESRenderer init method create space for the texture:
- (id) init { ....
width = 512; // make sure the texture size is the power of 2
height = 512;
glGenTextures(1, &spriteTexture);
glBindTexture(GL_TEXTURE_2D, spriteTexture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, spriteData);
//free(spriteData); // free this if not used any more
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
In case the noise is periodically updated, update the texture in the render method
- (void) render { .....
glBindTexture(GL_TEXTURE_2D, spriteTexture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, spriteData);