Advertisement

glTexImage2D

Started by December 08, 2022 11:09 AM
1 comment, last by cgrant 2 years, 3 months ago

Hi

how to set image alpha value as below?

Many thanks

const void* pixels = image.pixels.empty() ? NULL : &image.pixels[0];

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image.width, image.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);

The array containing the image data is what needs to get modified to set the image color values, whether is be R,G,B or A. The call to glTexImage2D does not set the value, all that does is supply the data to OpenGL to create the actual GPU texture resource from. Assuming you created the image somehow( loaded from file, procedural etc), given the layout of the data, then it is as simple a changing byte for each image pixel.

This topic is closed to new replies.

Advertisement