Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved OpenGL Image Load/Store using Qt 5.7?

    General and Desktop
    qt5 opengl shader qt5.7 image
    1
    1
    836
    Loading More Posts
    • 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.
    • otah007
      otah007 last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • First post
        Last post