[Solved] Deploy OpenGL shader app in older computers
-
If one sucessfully compiles a OpenGL 3.x or 4.x project and tries do deploy it to old PC's with grafic cards that doenst support advanced OpenGL versions what happens ? The program will fail or it will fallback to software rendering (slower) ? Or it depends on the driver ?
-
It will fail. Your application should check the version of the OpenGL context that was actually created and provide alternative rendering approaches or at least inform the user gracefully. See QOpenGLContext::format() and QSurfaceFormat for more info.
The software renderer on Windows is OpenGL 1.1 only. On Linux/Mac you will likely get newer than that but never OpenGL 4 in software afaik.
-
Thanks for answering ZapB.
I just tested this example "http://qt-project.org/wiki/How_to_use_OpenGL_Core_Profile_with_Qt":http://qt-project.org/wiki/How_to_use_OpenGL_Core_Profile_with_Qt (wich I believe you wrote it :) ) in my Wetab that has OpenGL 1.5 hardware support, with an ubuntu based distro. In fact it fails miserably@X Error: BadRequest (invalid request code or no such operation) 1
Extension: 153 (Uknown extension)
Minor opcode: 34 (Unknown request)
Resource id: 0x1a00005
Could not enable sample buffers
QGLShader::compile(Vertex): 0:1(10): error: GLSL 3.30 is not supported. Supported versions are: 1.00 ES, 1.10, and 1.20"0:1(10): error: GLSL 3.30 is not supported. Supported versions are: 1.00 ES, 1.10, and 1.20
"
QGLShader::compile(Fragment): 0:1(10): error: GLSL 3.30 is not supported. Supported versions are: 1.00 ES, 1.10, and 1.200:6(8): error: unrecognized layout identifier `location'
"0:1(10): error: GLSL 3.30 is not supported. Supported versions are: 1.00 ES, 1.10, and 1.20
0:6(8): error: unrecognized layout identifier `location'
" @But then again, with some minor changes to the shaders:
@void main(void)
{
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
}@@attribute vec4 vertex;
void main(void)
{
gl_Position = vertex;
}@and adding a default empty constructor to GLWidget, and initialising variable w without glFormat, it works beatifull without errors, displaint that red triangle.
So now I'm confused, I'm using a shaders program, don't know what version, on a OpenGL hardware 1.5 version, so for sure it must be falling back to software rendering ? Also someone knows a similar program to OpenGL Extensions Viewer, for linux, to check OpenGL hardware capabilities ?
-
According to http://en.wikipedia.org/wiki/GLSL#Versions GLSL version 1.2 corresponds to OpenGL 2.1.
So apparently your hardware does support programmable shaders. The small chanegs you made are to adapt to the GLSL 1.2 syntax. It is not uncommon to ship several shader versions for different versions of GLSL/OpenGL or different rendering techniques and then to choose between them at runtime depending upon what your system supports.
-
To see which versions your system supports take a look at http://qt-project.org/doc/qt-5.0/qtopengl/qglformat.html#openGLVersionFlags
Alternatively request an OpenGL 4.3 context and see what you actually get back. That should be the maximum supported version.
For extensions, see QOpenGLContext::extensions() http://qt-project.org/doc/qt-5.0/qtgui/qopenglcontext.html#extensions
Hope this helps.
-
Thanks for your answer, I beggining to see the light. Just another question, regarding Windows, what's the deal with Glee and Glew libraries? I have read about them, but not sure if I really understood what they do under the wood. I guess they are just libraries that, because OpenGL is frozen in Windows to 1.1, implement the recent versions, and I guess I wont be needing them has long I use Qt OpenGL, only if I go with native OpenGL, right ?
-
Right, Glee and GLEW basically do the equivalent of this:
@
foreach(OpenGL Version) {
foreach(OpenGL Function in Version)
function = QOpenGLContext::getProcAddress(functionName)
}foreach(OpenGLExtension) {
foreach(OpenGL Function in Extension)
extensionFunction = QOpenGLContext::getProcAddress(extensionFunctionName)
}
@The Qt OpenGL classes do this function pointer resolution for you for the functions that they use. However if you wish to use the latest OpenGL 3/4 features then you will need to resolve those functions yourself - for now.
I hope to get functionality included in Qt 5.1 that does the equivalent of Glee/GLEW. See https://codereview.qt-project.org/#change,35408 for example.