Get to know OpenGL ES on iPhone. The OpenGL ES iPhone SDK example is a great starting point. Learn texture mapping. When you are familiar with glTexImage2D, use this to upload an image.
An example can be easily expanded as follows:
have the following meanings:
GLuint spriteTexture; GLubyte *spriteData;
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);
If the noise periodically updates, update the texture in the rendering method
- (void) render { ..... glBindTexture(GL_TEXTURE_2D, spriteTexture); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, spriteData);