Reputation: 65
I recently decided to start learning OpenGL, and I have a few questions. Mainly, I am wondering if OpenGL depends on a windowing system such as GTK+ and an extension to the windowing system's API that allows OpenGL regions to be created. I've also seen something along the lines of Xlib on the OpenGL Wiki, which seems to be a more direct connection into the X-Windowing System. Is Xlib just a more basic windowing system, or can windows entirely controlled by OpenGL be created? In the case that both are possible, which is the more widely accepted standard?
Upvotes: 1
Views: 669
Reputation: 45322
OpenGL's specification is compelely agnostic with respect to window systems. As far as OpenGL is concerned, there are no windows. All there is in this regard is the system-provided default framebuffer (FBO 0), which typically is connected to some window - however, this does not have to be the case. For example, there are pbuffers, which are a way to generate an OpenGL context without having a visible window at all.
All of these matters are platform dependent and thus outside the scope of OpenGL itself, but a set of platform-dependent APIs:
EAGL
, which is especially relevant for iOS devices like iPhone and iPad.GTK+ on the other hand is just some sort of widget library. It will use the underlying APIs of the platform to do its things, and it will rely on the platform-specific GL context APIs to implement the GL-specific features. It is the same with Qt.
Is Xlib just a more basic windowing system, or can windows entirely controlled by OpenGL be created?
xlib is the library implementing the X protocol, so it is the most low-level API (except of reimplementing the X protocol manually) when you are working with the X Window system. GTK+ will use it on such a platfrom, too.
Windows are never controlled by the GL. You will always need some platform-dependent method to create and manage the windows, and neither OpenGL nor the GL context APIs are going to help you much with that.
If you do just want a window to use with GL, using GUI toolkits like GTK+ or Qt might be overkill. There are some simple OpenGL window and context management libs like GLFW or freeGLUT (which is the only currently still actively developed implementation of the GLUT specification) which are also abstracting the platform-specific APIs. If you are trying to build a game or multimedia software, libraries like SDL and SFML might also be worth a look, as they provide a set of abstractions for other concepts besides GL, especially audio.
Upvotes: 7