【问题标题】:How to create a texture with alpha in QOpenGLTexture?如何在 QOpenGLTexture 中创建带 alpha 的纹理?
【发布时间】:2016-10-22 01:01:57
【问题描述】:

我正在尝试使用QImageQOpenGLTexture 生成纹理。 我已经将QImage颜色格式设置为RGBA8888,并用setPixel设置颜色,但似乎无论我如何更改alpha值,它仍然是255,并且图片的透明度永远不会改变.

这是我的代码:

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);

有什么建议吗?

【问题讨论】:

  • 谢谢回复,我已经解决了,好像是gl功能设置的问题。

标签: c++ qt opengl-es-2.0 qtopengl


【解决方案1】:

我发现了问题,不是纹理本身的设置。 这是因为我没有正确设置 gl 函数。 我加了

glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);

现在它起作用了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-05-19
    • 2018-04-02
    • 1970-01-01
    • 2010-10-30
    • 1970-01-01
    • 2013-01-01
    • 2012-02-22
    相关资源
    最近更新 更多