tags:

views:

31

answers:

1

I would like to copy an array of pixel data (colors) into a texture. Please could someone point me in the right direction? I have looked on google but all of the tutorials are for OpenGL, rather than OpenGL ES. Thanks :)

A: 

It’s about the same as in OpenGL:

  1. create the texture object in OpenGL ES:
    glGenTextures(1, &textureID);
  2. bind the texture object:
    glBindTexture(GL_TEXTURE_2D, textureID);
  3. upload texture data (from your c array):
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixeldata);

After that you can applay the texture to your geometry. Of course, the texture has to have the right dimensions (power of 2, square), pixel format and so on.

Nikolai Ruhe