Table of Contents
If you have already an existing application and you want to integrate a GUI, this is the right chapter for you.
Example 6.1. Custom OpenGL contexts
// create your OpenGL context
// creates the toolkit and loads necessary plugins
// this may be at any point before all other UFO calls
UXToolkit tk;
// Loads system resources
// You must have a valid OpenGL context at this time
UXDisplay display("dummygl");
// Instead of a frame like in normal application, just create a libUFO context
//
// deviceBounds is the bounding rectangle of your GL context
// contextBounds is the desired bounding rectangle of your UFO context within
// the GL contex (usually 0,0 and size of deviceBounds)
UXContext context(deviceBounds, contextBounds);
// you may make the root pane transparent so that UFO does not overwrite
// your own drawing
// context.getRootPane()->setOpaque(false);
// add your widgets
context.getContentPane()->add(new ULabel("label");
// more of your code, your main loop
{
// you have to pump the input events manually to the UFO event queue
display.pushKeyDown(&context, keyCode, unicodeChar);
display.pushMouseMove(&context, x, y);
// etc.
// dispatch and process events
display.dispatchEvents();
// draw the libUFO context
context.repaint();
}
A full example is given in test/sdl.cpp and
test/glut.cpp