Thanks to Reed Copsi for pointing me to glTexImage2D . It turns out that it is very simple; just pass the GLubyte array to the glTexImage2D function (as well as all the functions needed to bind the texture, etc.). Did not try this exact piece of code, but it should work fine. Array elements are a sequential version of rows, columns, and pipes.
int pixelIndex = 0; GLubyte pixels[400]; for (int x = 0; x < 10; x++) { for (int y = 0; y < 10; x++) { for (int channel = 0; channel < 4; channel++) {
I read in an OpenGL book you can use a 2D array for monochrome images, so I assume you can also use a 3D array.
source share