Cubemap texture with QOpenglTexture class.
-
Hi,
I'm having some problems with the QOpenglTexture class in Linux platform.
I'm doing environment mapping with a cube map texture using Qt OpenGL classes.
The following code shows both methods: Qt classes and "pure" OpenGL functions.
In OSX both of them work correctly, but in Linux only the "pure" OpenGL functions works.// glGenTextures(1, &textureGL); // glBindTexture(GL_TEXTURE_CUBE_MAP, textureGL); // glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, (void*) x.bits()); // glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, (void*) y.bits()); // glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, (void*) z.bits()); // glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, (void*) _x.bits()); // glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, (void*) _y.bits()); // glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, (void*) _z.bits()); // glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); texture = new QOpenGLTexture(QOpenGLTexture::TargetCubeMap); texture->create(); texture->bind(); texture->setSize(256, 256); texture->setFormat(QOpenGLTexture::RGBAFormat); texture->allocateStorage(); texture->setMinMagFilters(QOpenGLTexture::Linear, QOpenGLTexture::Linear); texture->setData(0, 0, QOpenGLTexture::CubeMapPositiveX, QOpenGLTexture::RGBA, QOpenGLTexture::UInt8, (void*) x.bits()); texture->setData(0, 0, QOpenGLTexture::CubeMapPositiveY, QOpenGLTexture::RGBA, QOpenGLTexture::UInt8, (void*) y.bits()); texture->setData(0, 0, QOpenGLTexture::CubeMapPositiveZ, QOpenGLTexture::RGBA, QOpenGLTexture::UInt8, (void*) z.bits()); texture->setData(0, 0, QOpenGLTexture::CubeMapNegativeX, QOpenGLTexture::RGBA, QOpenGLTexture::UInt8, (void*) _x.bits()); texture->setData(0, 0, QOpenGLTexture::CubeMapNegativeY, QOpenGLTexture::RGBA, QOpenGLTexture::UInt8, (void*) _y.bits()); texture->setData(0, 0, QOpenGLTexture::CubeMapNegativeZ, QOpenGLTexture::RGBA, QOpenGLTexture::UInt8, (void*) _z.bits());
And the corresponding bindings in the draw function:
// glBindTexture(GL_TEXTURE_CUBE_MAP, textureGL); texture->bind();
The variables x,y,z,_x,_y,_z are the RGBSwapped Qimages for the six faces of the cube.
texture is QopenglTexture pointer.
textureGL is GLuint.The rest of the setup is correct because the pure Opengl aproach work in OSX and Linux.
The only problem is the QOpenglTexture aproach on Linux.I think that something is missing in the Qopengltexture aproach but I can't realize what is.
Thanks
jjj