Table of Contents
In this chapter you will learn the basic concepts of libUFO.
There are three sub-sections which explain the basic parts of the "Hello, World!" example.
Before creating any other UFO object, you have to create the UFO toolkit.
This can be done by creating an instance of
UXToolkit
UXToolkit tk;
The toolkit does some basic initialization, loads external modules and sets up some UFO properties.
UToolkit
itsself is a pure virtual class which
may be implemented by yourself to give full control over global UFO methods.At next, you have to create a connection to the underlying windowing system to open an OpenGL window.
This can be done by creating an instance of
UXDisplay
UXDisplay display;
The Display is responsible for loading system ressources (e.g. libraries like OpenGL, the windowing library like X11, Win32, QT etc).
UDisplay
itsself is a pure virtual class which
may be implemented by yourself to give full control over UFO windowing.You can specify explicitly which video driver you want to load by
using a string argument which describes the video driver.
At the time of writing, this may be GLX
,
WGL
, SDL
, or
dummygl
, if you want to load all system ressources
yourself and open an OpenGL window yourself
(see also Integrating libUFO into existing
applications).
The UFO extension module (UX) contains a simple windowing manager. If you have created a display object, you can now create your first UFO frame (remember: The display object is responsible for system ressources.
This section is only relevant if you have already your own OpenGL window and you want to draw UFO widgets within this window.
The procedure is slightly different: You have to use the dummygl video driver and create a custom UFO context for use with your window.
Furthermore, you have to pump system events yourself (see also Integrating into existing applications).
Example 2.3. Custom OpenGL windows
This example shows how to set up libUFO for use with custom OpenGL windows.
UXToolkit tk; // Your OpenGL window should be open at this time UXDisplay display("dummygl"); // The bounding rectangle of your OpenGL window URectangle deviceBounds(0, 0, 640, 480); // The desired bounding rectangle of the UFO context within // that OpenGL window URectangle contextBounds(0, 0, 640, 480); UXContext context(deviceBounds, contextBounds);