Trusted Software Excellence across Desktop and Embedded
Take a glance at the areas of expertise where KDAB excels ranging from swift troubleshooting, ongoing consulting and training to multi-year, large-scale software development projects.
Find out why customers from innovative industries rely on our extensive expertise, including Medical, Biotech, Science, Renewable Energy, Transportation, Mobility, Aviation, Automation, Electronics, Agriculture and Defense.
High-quality Embedded Engineering across the Stack
To successfully develop an embedded device that meets your expectations regarding quality, budget and time to market, all parts of the project need to fit perfectly together.
Learn more about KDAB's expertise in embedded software development.
Where the capabilities of modern mobile devices or web browsers fall short, KDAB engineers help you expertly architect and build high-functioning desktop and workstation applications.
Extensible, Safety-compliant Software for the Medical Sector
Create intelligent, patient-focused medical software and devices and stay ahead with technology that adapts to your needs.
KDAB offers you expertise in developing a broad spectrum of clinical and home-healthcare devices, including but not limited to, internal imaging systems, robotic surgery devices, ventilators and non-invasive monitoring systems.
Building digital dashboards and cockpits with fluid animations and gesture-controlled touchscreens is a big challenge.
In over two decades of developing intricate UI solutions for cars, trucks, tractors, scooters, ships, airplanes and more, the KDAB team has gained market leading expertise in this realm.
Build on Advanced Expertise when creating Modern UIs
KDAB assists you in the creation of user-friendly interfaces designed specifically for industrial process control, manufacturing, and fabrication.
Our specialties encompass the custom design and development of HMIs, enabling product accessibility from embedded systems, remote desktops, and mobile devices on the move.
Legacy software is a growing but often ignored problem across all industries. KDAB helps you elevate your aging code base to meet the dynamic needs of the future.
Whether you want to migrate from an old to a modern GUI toolkit, update to a more recent version, or modernize your code base, you can rely on over 25 years of modernization experience.
KDAB offers a wide range of services to address your software needs including consulting, development, workshops and training tailored to your requirements.
Our expertise spans cross-platform desktop, embedded and 3D application development, using the proven technologies for the job.
When working with KDAB, the first-ever Qt consultancy, you benefit from a deep understanding of Qt internals, that allows us to provide effective solutions, irrespective of the depth or scale of your Qt project.
Qt Services include developing applications, building runtimes, mixing native and web technologies, solving performance issues, and porting problems.
KDAB helps create commercial, scientific or industrial desktop applications from scratch, or update its code or framework to benefit from modern features.
Discover clean, efficient solutions that precisely meet your requirements.
Boost your team's programming skills with in-depth, constantly updated, hands-on training courses delivered by active software engineers who love to teach and share their knowledge.
Our courses cover Modern C++, Qt/QML, Rust, 3D programming, Debugging, Profiling and more.
The collective expertise of KDAB's engineering team is at your disposal to help you choose the software stack for your project or master domain-specific challenges.
Our particular focus is on software technologies you use for cross-platform applications or for embedded devices.
Since 1999, KDAB has been the largest independent Qt consultancy worldwide and today is a Qt Platinum partner. Our experts can help you with any aspect of software development with Qt and QML.
KDAB specializes in Modern C++ development, with a focus on desktop applications, GUI, embedded software, and operating systems.
Our experts are industry-recognized contributors and trainers, leveraging C++'s power and relevance across these domains to deliver high-quality software solutions.
KDAB can guide you incorporating Rust into your project, from as overlapping element to your existing C++ codebase to a complete replacement of your legacy code.
Unique Expertise for Desktop and Embedded Platforms
Whether you are using Linux, Windows, MacOS, Android, iOS or real-time OS, KDAB helps you create performance optimized applications on your preferred platform.
If you are planning to create projects with Slint, a lightweight alternative to standard GUI frameworks especially on low-end hardware, you can rely on the expertise of KDAB being one of the earliest adopters and official service partner of Slint.
KDAB has deep expertise in embedded systems, which coupled with Flutter proficiency, allows us to provide comprehensive support throughout the software development lifecycle.
Our engineers are constantly contributing to the Flutter ecosystem, for example by developing flutter-pi, one of the most used embedders.
KDAB invests significant time in exploring new software technologies to maintain its position as software authority. Benefit from this research and incorporate it eventually into your own project.
Start here to browse infos on the KDAB website(s) and take advantage of useful developer resources like blogs, publications and videos about Qt, C++, Rust, 3D technologies like OpenGL and Vulkan, the KDAB developer tools and more.
The KDAB Youtube channel has become a go-to source for developers looking for high-quality tutorial and information material around software development with Qt/QML, C++, Rust and other technologies.
Click to navigate the all KDAB videos directly on this website.
In over 25 years KDAB has served hundreds of customers from various industries, many of them having become long-term customers who value our unique expertise and dedication.
Learn more about KDAB as a company, understand why we are considered a trusted partner by many and explore project examples in which we have proven to be the right supplier.
The KDAB Group is a globally recognized provider for software consulting, development and training, specializing in embedded devices and complex cross-platform desktop applications.
Read more about the history, the values, the team and the founder of the company.
When working with KDAB you can expect quality software and the desired business outcomes thanks to decades of experience gathered in hundreds of projects of different sizes in various industries.
Have a look at selected examples where KDAB has helped customers to succeed with their projects.
KDAB is committed to developing high-quality and high-performance software, and helping other developers deliver to the same high standards.
We create software with pride to improve your engineering and your business, making your products more resilient and maintainable with better performance.
KDAB has been the first certified Qt consulting and software development company in the world, and continues to deliver quality processes that meet or exceed the highest expectations.
In KDAB we value practical software development experience and skills higher than academic degrees. We strive to ensure equal treatment of all our employees regardless of age, ethnicity, gender, sexual orientation, nationality.
Interested? Read more about working at KDAB and how to apply for a job in software engineering or business administration.
In Qt 5.0 the QOpenGLShader and QOpenGLShaderProgram classes only had support for Vertex and Fragment shaders. Qt 5.1 will include support for all shader stages supported by OpenGL:
Vertex Shaders
Fragment Shaders
Geometry Shaders (requires OpenGL 3.2)
Tessellation Control and Tessellation Evaluation Shaders (requires OpenGL 4.0)
Compute Shaders (requires OpenGL 4.3)
As long as your platform has support for the required OpenGL version, then Qt 5.1 will work there. The availability of Geometry, Tessellation stage and Compute shaders really opens the doors for some interesting effects and order of magnitude improvements in performance over what is possible with plain OpenGL 2.x.
For the future
As we have seen, Qt 5.1 adds a great deal new functionality and enablers around OpenGL. There is still much to do and we will continue adding more enablers to make it easier and safer to write OpenGL code as we move towards Qt 5.2. Some of the items on the radar include Textures, Texture Images, Samplers, Occlusion Queries, Transform feedback objects, Uniform Buffer Objects, Shader Storage Buffer Objects and Shader Program Pipeline Objects, Object labels for debug output
We are very keen to see OpenGL support in Qt continue to improve and will continue to work to do so. I know many people have been asking about the status of Qt3D. Although not part of the Qt3D module, the improvements described here form a good part of the foundations upon which we will build the Qt3D renderer. If all goes to plan then Qt3D will be released along with Qt 5.2.
An example
For now here is a video of an example written using Qt 5.1 (dev branch) and OpenGL. This gives a small taste of what can easily be done using these two great APIs together:
To watch this video on our website please or view it directly on YouTube
This scene consists of the following:
Terrain heightmap texture used to render large terrain region in just one function call!
Rendered with GL_PATCHES as we are using tessellation shaders
View frustum clipping performed on GPU (needs improvement to remove artifacts)
Dynamic tessellation levels determined by screen-space error
Wireframe included in single pass using geometry shader
GLSL subroutines to quickly change rendering style without changing shader program
Dynamic normal vector calculation
Texture blending controlled by terrain height, slope, and fragment distance
Very simple fog for depth cueing
Per-pixel directional lighting
As you can see this is quite some features but we have moved much work to the GPU. In fact the entire rendering function for this example is:
voidTerrainTessellationScene::render(){glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); m_material->bind(); QOpenGLShaderProgramPtr shader = m_material->shader(); shader->bind();// Set the fragment shader display mode subroutine m_funcs->glUniformSubroutinesuiv( GL_FRAGMENT_SHADER,1,&m_displayModeSubroutines[m_displayMode]);// Set the horizontal and vertical scales applied// in the tessellation stages shader->setUniformValue("horizontalScale", m_horizontalScale ); shader->setUniformValue("verticalScale", m_verticalScale );// Pass in the usual transformation matrices QMatrix4x4 viewMatrix = m_camera->viewMatrix(); QMatrix4x4 modelViewMatrix = viewMatrix * m_modelMatrix; QMatrix3x3 worldNormalMatrix = m_modelMatrix.normalMatrix(); QMatrix3x3 normalMatrix = modelViewMatrix.normalMatrix(); QMatrix4x4 mvp = m_camera->projectionMatrix()* modelViewMatrix; shader->setUniformValue("modelMatrix", m_modelMatrix ); shader->setUniformValue("modelViewMatrix", modelViewMatrix ); shader->setUniformValue("worldNormalMatrix", worldNormalMatrix ); shader->setUniformValue("normalMatrix", normalMatrix ); shader->setUniformValue("mvp", mvp );// Set the lighting parameters QVector4D worldLightDirection(sinf( m_sunTheta * degToRad ),cosf( m_sunTheta * degToRad ),0.0f,0.0f); QMatrix4x4 worldToEyeNormal( normalMatrix ); QVector4D lightDirection = worldToEyeNormal * worldLightDirection; shader->setUniformValue("light.position", lightDirection ); shader->setUniformValue("light.intensity",QVector3D(1.0f,1.0f,1.0f));// Set the material properties shader->setUniformValue("material.Ka",QVector3D(0.1f,0.1f,0.1f)); shader->setUniformValue("material.Kd",QVector3D(1.0f,1.0f,1.0f)); shader->setUniformValue("material.Ks",QVector3D(0.3f,0.3f,0.3f)); shader->setUniformValue("material.shininess",10.0f);// Render the quad as a patch m_vao.bind(); shader->setPatchVertexCount(1);glDrawArrays( GL_PATCHES,0, m_patchCount );}
Most of the rendering function is just setting uniform variables and could be replaced with the use of a uniform buffer. The complete source code for this example is available at:
Requirements for this example are Qt 5.1 alpha (or a recent build from the stable branch of git) and an OpenGL 4.0 capable system. See the window.cpp file for controls.
There are a number of improvements that could quite easily be made:
Use a compute shader to generate terrain on demand as we move around the world
Use a floating point texture for more vertical resolution
Use a Z-fill pre-pass to reduce fragment shader work load
Compute normal vectors once in compute shader rather than every frame
Add trees, bushes, rocks, grass using instanced geometry rendering
Make the terrain deformable and paintable (e.g. raise/lower land, paint paths, change terrain base color)
Use a density function rather than a simple heightmap to create caves and overhangs
Use a quad-tree tile approach to further reduce distant triangle count
Add more realistic atmospheric scattering
Ambient occlusion and shadows
We will cover some of these in future blog articles and in more depth in our Qt and OpenGL trainings. Happy rendering!
About KDAB
Trusted software excellence across embedded and desktop platforms
The KDAB Group is a globally recognized provider for software consulting, development and training, specializing in embedded devices and complex cross-platform desktop applications. In addition to being leading experts in Qt, C++ and 3D technologies for over two decades, KDAB provides deep expertise across the stack, including Linux, Rust and modern UI frameworks. With 100+ employees from 20 countries and offices in Sweden, Germany, USA, France and UK, we serve clients around the world.
Could you, please, explain what is the overhead in using Qt for real-time 3D applications? Particularly on mobile platforms and also with QQuickView, QGuiApplication ?
10 - Apr - 2013
Sean Harmer
It all depends what you are trying to do. QGuiApplication + QWindow + QOpenGLContext gives you basically the same as something like GLUT or SDL. It's entirely up to you how to delegate rendering and other tasks to threads in your application but there is no real overhead in using Qt like this.
If you want to combine custom OpenGL rendering with Qt Quick 2 then of course there is the small overhead of that technology stack for the runtime. However, it does buy you a very powerful way of creating UIs and property bindings are immensely useful.
We are aware of many projects using Qt5 + Qt Quick 2 + OpenGL on mobile devices. Performance is as always dependent upon what your hardware can do and how effectively you are using it.
16 - Apr - 2013
Billy Zelsnack
Great series. I would love to see a part 6 showing the various practical opengl + ui options for 5.1.
24 - Apr - 2013
Julio Fernando Baffa
I am writing an application that works using opengl widgets multithreaded. My actual approach is QGraphicsView+QGraphisScene+OpenGL based in qq-26-openglcanvas example. Can I use QWindows+QOpenGLContext+QWidget::createWindowContainer to replace old style? If this is possible, how can I do that?
25 - Apr - 2013
Sean Harmer
The same technique should still work. Why do you feel the need to change it? If it is to use QOpenGLShaderProgram rather than QGLShaderProgram etc then there is no need as the new QOpenGL* classes should work with QGLWidget and friends.
An alternative that is now open to you would be to use QML over OpenGL "underlay" or OpenGL-based custom items.
25 - Apr - 2013
Julio Fernando Baffa
I am looking for the best performance as possible for my real time application. The reason to try to change it, is for new application are recomended use of QOpenGLxxx instead of QGLxxx. My problem is when I try to attach for example a QLabel into a layout and then to QWindows container (QWidget) simply this widget not appear, only shown raw opengl. Can you write a little example in how to do that? In respect to your suggestion of use QML, particulary, I feel good programming in C++.
1 - Aug - 2013
Mathieu
+1 I would also like to know if it is possible to add QWidgets of top of an QWindow that uses OpenGL....
17 - Sept - 2013
mikael
Hi Sean,
Is there a way to load dds files through the new Qt OpenGL API?
Thank you for this serie of OpenGL examples
Best regards
Hi Sean, I'm from Venezuela, I'm currently doing some research for my thesis on real time planet rendering before I get to implement something and I found this article very useful, but it is too much QT-oriented, I would like to know if you have a paper or something about your implementation on the terrain renderer because I can't find anything documented similar to this (terrain rendering using tessellation shaders), it is something relatively new and I'm almost sure I will use your implementation and make it work on spherical surfaces (I will give you credits on my thesis, I'm asking for permission to take your source and use it).
If you give me permission, I would like some help to make some of the improvements you mentioned (quad tree, deformable terrain data, compute normal vectors).
Thanks in advice for your help, I will really appreciate it.
22 - May - 2013
Sean Harmer
Hi Luis, please feel free to build upon this code as you see fit. A good reference is the chapter on this topic in the book OpenGL Insights.
22 - May - 2013
Luis
Thanks Sean, I'm just downloading a copy of the book right now and it looks very great, this documentation will help with my work, if I get to improve something in your code I will send it to you. Please give me your email so I can contact you personally (if it's ok and you have some time to help me)
Thank you again! have a nice day :)
23 - May - 2013
Will Dobbie
Hi Sean,
I'm attempting to implement a QML GUI overlay on top of an OpenGL 3.2+ underlay. You mention this approach in your QtDD12 OpenGL with Qt5 talk, via inheriting QQuickView and setting a custom QSurfaceFormat with the newer OpenGL version set to the compatibility profile.
Unfortunately on OS X there is no compatibility profile, you can only create a 3.2 context using the core profile. Is there any other way of mixing Qt Quick 2 and OpenGL 3.2+, without rendering one of them to an FBO?
Thanks for you advice and your articles
24 - May - 2013
Dhi Aurrahman
Is it possible to run the app using OpenGL < 4.0 ? How to set the OpenGL version?
24 - May - 2013
Sean Harmer
Unfortunately not. This demo requires OpenGL 4 for the tessellation shader support.
A vertex shader and 4K versus. A Tesselation shader and a whole MOUNTAIN of libraries .
Sorry, I'm JUST about tired and immature enough to find this funny ;)
11 - Jun - 2013
florian
The tessellation behavior does not seem right : as we come closer to the geometry there is indeed more triangles, but they are all on the same flat squared patch.
It creates very sharp edges, and that is what tessellation is supposed to avoid.
28 - Jun - 2013
pmaynard
For an image display tool using QT 5.1, what's the best way to support multiple windows? I can't use QMdiArea, because it expects QWidgets not QWindows? And without QWindows all the wonderful QOpenXXX methods aren't available.
1 - Jul - 2013
Sean Harmer
It is now possible to embed a QWindow into a QWidget by using
I only see a sky blue scene - any common problem that could cause this? My graphics card is able to handle opengl 4.+
11 - Aug - 2013
anm
Yes, I have the same problem in the output reads:
Total number of patches = 25600
QOpenGLContext :: swapBuffers () called with non-exposed window, behavior is undefined
11 - Aug - 2013
Sean Harmer
Which platform, GPU and driver version do you guys have please? I've only tested this on Linux, nVidia GeForce 500 series with a recent binary blob driver from nVidia. You may need to poke around and see which context version you are getting back from the system.
12 - Aug - 2013
glararan
Hello,
I'm trying to learn OpenGL for Qt from this project, can you help me with one problem? I'm trying to get 3D mouse coords => 2D mouse coords to 3D world coords, I found gluUnProject, but it doesn't work, so I used QMatrixes from Camera to create own, but still one problem left.
I have terrain start location, I get mouse into center of screen and I'm getting wrong Z position, it should be 230.0 Z but it is 216.1 Z
When I rotate with camera on axis X to left (-90 pan degrees), Z became normal, but X coord get wrongs :/
Currently QVector3D on [935, 475] (center) = QVector3D(249.997, 10.0002, 216.095)
Should be QVector3D(250, 10, 230).
Have you any idea how to solve this?
14 - Aug - 2013
glararan
Hi,
I want to get world coords from mouse, I need to locate terrain xyz.
Because gluUnProject not working, I build own gluUnProject, but I have big trouble with camera, when I rotate camera, world coords are changed and are incorrect.
When I just start app, my Z coordinate is incorrect, when I turn camera to left by 90 degrees, Z is in normal, but X is corrupted.
Without this fix, the camera doesn't work or I missed something ?
1 - Sept - 2013
Maiss
Hi Sean,
I keep getting blue screen after compilation like some commenter mentioned. Do you have an idea what causes this? The code compile and It display "Total number of patches = 25600 ", but it show only a blue screen.
My settings are:
Qt 5.1.1 (tried both MinGW/VS2010-12)
Windows 7 64
AMD 7950 (with latest drives).
Thanks.
17 - Sept - 2013
Sean Harmer
Hmmm this sounds like some difference between nVidia vs AMD in GLSL support. I don't have any AMD cards to test on here. I suspect it's something in either the tess or geometry shaders.
27 - Sept - 2013
uri
Same problem here: I'm just getting a blue screen.
AMD HD6570 (Catalyst 13.9, latest as of Sept. 2013).
Qt 5.1
Windows 7 64
Any chance for an update? I'd love to try this out on my ATI card.
27 - Sept - 2013
Sean Harmer
Unfortunately I don't have any AMD cards on which to test. Patches welcome of course :)
4 - Oct - 2013
Epxzz
Hey,
great demo. It helps me a lot to understand all the new OpenGL stuff.
I imported the project into Visual Studio and tried to use nvidia nsight for graphical debugging.
Unfortunately I can't get it to work.
Do you have any clue?
Hi ! I have a few questions about the tessellation demo:
Some functions are called without a pointer, for example:
glEnable( GL_DEPTH_TEST ); How it works ?
Why you use different qopenglfunctions in the project ? For example material.cpp contains #include , sampler.cpp contains #include Why you don't use QOpenGLFunctions_4_0_Core everywhere ?
14 - Oct - 2013
Sean Harmer
Hi.
1) Some functions are exported by the libraries on all platforms. The most restrictive platform is Windows which only exports OpenGL 1.0 and 1.1 functions.
2) Yes I probably should have used that consistently throughout. I wrote those parts before QOpenGLFunctions_MAJOR_MINOR existed.
27 - Oct - 2013
SeVerage
Hello Sean,
Is it possible to use the WGL_AMD_gpu_association or the WGL_NV_gpu_affinity extensions to choose the graphic card for the QOpenGLContext?
We tried it with setting the QScreen for the Context with Windows 7 and two NVIDIA Quadro Graphic cards, each connected with one screen, but the result was that only the first graphic card renders the two contexts.
Is there any way to choose the gpu for a QOpenGLContext?
Thanks
28 - Oct - 2013
Sean Harmer
Hi,
Hmmm, I don't recall seeing any explicit support for those extensions within Qt. Would be a nice thing to add though.
28 - Oct - 2013
SeVerage
Ok, so when we set the QScreen for a QOpenGLContext, before we create it, the Context will always be on the primary GPU?
28 - Oct - 2013
Irbis
Hi! I want to use OpenGL 4.* Core funtions without QOpenGLFunctions_4_*_Core pointer: m_funcs->glFunction();
I was trying to modify Terrain Tesselation demo but without success. Here is a modified class definition:
class TerrainTessellationScene : public AbstractScene, protected QOpenGLFunctions_4_0_Core
Then in void TerrainTessellationScene::initialise() I removed the following code:
When I run the program it crashes with the exit code: -1073741819
What is wrong ?
28 - Oct - 2013
Sean Harmer
Do you have a valid current context when you call initializeOpenGLFunctions();?
28 - Oct - 2013
Irbis
Yes, I only changed the code mentioned above, everything else is the same as in the terrain tessellation demo. void Window::initializeGL() is called after the context is created and set. Could you reproduce that way of using QOpenGLFunctions on your machine ?
29 - Oct - 2013
Ryan
Hi Sean:
Thanks for these tutorials. I found something really strange when i was trying to follow your tutorials to set up OpenGL in Qt.
Firstly, I have a ATI radeon hd 5750 graphics card. After searching online i found it that it only supports up to openGL 3.2.
But when i was trying to create openGL context with version 4.3, it succeeded, which really confused me.
Another thing i was super confused about was i was able to pass in any int number as version numbers, like 1000.11, and create() would just work. But i was not able to resolve function entry points if I did that.
According to Qt document, context.format() should have the actually created version number for openGL for me to query, but apparently in my case it doesnt.
So whats wrong?
Thanks.
30 - Oct - 2013
Sean Harmer
Are you on OS X by any chance? If so which version?
30 - Oct - 2013
Ryan
Yes, I am using mac osx mavericks, whatever version is the latest..
30 - Oct - 2013
Sean Harmer
Ah right. That sounds like the core profile support in the cocoa QPA plugin needs to be extended to handle Mavericks. I've only just upgraded myself. I'll try to push a patch for this in time for Qt 5.2.0. I've created the following task for this https://bugreports.qt-project.org/browse/QTBUG-34471
Thanks for the report!
30 - Oct - 2013
Irbis
Hi ! I made a mistake: In the project I mixed two types of initialization. The second way of initialization GL functions also works fine. I assume that when I call QOpenGLFunctions_4_3_Core::initializeOpenGLFunctions() it automatically uses existing context, right ?
30 - Oct - 2013
Sean Harmer
Glad you sorted it. Yes, internally it uses QOpenGLContext::currentContext().
30 - Oct - 2013
Irbis
In my project I have many classes which use GL functions and inherit from QOpenGLFunctions_4_3_Core, so in each constructor (or more generally for each object) I should call QOpenGLFunctions_4_3_Core::initializeOpenGLFunctions() or there is other way ?
30 - Oct - 2013
Sean Harmer
You could change from using inheritance to having a pointer to the QOpenGLFunctions_4_3_Core object that you make available via a static function or some other method.
If you stick with the inheritance approach then yes you should always call initializeOpenGLFunctions(). However, it only does the function resolution work the first time it is called on any instance as the backends are shared internally within QOpenGLContext. So after the first call to initializeOpenGLFunctions() it is essentially a no-op for further calls.
30 - Oct - 2013
Irbis
I'm not sure if I understood you correctly (also my english is not perfect). We have for example three classes which inherit from QOpenGLFunctions_4_3_Core. Class A contains objects of class B and C. The constructor of class A looks like this:
A::A()
{
QOpenGLFunctions_4_3_Core::initializeOpenGLFunctions();
b = new B;
c = new C;
}
Constructors of class B and C also have to call QOpenGLFunctions_4_3_Core::initializeOpenGLFunctions(); but adresses are resolved dynamically only once when constructor of class A calls QOpenGLFunctions_4_3_Core::initializeOpenGLFunctions(). So what happens when constructors of class B and C call that function ?
30 - Oct - 2013
Sean Harmer
Yes if using the inheritance approach that is correct. Internally the calls inside of B and C will just get hold of pointers to the internal objects that contain the function addresses. If you are interested in the actual mechanics of this have a look at the implementation of initializeOpenGLFunctions() and how the Backend classes are cached inside of QOpenGLContext.
4 - Nov - 2013
Irbis
Hi ! I created a program where my glwindow which inherits form QWindow is part of the QMainWindow (I have there also some other widgets which I use for example to set a light intensity etc). I used QWidget::createWindowContainer function. I turned off v-sync and set a timer interval to "0" to check how many fps I can get. The result was about 2200 fps, but when I ran the application I got following message: QOpenGLContext::swapBuffers() called with non-exposed window, behavior is undefined. With the timer interval set to the value > 0 I don't get that message. Moreover when the timer interval is set to 0 and I want for example resize a main window the application hangs up. What do you think about it ?
4 - Nov - 2013
Sean Harmer
To avoid the warning about non-exposed windows, just check if the window has been exposed (isExposed()) before doing anything in your render function. If the window has not been exposed yet, don't bother drawing anything and just return.
Not sure about the lockup when resizing the main window. Have you tried breaking using the debugger to see where it is stuck?
4 - Nov - 2013
Irbis
Yes, but a debugger doesn't contain any message. I have to use "ctrl+ alt + del" and kill the process manually.
I also wonder why I get 64 fps when a timer interval is set to 1 (should be 1000 fps). Other results: interval = 10 also 64 fps, interval = 50 -> 16 fps, interval = 100 -> 9 fps. Only the last result (100 ms -> 9fps) seems to be correct.
15 - Nov - 2013
Elangovan D
I have problem in compiling my opengl library across arm platform.
Processor:freescale i.mx51
it is giving error opengles test functionality failed
Provide some assistance.
Regards
D.Elangovan
10 - Dec - 2013
Slavina
Hi,
I was getting a segfault (with all 5 shaders, fault was at linking) or the blue sky (with fragment, vertex, and geometry) when running the app in Qt Creator, Win 7 64 with Intel HD Graphics 4000 OpenGL 4.0. Tried Qt 5.1 mingw48_32, Qt 5.1 msvc2010 32-bit OpenGL, Qt 5.2 msvc2010 32 OpenGL. The qt version doesn't seem to make a difference. Aside from updating all opengl functions to QOpenGLFunctions_4_Core, which didn't seem to fix the problem, I tried modifying the shaders. The one offending line I found was line 85 in terraintessellation.tcs:
//vec4 clipSpacePatchCorners[4];
After commenting it out the app runs fine. I'm very puzzled though, because clipSpacePatchCorners is used in the shader (without being declared if line 85 is commented out) and despite some errors I get (main problem is, of course, "Could not compile tessellation control shader. Log:" "ERROR: 2:93: 'clipSpacePatchCorners' : undeclared identifier"), the app only runs with this change. If I comment out all references to clipSpacePatchCorners, then the app is just the blue sky ...
20 - Dec - 2013
Slavina
As a quick followup:
the segfault caused by terraintesselation.tcs was happening during the calculation of max(gl_TessLevelOuter[1], gl_TessLevelOuter[3]). Accessing the array values directly in that function was causing a problem. I copied them in local variables and passed to the max() function, then the shader compiled and linked fine. However, the application showed only the blue sky, no terrain. I figured the 'else' clause might have to do something with it (it sets gl_TessLevelOuter and gl_TessLevelInner to 0.0). After commenting the else {} contents out, the terrain did show, but with odd behavior. The individual patches were flickering.
The app looks ok if terraintesselation.tcs fails to compile.
26 - Feb - 2014
Johan
I didn't see a license notice in the source download.
Can I use your example code in an open source project I'm developing? It will most likely be licensed under the zlib license or another permissive license.
26 - Feb - 2014
Sean Harmer
Please feel free to do so. A link back to here would be appreciated.
4 - Mar - 2014
Bernd Dreier
Hi,
I'm trying to run your example code on a new Macbook Pro running OSX Mavericks, because I have problems with my own code. However, I get the same errors during runtime, i.e. during compile time of the tesselation shaders with your example: QOpenGLShader::compile(): ERROR: 0:6: Invalid use of layout 'vertices'
ERROR: 0:15: Use of undeclared identifier 'gl_InvocationID' and more...
Any hints or thoughts?
Bernd
4 - Mar - 2014
Sean Harmer
Which version OpenGL context are you getting back from Mavericks? Not all Mavericks hw is capable of OpenGL 4. Some devices will only give you and OpenGL 3.2 core profile context. Admittedly I've not tried this on Mavericks myself yet so there could be other bugs/problems.
5 - Mar - 2014
Bernd Dreier
I get back a 4.1 context as expected. I'm on Qt 5.2.1 now - the versions before had a bug, which gave you back always the version you demanded - not the one you really have. But this is solved. It's a NVidia GT750m, which should be able to do GLSL 4.1 ...
17 - Mar - 2014
Bernd Dreier
No one out there with the same problem? No hints?
Bernd
17 - Mar - 2014
Sean Harmer
Sorry really busy lately. I'll look into this in the near future.
31 - Mar - 2014
Bernd Dreier
I have almost sorted it out: There is a bug in compiling tesselation shaders in Qt. If I compile (only) the tesselation Shaders with the native OpenGL-Funcs, the example works! However, I see the textures only randomly, but this will have others reasons, I assume. Somebody should track down the compilation of tesselation shaders in Qt...
Bernd
9 - Oct - 2014
Evan
I also have the exact error output. Qt 5.3, OSX 10.9.4. OpenGL context is 4.1.
15 - Mar - 2014
sargas
Hi, I want to ask, why the screen flickers white from time to time?
22 - May - 2014
Francisco Boni
I tried to run the source with a compatibility context and I couldn't get it run properly. It was crashing when I call versionFunctions() (segfault)
It seems QOpenGLContext create(), after setting the QSurfaceFormat properly, was completely rejecting the compatibility setting and creating a Core context instead, completely ignoring my request for a compatibility context (format.setProfile( QSurfaceFormat::CompatibilityProfile).
I discovered the case. In the original code at kdab:
// Create an OpenGL context
m_context = new QOpenGLContext;
m_context->setFormat( format );
m_context->create();
by creating the context (create()) before setFormat, I was able to correctly initiate a proper Compatibility Context. It seems that the original source needs to be fixed.
22 - May - 2014
Francisco Boni
It seems I've got lucky with the AMD drivers and the context is not to be created before setFormat:
"Creating the context before setFormat() is wrong and works by accident since what you are requesting then is a plain OpenGL 2.0 context and the driver most likely gives you 4.3 compatibility. On other drivers or platforms this may fail so be careful.
The behavior you are seeing is caused by the AMD driver: it refuses to create a proper compatibility profile context unless the forward compatibility set is not set. Qt sets the fwdcompat bit by default, it can be turned off by setting the DeprecatedFunctions option on the QSurfaceFormat. So requesting for Compatibility together with DeprecatedFunctions will give what you want. Other vendors’ drivers do not have this problem, there not setting DeprecatedFunctions (i.e. setting forward compatibility) is ignored for compatibility profiles, as it should be."
29 - Mar - 2015
HGH
Is it possible to create OpenGL context without QApplication, without a window/widgets?
The use case: console application for offscreen rendering or just compute shaders?
29 - Mar - 2015
Sean Harmer
Yes. You can use QGuiApplication, QOpenGLContext and QOffscreenSurface. Just don't create or show any widgets or windows and render into an FBO render target.
12 - May - 2015
Brian
Hi,
So I am trying to use the QOpenGLFunctions_MAJOR_MINOR system, but it seems to stop at OpenGL 4.3? How can I get access to OpenGL 4.4 and 4.5? A look through the Qt 4.5.1 install I have on Windows backs this up, no files for 4.4 and 4.5. I've also been puzzled no one else has come across this issue. Thanks,
12 - May - 2015
Sean Harmer
Coming in Qt 5.5 any time now. Beta snapshots are available for download.
5 - Nov - 2015
Alexey
Good day! I try to run example of code published here as "terrain tesselation" and my IDE can not run this example because these errors happened:
undefined reference to '_imp__glDeleteTextures@8'; 'undefined reference to _imp__glGenTextures@8'; undefined reference to '_imp__glBindTeture@8'; undefined reference to '_imp__glTexImage2D@36'. I didn't some changes in source code. Please tell me what should i do to run example? My system description: renderer is GeForce GTX750 Ti/PCIe/SSE2 2048Mb, OpenGL version is 4.4, Driver vercion 10.18.13.5597 Forceware, Windows 7 x64. IDE: QTCreator 3.4.2 (it uses QT libs 5.5.0 and compiler MinGW 492_32). Thanks!
Sean Harmer
Managing Director KDAB UK
Dr Sean Harmer is a senior software engineer at KDAB where he heads up our UK office and also leads the 3D R&D team. He has been developing with C++ and Qt since 1998 and is Qt 3D Maintainer and lead developer in the Qt Project. Sean has broad experience and a keen interest in scientific visualization and animation in OpenGL and Qt. He holds a PhD in Astrophysics along with a Masters in Mathematics and Astrophysics.
71 Comments
10 - Apr - 2013
HGH
Could you, please, explain what is the overhead in using Qt for real-time 3D applications? Particularly on mobile platforms and also with QQuickView, QGuiApplication ?
10 - Apr - 2013
Sean Harmer
It all depends what you are trying to do. QGuiApplication + QWindow + QOpenGLContext gives you basically the same as something like GLUT or SDL. It's entirely up to you how to delegate rendering and other tasks to threads in your application but there is no real overhead in using Qt like this.
If you want to combine custom OpenGL rendering with Qt Quick 2 then of course there is the small overhead of that technology stack for the runtime. However, it does buy you a very powerful way of creating UIs and property bindings are immensely useful.
We are aware of many projects using Qt5 + Qt Quick 2 + OpenGL on mobile devices. Performance is as always dependent upon what your hardware can do and how effectively you are using it.
16 - Apr - 2013
Billy Zelsnack
Great series. I would love to see a part 6 showing the various practical opengl + ui options for 5.1.
24 - Apr - 2013
Julio Fernando Baffa
I am writing an application that works using opengl widgets multithreaded. My actual approach is QGraphicsView+QGraphisScene+OpenGL based in qq-26-openglcanvas example. Can I use QWindows+QOpenGLContext+QWidget::createWindowContainer to replace old style? If this is possible, how can I do that?
25 - Apr - 2013
Sean Harmer
The same technique should still work. Why do you feel the need to change it? If it is to use QOpenGLShaderProgram rather than QGLShaderProgram etc then there is no need as the new QOpenGL* classes should work with QGLWidget and friends.
An alternative that is now open to you would be to use QML over OpenGL "underlay" or OpenGL-based custom items.
25 - Apr - 2013
Julio Fernando Baffa
I am looking for the best performance as possible for my real time application. The reason to try to change it, is for new application are recomended use of QOpenGLxxx instead of QGLxxx. My problem is when I try to attach for example a QLabel into a layout and then to QWindows container (QWidget) simply this widget not appear, only shown raw opengl. Can you write a little example in how to do that? In respect to your suggestion of use QML, particulary, I feel good programming in C++.
1 - Aug - 2013
Mathieu
+1 I would also like to know if it is possible to add QWidgets of top of an QWindow that uses OpenGL....
17 - Sept - 2013
mikael
Hi Sean, Is there a way to load dds files through the new Qt OpenGL API? Thank you for this serie of OpenGL examples Best regards
17 - Sept - 2013
Sean Harmer
Not yet. I was hoping to do this for 5.2 but I'm running out of time before the feature freeze so it likely won't make it until 5.3. I am hoping to get https://codereview.qt-project.org/#change,56462 finished soon which you should then be able to use with something like https://code.google.com/p/nvidia-texture-tools/.
20 - May - 2013
Luis
Hi Sean, I'm from Venezuela, I'm currently doing some research for my thesis on real time planet rendering before I get to implement something and I found this article very useful, but it is too much QT-oriented, I would like to know if you have a paper or something about your implementation on the terrain renderer because I can't find anything documented similar to this (terrain rendering using tessellation shaders), it is something relatively new and I'm almost sure I will use your implementation and make it work on spherical surfaces (I will give you credits on my thesis, I'm asking for permission to take your source and use it).
If you give me permission, I would like some help to make some of the improvements you mentioned (quad tree, deformable terrain data, compute normal vectors).
Thanks in advice for your help, I will really appreciate it.
22 - May - 2013
Sean Harmer
Hi Luis, please feel free to build upon this code as you see fit. A good reference is the chapter on this topic in the book OpenGL Insights.
22 - May - 2013
Luis
Thanks Sean, I'm just downloading a copy of the book right now and it looks very great, this documentation will help with my work, if I get to improve something in your code I will send it to you. Please give me your email so I can contact you personally (if it's ok and you have some time to help me)
Thank you again! have a nice day :)
23 - May - 2013
Will Dobbie
Hi Sean, I'm attempting to implement a QML GUI overlay on top of an OpenGL 3.2+ underlay. You mention this approach in your QtDD12 OpenGL with Qt5 talk, via inheriting QQuickView and setting a custom QSurfaceFormat with the newer OpenGL version set to the compatibility profile.
Unfortunately on OS X there is no compatibility profile, you can only create a 3.2 context using the core profile. Is there any other way of mixing Qt Quick 2 and OpenGL 3.2+, without rendering one of them to an FBO?
Thanks for you advice and your articles
24 - May - 2013
Dhi Aurrahman
Is it possible to run the app using OpenGL < 4.0 ? How to set the OpenGL version?
24 - May - 2013
Sean Harmer
Unfortunately not. This demo requires OpenGL 4 for the tessellation shader support.
4 - Jun - 2013
Tore Slinning
See if you can beat this ;)
http://pouet.net/prod.php?which=52938
A vertex shader and 4K versus. A Tesselation shader and a whole MOUNTAIN of libraries .
Sorry, I'm JUST about tired and immature enough to find this funny ;)
11 - Jun - 2013
florian
The tessellation behavior does not seem right : as we come closer to the geometry there is indeed more triangles, but they are all on the same flat squared patch. It creates very sharp edges, and that is what tessellation is supposed to avoid.
28 - Jun - 2013
pmaynard
For an image display tool using QT 5.1, what's the best way to support multiple windows? I can't use QMdiArea, because it expects QWidgets not QWindows? And without QWindows all the wonderful QOpenXXX methods aren't available.
1 - Jul - 2013
Sean Harmer
It is now possible to embed a QWindow into a QWidget by using
http://doc-snapshot.qt-project.org/qt5-release/qtwidgets/qwidget.html#createWindowContainer
9 - Aug - 2013
nick
I only see a sky blue scene - any common problem that could cause this? My graphics card is able to handle opengl 4.+
11 - Aug - 2013
anm
Yes, I have the same problem in the output reads: Total number of patches = 25600 QOpenGLContext :: swapBuffers () called with non-exposed window, behavior is undefined
11 - Aug - 2013
Sean Harmer
Which platform, GPU and driver version do you guys have please? I've only tested this on Linux, nVidia GeForce 500 series with a recent binary blob driver from nVidia. You may need to poke around and see which context version you are getting back from the system.
12 - Aug - 2013
glararan
Hello,
I'm trying to learn OpenGL for Qt from this project, can you help me with one problem? I'm trying to get 3D mouse coords => 2D mouse coords to 3D world coords, I found gluUnProject, but it doesn't work, so I used QMatrixes from Camera to create own, but still one problem left.
I have terrain start location, I get mouse into center of screen and I'm getting wrong Z position, it should be 230.0 Z but it is 216.1 Z
When I rotate with camera on axis X to left (-90 pan degrees), Z became normal, but X coord get wrongs :/
My code.
Currently QVector3D on [935, 475] (center) = QVector3D(249.997, 10.0002, 216.095) Should be QVector3D(250, 10, 230).
Have you any idea how to solve this?
14 - Aug - 2013
glararan
Hi,
I want to get world coords from mouse, I need to locate terrain xyz.
Because gluUnProject not working, I build own gluUnProject, but I have big trouble with camera, when I rotate camera, world coords are changed and are incorrect.
When I just start app, my Z coordinate is incorrect, when I turn camera to left by 90 degrees, Z is in normal, but X is corrupted.
My code is available here.
1 - Sept - 2013
Hardware
Hi Sean,
I think you've forgotten to update the viewMatrix in two methods : http://pastebin.com/munfWX3g
Without this fix, the camera doesn't work or I missed something ?
1 - Sept - 2013
Maiss
Hi Sean,
I keep getting blue screen after compilation like some commenter mentioned. Do you have an idea what causes this? The code compile and It display "Total number of patches = 25600 ", but it show only a blue screen.
My settings are:
Qt 5.1.1 (tried both MinGW/VS2010-12) Windows 7 64 AMD 7950 (with latest drives).
Thanks.
17 - Sept - 2013
Sean Harmer
Hmmm this sounds like some difference between nVidia vs AMD in GLSL support. I don't have any AMD cards to test on here. I suspect it's something in either the tess or geometry shaders.
27 - Sept - 2013
uri
Same problem here: I'm just getting a blue screen.
AMD HD6570 (Catalyst 13.9, latest as of Sept. 2013). Qt 5.1 Windows 7 64
Any chance for an update? I'd love to try this out on my ATI card.
27 - Sept - 2013
Sean Harmer
Unfortunately I don't have any AMD cards on which to test. Patches welcome of course :)
4 - Oct - 2013
Epxzz
Hey, great demo. It helps me a lot to understand all the new OpenGL stuff. I imported the project into Visual Studio and tried to use nvidia nsight for graphical debugging. Unfortunately I can't get it to work. Do you have any clue?
I also asked for help in the Nvidia Forums and started this thread: https://devtalk.nvidia.com/default/topic/610558/nsight-visual-studio-edition/setup-nsight-for-qt5-1-project/
14 - Oct - 2013
Irbis
Hi ! I have a few questions about the tessellation demo:
Some functions are called without a pointer, for example: glEnable( GL_DEPTH_TEST ); How it works ?
Why you use different qopenglfunctions in the project ? For example material.cpp contains #include , sampler.cpp contains #include Why you don't use QOpenGLFunctions_4_0_Core everywhere ?
14 - Oct - 2013
Sean Harmer
Hi.
1) Some functions are exported by the libraries on all platforms. The most restrictive platform is Windows which only exports OpenGL 1.0 and 1.1 functions.
2) Yes I probably should have used that consistently throughout. I wrote those parts before QOpenGLFunctions_MAJOR_MINOR existed.
27 - Oct - 2013
SeVerage
Hello Sean,
Is it possible to use the WGL_AMD_gpu_association or the WGL_NV_gpu_affinity extensions to choose the graphic card for the QOpenGLContext?
We tried it with setting the QScreen for the Context with Windows 7 and two NVIDIA Quadro Graphic cards, each connected with one screen, but the result was that only the first graphic card renders the two contexts.
Is there any way to choose the gpu for a QOpenGLContext?
Thanks
28 - Oct - 2013
Sean Harmer
Hi,
Hmmm, I don't recall seeing any explicit support for those extensions within Qt. Would be a nice thing to add though.
28 - Oct - 2013
SeVerage
Ok, so when we set the QScreen for a QOpenGLContext, before we create it, the Context will always be on the primary GPU?
28 - Oct - 2013
Irbis
Hi! I want to use OpenGL 4.* Core funtions without
QOpenGLFunctions_4_*_Core pointer: m_funcs->glFunction();
I was trying to modify Terrain Tesselation demo but without success. Here is a modified class definition:Then in void
TerrainTessellationScene::initialise()
I removed the following code:and I added:
I also removed
mfuncs->
from the code.When I run the program it crashes with the exit code: -1073741819
What is wrong ?
28 - Oct - 2013
Sean Harmer
Do you have a valid current context when you call initializeOpenGLFunctions();?
28 - Oct - 2013
Irbis
Yes, I only changed the code mentioned above, everything else is the same as in the terrain tessellation demo. void Window::initializeGL() is called after the context is created and set. Could you reproduce that way of using QOpenGLFunctions on your machine ?
29 - Oct - 2013
Ryan
Hi Sean: Thanks for these tutorials. I found something really strange when i was trying to follow your tutorials to set up OpenGL in Qt. Firstly, I have a ATI radeon hd 5750 graphics card. After searching online i found it that it only supports up to openGL 3.2. But when i was trying to create openGL context with version 4.3, it succeeded, which really confused me. Another thing i was super confused about was i was able to pass in any int number as version numbers, like 1000.11, and create() would just work. But i was not able to resolve function entry points if I did that. According to Qt document, context.format() should have the actually created version number for openGL for me to query, but apparently in my case it doesnt. So whats wrong? Thanks.
30 - Oct - 2013
Sean Harmer
Are you on OS X by any chance? If so which version?
30 - Oct - 2013
Ryan
Yes, I am using mac osx mavericks, whatever version is the latest..
30 - Oct - 2013
Sean Harmer
Ah right. That sounds like the core profile support in the cocoa QPA plugin needs to be extended to handle Mavericks. I've only just upgraded myself. I'll try to push a patch for this in time for Qt 5.2.0. I've created the following task for this https://bugreports.qt-project.org/browse/QTBUG-34471
Thanks for the report!
30 - Oct - 2013
Irbis
Hi ! I made a mistake: In the project I mixed two types of initialization. The second way of initialization GL functions also works fine. I assume that when I call QOpenGLFunctions_4_3_Core::initializeOpenGLFunctions() it automatically uses existing context, right ?
30 - Oct - 2013
Sean Harmer
Glad you sorted it. Yes, internally it uses QOpenGLContext::currentContext().
30 - Oct - 2013
Irbis
In my project I have many classes which use GL functions and inherit from QOpenGLFunctions_4_3_Core, so in each constructor (or more generally for each object) I should call QOpenGLFunctions_4_3_Core::initializeOpenGLFunctions() or there is other way ?
30 - Oct - 2013
Sean Harmer
You could change from using inheritance to having a pointer to the QOpenGLFunctions_4_3_Core object that you make available via a static function or some other method.
If you stick with the inheritance approach then yes you should always call initializeOpenGLFunctions(). However, it only does the function resolution work the first time it is called on any instance as the backends are shared internally within QOpenGLContext. So after the first call to initializeOpenGLFunctions() it is essentially a no-op for further calls.
30 - Oct - 2013
Irbis
I'm not sure if I understood you correctly (also my english is not perfect). We have for example three classes which inherit from QOpenGLFunctions_4_3_Core. Class A contains objects of class B and C. The constructor of class A looks like this:
Constructors of class B and C also have to call QOpenGLFunctions_4_3_Core::initializeOpenGLFunctions(); but adresses are resolved dynamically only once when constructor of class A calls QOpenGLFunctions_4_3_Core::initializeOpenGLFunctions(). So what happens when constructors of class B and C call that function ?
30 - Oct - 2013
Sean Harmer
Yes if using the inheritance approach that is correct. Internally the calls inside of B and C will just get hold of pointers to the internal objects that contain the function addresses. If you are interested in the actual mechanics of this have a look at the implementation of initializeOpenGLFunctions() and how the Backend classes are cached inside of QOpenGLContext.
4 - Nov - 2013
Irbis
Hi ! I created a program where my glwindow which inherits form QWindow is part of the QMainWindow (I have there also some other widgets which I use for example to set a light intensity etc). I used QWidget::createWindowContainer function. I turned off v-sync and set a timer interval to "0" to check how many fps I can get. The result was about 2200 fps, but when I ran the application I got following message: QOpenGLContext::swapBuffers() called with non-exposed window, behavior is undefined. With the timer interval set to the value > 0 I don't get that message. Moreover when the timer interval is set to 0 and I want for example resize a main window the application hangs up. What do you think about it ?
4 - Nov - 2013
Sean Harmer
To avoid the warning about non-exposed windows, just check if the window has been exposed (isExposed()) before doing anything in your render function. If the window has not been exposed yet, don't bother drawing anything and just return.
Not sure about the lockup when resizing the main window. Have you tried breaking using the debugger to see where it is stuck?
4 - Nov - 2013
Irbis
Yes, but a debugger doesn't contain any message. I have to use "ctrl+ alt + del" and kill the process manually.
I also wonder why I get 64 fps when a timer interval is set to 1 (should be 1000 fps). Other results: interval = 10 also 64 fps, interval = 50 -> 16 fps, interval = 100 -> 9 fps. Only the last result (100 ms -> 9fps) seems to be correct.
15 - Nov - 2013
Elangovan D
I have problem in compiling my opengl library across arm platform.
Processor:freescale i.mx51 it is giving error opengles test functionality failed
Provide some assistance.
Regards
D.Elangovan
10 - Dec - 2013
Slavina
Hi,
I was getting a segfault (with all 5 shaders, fault was at linking) or the blue sky (with fragment, vertex, and geometry) when running the app in Qt Creator, Win 7 64 with Intel HD Graphics 4000 OpenGL 4.0. Tried Qt 5.1 mingw48_32, Qt 5.1 msvc2010 32-bit OpenGL, Qt 5.2 msvc2010 32 OpenGL. The qt version doesn't seem to make a difference. Aside from updating all opengl functions to QOpenGLFunctions_4_Core, which didn't seem to fix the problem, I tried modifying the shaders. The one offending line I found was line 85 in terraintessellation.tcs: //vec4 clipSpacePatchCorners[4]; After commenting it out the app runs fine. I'm very puzzled though, because clipSpacePatchCorners is used in the shader (without being declared if line 85 is commented out) and despite some errors I get (main problem is, of course, "Could not compile tessellation control shader. Log:" "ERROR: 2:93: 'clipSpacePatchCorners' : undeclared identifier"), the app only runs with this change. If I comment out all references to clipSpacePatchCorners, then the app is just the blue sky ...
20 - Dec - 2013
Slavina
As a quick followup: the segfault caused by terraintesselation.tcs was happening during the calculation of max(gl_TessLevelOuter[1], gl_TessLevelOuter[3]). Accessing the array values directly in that function was causing a problem. I copied them in local variables and passed to the max() function, then the shader compiled and linked fine. However, the application showed only the blue sky, no terrain. I figured the 'else' clause might have to do something with it (it sets gl_TessLevelOuter and gl_TessLevelInner to 0.0). After commenting the else {} contents out, the terrain did show, but with odd behavior. The individual patches were flickering. The app looks ok if terraintesselation.tcs fails to compile.
26 - Feb - 2014
Johan
I didn't see a license notice in the source download.
Can I use your example code in an open source project I'm developing? It will most likely be licensed under the zlib license or another permissive license.
26 - Feb - 2014
Sean Harmer
Please feel free to do so. A link back to here would be appreciated.
4 - Mar - 2014
Bernd Dreier
Hi, I'm trying to run your example code on a new Macbook Pro running OSX Mavericks, because I have problems with my own code. However, I get the same errors during runtime, i.e. during compile time of the tesselation shaders with your example: QOpenGLShader::compile(): ERROR: 0:6: Invalid use of layout 'vertices' ERROR: 0:15: Use of undeclared identifier 'gl_InvocationID' and more... Any hints or thoughts? Bernd
4 - Mar - 2014
Sean Harmer
Which version OpenGL context are you getting back from Mavericks? Not all Mavericks hw is capable of OpenGL 4. Some devices will only give you and OpenGL 3.2 core profile context. Admittedly I've not tried this on Mavericks myself yet so there could be other bugs/problems.
5 - Mar - 2014
Bernd Dreier
I get back a 4.1 context as expected. I'm on Qt 5.2.1 now - the versions before had a bug, which gave you back always the version you demanded - not the one you really have. But this is solved. It's a NVidia GT750m, which should be able to do GLSL 4.1 ...
17 - Mar - 2014
Bernd Dreier
No one out there with the same problem? No hints? Bernd
17 - Mar - 2014
Sean Harmer
Sorry really busy lately. I'll look into this in the near future.
31 - Mar - 2014
Bernd Dreier
I have almost sorted it out: There is a bug in compiling tesselation shaders in Qt. If I compile (only) the tesselation Shaders with the native OpenGL-Funcs, the example works! However, I see the textures only randomly, but this will have others reasons, I assume. Somebody should track down the compilation of tesselation shaders in Qt... Bernd
9 - Oct - 2014
Evan
I also have the exact error output. Qt 5.3, OSX 10.9.4. OpenGL context is 4.1.
15 - Mar - 2014
sargas
Hi, I want to ask, why the screen flickers white from time to time?
22 - May - 2014
Francisco Boni
I tried to run the source with a compatibility context and I couldn't get it run properly. It was crashing when I call versionFunctions() (segfault)
It seems QOpenGLContext create(), after setting the QSurfaceFormat properly, was completely rejecting the compatibility setting and creating a Core context instead, completely ignoring my request for a compatibility context (format.setProfile( QSurfaceFormat::CompatibilityProfile).
I discovered the case. In the original code at kdab:
by creating the context (create()) before setFormat, I was able to correctly initiate a proper Compatibility Context. It seems that the original source needs to be fixed.
22 - May - 2014
Francisco Boni
It seems I've got lucky with the AMD drivers and the context is not to be created before setFormat:
"Creating the context before setFormat() is wrong and works by accident since what you are requesting then is a plain OpenGL 2.0 context and the driver most likely gives you 4.3 compatibility. On other drivers or platforms this may fail so be careful. The behavior you are seeing is caused by the AMD driver: it refuses to create a proper compatibility profile context unless the forward compatibility set is not set. Qt sets the fwdcompat bit by default, it can be turned off by setting the DeprecatedFunctions option on the QSurfaceFormat. So requesting for Compatibility together with DeprecatedFunctions will give what you want. Other vendors’ drivers do not have this problem, there not setting DeprecatedFunctions (i.e. setting forward compatibility) is ignored for compatibility profiles, as it should be."
29 - Mar - 2015
HGH
Is it possible to create OpenGL context without QApplication, without a window/widgets?
The use case: console application for offscreen rendering or just compute shaders?
29 - Mar - 2015
Sean Harmer
Yes. You can use QGuiApplication, QOpenGLContext and QOffscreenSurface. Just don't create or show any widgets or windows and render into an FBO render target.
12 - May - 2015
Brian
Hi, So I am trying to use the QOpenGLFunctions_MAJOR_MINOR system, but it seems to stop at OpenGL 4.3? How can I get access to OpenGL 4.4 and 4.5? A look through the Qt 4.5.1 install I have on Windows backs this up, no files for 4.4 and 4.5. I've also been puzzled no one else has come across this issue. Thanks,
12 - May - 2015
Sean Harmer
Coming in Qt 5.5 any time now. Beta snapshots are available for download.
5 - Nov - 2015
Alexey
Good day! I try to run example of code published here as "terrain tesselation" and my IDE can not run this example because these errors happened: undefined reference to '_imp__glDeleteTextures@8'; 'undefined reference to _imp__glGenTextures@8'; undefined reference to '_imp__glBindTeture@8'; undefined reference to '_imp__glTexImage2D@36'. I didn't some changes in source code. Please tell me what should i do to run example? My system description: renderer is GeForce GTX750 Ti/PCIe/SSE2 2048Mb, OpenGL version is 4.4, Driver vercion 10.18.13.5597 Forceware, Windows 7 x64. IDE: QTCreator 3.4.2 (it uses QT libs 5.5.0 and compiler MinGW 492_32). Thanks!