QOpenGLTexture (Qt)从原始数据(freeimage)
QOpenGLTexture (Qt) from raw data (freeimage)
我一直在使用旧的Qt OpenGl方法,但现在是时候切换到较新的方法了。
是位图一个FIBITMAP*正确初始化
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height,0,GL_BGRA GL_UNSIGNED_BYTE (void *) FreeImage_GetBits (pImage));
对我来说很有吸引力。
但是现在在较新的方法中,更倾向于使用QOpenGLTexture
不幸的是,我的尝试没有成功。
QOpenGLTexture*qtexture = newQOpenGLTexture (QOpenGLTexture:: Target2D);
纹理-> setData (QOpenGLTexture:: PixelFormat:: RGBA,QOpenGLTexture:: PixelType:: Int8 FreeImage_GetBits(位图));
代码返回1x1纹理但如果我使用
强制大小qtexture setSize ->(宽度、高度,4);
qtexture有适当的大小,但它完全是黑色的,我也试图在Qt/Freeimage论坛等搜索,但没有相关的不幸的是,每个人都使用QImage来喂养QOpenGLTexture,但不幸的是,我需要支持一些"奇怪"的文件格式,如。hdr或。exr,不支持Qt本身。
提前感谢您的时间!
对于QOpenGLTexture
,必须在allocateStorage
之前设置Size
、Format
。最后一步是setData
。
QOpenGLTexture *text = new QOpenGLTexture(QOpenGLTexture::Target2D);
text->setMinMagFilters(QOpenGLTexture::Linear, QOpenGLTexture::Linear);
text->create();
// given some `width`, `height` and `data_ptr`
text->setSize(width, height, 1);
text->setFormat(QOpenGLTexture::RGBA8_UNorm);
text->allocateStorage();
text->setData(QOpenGLTexture::Red, QOpenGLTexture::UInt8, data_ptr);
qtexture -> allocateStorage ();
是关键!
- C++:将值赋值给原始数据类型(例如布尔值)是原子操作吗?
- 从USBPcap库读取原始数据
- BoostSpirit.Qi-针对原始数据类型进行边界检查
- Qt - 将空指针(原始数据)转换为 QImage 并将其显示在标签上
- 使用 QDataStream 对原始数据进行反序列化
- 当原始数据是常量时,修改指针指向的位置是 UB 吗?
- IMAGE_SECTION_HEADER的虚拟地址和指针到原始数据的差异
- 直接从 RAM 发送原始数据
- MEX C++原始数据访问
- 服务器客户端通过原始数据错误C 发送接收结构
- 如何从C 中的卷曲中获取原始数据
- 在C/C 中创建和发送原始数据包
- 如何捕获麦克风缓冲区原始数据
- 用原始数据填充 std::vector
- opencv::Mat,从原始数据中获取像素值
- 使用 Qt 通过蓝牙发送多个原始数据包
- 将sqlite原始数据读取到qbyTearray
- 矢量调整大小抛出bad_alloc会使原始数据无效
- 从原始数据就地创建 std::vector
- QOpenGLTexture (Qt)从原始数据(freeimage)