View Full Version : QT4.7 & QGLFormat::CoreProfile & shaders

18th December 2010, 12:22
QT 4.7 on Linux, video card nvidia GTX 460 with OpenGl 4.1 support.
if I set QGLFormat to CoreProfile and request version above 3.1 (i.e format.setVersion(3.2), format.setVersion(4.1)) shaders fails to compile.
I think shader below confirm OpenGl 4.1 standard specification
"in vec4 vrtx;\n"
"void main(void)\n"
"gl_Position = vrtx;\n"
"gl_PointSize = 2;\n"
but even this simple shader compilation fails. If i set profile to CompatibilityProfile, or set version below 3.2 it compiles fine.
As I want to use latest core, I'll appreciate any advice on where to look to solve the matter.



24th December 2010, 12:17
In addition to the above :
format.setVersion(4, 1);
QGLFormat::hasOpenGL() - returns true
this->context()->isValid() - returns true

Next checkind for support of Vertex shader:
shader->hasOpenGLShaders(QGLShader::Vertex, context()) - returns FALSE.

~> glxinfo | grep vendor returns:
server glx vendor string: NVIDIA Corporation
client glx vendor string: NVIDIA Corporation
OpenGL vendor string: NVIDIA Corporation

~> glxinfo | grep render:
direct rendering: Yes
OpenGL renderer string: GeForce GTX 460/PCI/SSE2

~> glxinfo | grep Open
OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: GeForce GTX 460/PCI/SSE2
OpenGL version string: 4.1.0 NVIDIA 260.19.29
OpenGL extensions:

So, I'm totally confused how with valid context and OpenGL 4.1 support I do not have support even for Vertex shader?

27th December 2010, 00:15
I have the same problem. So i stay with CompabilityProfile. You can look on a working example from this post (http://www.qtcentre.org/threads/37314-An-example-of-triangle-in-opengl-4.1-with-vertex-buffer-object-and-simplest-shaders). I just provide in shader itself a #version 410 core. ( Any number representing a version of the language a compiler does not support will cause an error to be generated.) When i switched to CoreProfile in Format i get vertex errors and nothing on screen. Now I'm looking why, and checking how opengl is made in qt.

27th December 2010, 23:04
In QT 4.7 qgl.h OpenGLVersionFlag defined up to v. 4.0. With gl3w https://github.com/skaslev/gl3w I was able to set 4.1 core profile, shaders compile fine, but I'm getting: warning C7568: #version 410 not fully supported on current GPU target profile. That's possible that QT has the same bug as glew:
glGetString(GL_EXTENSIONS) being deprecated, an error is generated, no extension is returned and then GLEW fails to initialize. So currently, it’s not recommended to use GLEW with a core profile context. - I havn't check this, but their approach to wrapping opengl looks similar.