Qt can not use opengl profile
-
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 profileMy 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
-
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 profileMy 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
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