I understand the purpose of GTK, QT or other graphic toolkits. But I don't understand the role of OpenGL. Is it just another GUI-library or does it refer to something more fundamental? If so, what is it and when should I use it in day-by-day hacking?
now that GTK+ supports OpenGL natively (at least on Linux and Windows) it's probably a good time to show how to properly use OpenGL with GTK+.
After a rewrite, the toolkit became GTK+ and saw release in 1998. Unlike Qt, people had the freedom to edit, modify, and share GTK+ from the beginning. While Qt is in some ways a more versatile and adaptable toolkit, a community consolidated around GTK+ during these early years.
The Qt OpenGL module makes it easy to use OpenGL in Qt applications. It provides an OpenGL widget class that can be used just like any other Qt widget, except that it opens an OpenGL display buffer where you can use the OpenGL API to render the contents.
OpenGL is just the graphics library. Java is a porgramming language and Unity3D is a game engine. Games can use OpenGL while still being coded using Java and Unity3D uses OpenGL on platforms that aren't Windows.
OpenGL is a library for drawing graphics on a low level. It excels mainly at 3D graphics. The most important competitor to OpenGL is Direct3D (not the whole DirectX).
GL is only really powerful if you have it hardware accelerated. Today, almost every desktop or laptop solution has GL acceleration, but on some systems where the graphics card is integrated into the chipset, it is still rather slow.
For day-by-day hacking, GL can serve many unusual purposes. The reason is that you can leverage the GPU's processing power for graphic related tasks. For anything non-graphical, newer languages like CUDA exist as well to access the GPU.
While GL's real strengths lie in 3D scene rendering, it is often also used for 2D manipulation or composition. The reason is that 2D acceleration architectures of graphics cards often don't reach the power (freedom) or performance of GL. That's why sometimes GL is used for video output (mainly scaling) or blending tasks, even if specific 2D acceleration for these tasks would be available. Mac OS X is a prominent example of a whole desktop (optionally) being rendered through GL to allow appealing effects without high CPU load. But it can also be used for example to blend anti-aliased text glyphs onto a textured background.
As soon as you do a graphical, performance critical task, you will probably want the GPU to help out (possible even if you don't draw on screen) and then OpenGL is the clean, standardized, cross-platform answer to your needs. Today's GUI toolkits mostly don't offer you GPU-accelerated drawing, but the inclusion of GL rendering into their widgets. So you can use them for UI drawing and include your performance critical realtime graphics where it suits. Building a whole UI inside GL is a pain, but there are also solutions for that available (typical use cases are games with in-game UI).
It's something more fundamental. OpenGL lets you perform low-level drawing (think "draw a line from here to here" rather than "draw a button"). OpenGL operations are also often hardware accelerated and thus very efficient, and the OpenGL API allows you to easily work with 3D.
Choosing between OpenGL and a GUI toolkit like QT or GTK really depends on whether you're trying to draw UI elements for your application or want very fine control over how your graphics are drawn.
Sometimes, GUI toolkits employ OpenGL under the covers in order to draw their on-screen elements.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With