Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. Cubemap texture with QOpenglTexture class.
QtWS25 Last Chance

Cubemap texture with QOpenglTexture class.

Scheduled Pinned Locked Moved Game Development
qopengltexturecube map
1 Posts 1 Posters 3.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jjjj
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved