OpenGL Image Load/Store using Qt 5.7?



  • I'm trying to port some code across from a non-Qt project to Qt and I can't get image load/store to work. I've created my texture and bound it to the shaders, but it doesn't seem to be reading the data - all I get is a black screen, which means the values are all 0. Is there any Qt-native way to use image load/store, and if not how do I use standard OpenGL functions to make it work with Qt shader programs?

    float* data = new float[IMAGE_WIDTH * IMAGE_HEIGHT];
    for (int i = 0; i < IMAGE_WIDTH * IMAGE_HEIGHT; ++i)
    	data[i] = float(i) / float(IMAGE_WIDTH * IMAGE_HEIGHT);
    
    GLuint tex[1];
    glGenTextures(1, tex);
    glBindTexture(GL_TEXTURE_2D, tex[0]);
    glTexStorage2D(GL_TEXTURE_2D, 1, GL_R32F, IMAGE_WIDTH, IMAGE_HEIGHT);
    glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, IMAGE_WIDTH, IMAGE_HEIGHT, GL_RED, GL_FLOAT, data);
    
    delete[] data;
    
    m_program->bind();
    glBindImageTexture(0, tex[0], 0, GL_FALSE, 0, GL_READ_WRITE, GL_R32F);
    m_program->release();
    
    m_compute->bind();
    glBindImageTexture(0, tex[0], 0, GL_FALSE, 0, GL_READ_WRITE, GL_R32F);
    m_compute->release();
    

    The shaders definitely work as they are identical to the ones used in the non-Qt project. However I'm not sure if this is the correct way to bind the image using Qt:

    // Image from image load/store
    layout (binding = 0, r32f) uniform image2D pixels;
    

    Any help would be very much appreciated.



Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.