I'm trying to generate a texture with QImage
and QOpenGLTexture
.
I've set the QImage
color format to RGBA8888
, and set color with setPixel
, but it seems like no matter how I change the alpha value, it remains to 255, and the transparency of the picture will never change.
Here's my code:
QImage texPic(width, height, QImage::Format_RGBA8888);
texPic.setPixel(0, 0, qRgba(255,0,0,0));
texPic.setPixel(0, 1, qRgba(0,255,0,100));
QOpenGLTexture *texture = new QOpenGLTexture(texPic);
Any suggestions?
I've found the problem, it's not from the setting of texture itself. It because I didn't get the gl functions setting right. I added
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
And now it worked.