Load single color channel to OpenGL texture
Posted: 2010-06-22T05:10:40-07:00
To load all channels I'm doing this:
Loading single channel should look like this:
Bu it works only for red channel, if I try same with green or blue channel I'm getting black image.
Is this the right way to do it?
Code: Select all
im.read(filename);
im.write(&blob, "RGB", 8);
glTexImage2D(GL_TEXTURE_2D, 0, 3, im.columns(), im.rows(), 0, GL_RGB, GL_UNSIGNED_BYTE, blob.data());
Code: Select all
im.read(filename);
im.write(&blob, "R", 8);
glTexImage2D(GL_TEXTURE_2D, 0, 1, im.columns(), im.rows(), 0, GL_RED, GL_UNSIGNED_BYTE, blob.data());
Code: Select all
im.read(filename);
im.write(&blob, "G", 8);
glTexImage2D(GL_TEXTURE_2D, 0, 1, im.columns(), im.rows(), 0, GL_GREEN, GL_UNSIGNED_BYTE, blob.data());