QOpenGLTexture

来源:互联网 发布:群智能算法论文 编辑:程序博客网 时间:2024/06/11 14:39
1Here'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 have found the problem, it's not from the setting of texture itself.It because I didn't get the gl functions setting right.I addedglBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);glEnable(GL_BLEND);And now it worked.2  Qt 5 with QOpenGLTexture and 16 bits integers imagesTo be clear, here is the corrected code:QOpenGLTexture *oglt = new QOpenGLTexture(QOpenGLTexture::Target2D);oglt->setMinificationFilter(QOpenGLTexture::NearestMipMapNearest);oglt->setMagnificationFilter(QOpenGLTexture::Nearest);//oglt->setFormat(QOpenGLTexture::RGB32F); // worksoglt->setFormat(QOpenGLTexture::RGB16U); // now works with integer images (unsigned)oglt->setSize(naxis1, naxis2);//oglt->allocateStorage(QOpenGLTexture::RGB, QOpenGLTexture::Float32); // works//oglt->setData(QOpenGLTexture::RGB, QOpenGLTexture::Float32, tempImageRGB.data); // worksoglt->allocateStorage(QOpenGLTexture::RGB_Integer, QOpenGLTexture::UInt16); // now works with integer images (unsigned)oglt->setData(QOpenGLTexture::RGB_Integer, QOpenGLTexture::UInt16, tempImageRGB.data); // now works with integer images (unsigned)3QOpenGLTexture*qtexture = new QOpenGLTexture(QOpenGLTexture::Target2D);qtexture->setData(QOpenGLTexture::PixelFormat::RGBA, QOpenGLTexture::PixelType::Int8,FreeImage_GetBits(bitmap));qtexture->allocateStorage();   // was the key!4 QOpenGLTexture Class   http://doc.qt.io/qt-5/qopengltexture.html#details

see Public Functions

..................5 http://doc.qt.io/qt-5/qtopengl-textures-example.html