Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt can not use opengl profile

Qt can not use opengl profile

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 1.1k 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.
  • S Offline
    S Offline
    Samuel Ives
    wrote on last edited by
    #1

    I built the qt from the source without the angle, in my opengl widget I configured it to the following profile:

        QSurfaceFormat format;
        format.setVersion(4, 3);
        format.setProfile(QSurfaceFormat::CoreProfile);
        format.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
    
        setFormat(format);
    

    First of all I'm using glew, hey my compile code for shaders:

    GLuint GLEngine::createShader(GLenum shaderType, const std::string &shaderSource)
    {
    
        //Parse shader type
        GLuint shader = glCreateShader(shaderType);
    
        const GLchar *source = shaderSource.c_str();
        int sourceLength = shaderSource.length();
    
        //Parse shader source
        glShaderSource(shader, 1, &source, &sourceLength);
        //Compile the shader
        glCompileShader(shader);
    
        //Check shader compilation
        GLint sucess;
        glGetShaderiv(shader, GL_COMPILE_STATUS, &sucess);
    
        if(sucess != GL_TRUE){
    
            int logLength;
            glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &logLength);
            char *logInfo = (char*)malloc(logLength);
    
            //Get shader compiler log
            glGetShaderInfoLog(shader, logLength, &logLength, logInfo);
    
            qCritical() << "Could not compile shader: " << logInfo;
    
            free(logInfo);
            glDeleteShader(shader);
    
            return 0;
        }
    
        return shader;
    }
    

    However I get the following error from my vertex shader:

    Could not compile shader: 0(3) : error C7548: 'layout(location)' requires "#extension GL_ARB_separate_shader_objects : enable" before use
    0(3) : error C0000: ... or #version 410
    0(6) : error C5052: gl_Position is not accessible in this profile

    My shader:

    #version 330 core
    
    layout(location=0) in vec4 position;
    
    void main(){
        gl_Position = position;
    }
    

    I thought setting the opengl version and profile would be enough to use opengl in my application, but it does not seem like all I have to do to work

    A 1 Reply Last reply
    0
    • S Samuel Ives

      I built the qt from the source without the angle, in my opengl widget I configured it to the following profile:

          QSurfaceFormat format;
          format.setVersion(4, 3);
          format.setProfile(QSurfaceFormat::CoreProfile);
          format.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
      
          setFormat(format);
      

      First of all I'm using glew, hey my compile code for shaders:

      GLuint GLEngine::createShader(GLenum shaderType, const std::string &shaderSource)
      {
      
          //Parse shader type
          GLuint shader = glCreateShader(shaderType);
      
          const GLchar *source = shaderSource.c_str();
          int sourceLength = shaderSource.length();
      
          //Parse shader source
          glShaderSource(shader, 1, &source, &sourceLength);
          //Compile the shader
          glCompileShader(shader);
      
          //Check shader compilation
          GLint sucess;
          glGetShaderiv(shader, GL_COMPILE_STATUS, &sucess);
      
          if(sucess != GL_TRUE){
      
              int logLength;
              glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &logLength);
              char *logInfo = (char*)malloc(logLength);
      
              //Get shader compiler log
              glGetShaderInfoLog(shader, logLength, &logLength, logInfo);
      
              qCritical() << "Could not compile shader: " << logInfo;
      
              free(logInfo);
              glDeleteShader(shader);
      
              return 0;
          }
      
          return shader;
      }
      

      However I get the following error from my vertex shader:

      Could not compile shader: 0(3) : error C7548: 'layout(location)' requires "#extension GL_ARB_separate_shader_objects : enable" before use
      0(3) : error C0000: ... or #version 410
      0(6) : error C5052: gl_Position is not accessible in this profile

      My shader:

      #version 330 core
      
      layout(location=0) in vec4 position;
      
      void main(){
          gl_Position = position;
      }
      

      I thought setting the opengl version and profile would be enough to use opengl in my application, but it does not seem like all I have to do to work

      A Offline
      A Offline
      Alain38 0
      wrote on last edited by
      #2

      Hi @Samuel-Ives ,
      The problem does not comes from Qt. It comes froms your shader source. On the Qt side, i.e. the PC, you have specified that your are using OpenGL 4.3. But, in the shader code, that is for the GPU, you have specified that the code is in OpenGL 3.3. (pragma #version 330 core). And you try to use functionalities introduced in OpenGL4.1. Replace 330 by 410 as suggested by the compiler error

      1 Reply Last reply
      2

      • Login

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