Main contents


GLGUI is a visualization and Windowing library for OpenGL. To be more precise it is a collection of helpful functions for visualizing stuff and a set of classes for windowing. With GLGUI you can make a 2D panel into 3D OpenGL world. You can attach RGB images and various kind of buttons into it to have controls.

This package is tested only on Linux, and comes only with Linux makefile, but there should not be anything that would not compile on windows also.

Download 1.0


To unpack:

tar -xvvf GLGUI_1.0.tar

To compile and run:



html – The doxygen documentation
inc – all needed headers
icons – the icons needed by the test program


README - Readme file
LICENSE - BSD sort of License(I don't care what you do with the software, just don't blame of anything) 
Makefile – A linux makefile to compile the example program
SDLBase.cpp – The example program

GUIPanel files

GUIPanel.cpp – The 2D panel container for the OpenGL
Button.cpp – Button for GUIPanel
RadioButtonGroup.cpp – Radiobuttongroup for GUIPanel
RGBScreen.cpp – RGB Screen for GUIPanel
TextureLabel.cpp – Static texture label for GUIPanel


RGBImage.cpp – A class for RGB Image manipulation 
CGLHeightMap.cpp  - A class that draws height map (float matrix) in 3D 
GLUtils.cpp – A class that has some helpful 3D primitives for OpenGL
ownutils.c – Cross platform library for threading, mutexes and stuff like that
JPEGDecoder.cpp – A library for decoding JPEG images

Required libraries

You need to have OpenGL, GLUtils, SDL and libjpeg developmen packages installed (and libraries).


The GUIPanel is a 2D GUI window in 3D. It is a “container” for implemented components. The ideology is that you think the window as 2D plane (the origin is the center of the panel). You create an object with 2D position, which is relative to GUIPanel. The you add the object to the panel, and the panel takes care of the rest.

An example

panel = new glutgui::GUIPanel(1,20,20,"icons/kuva.jpg");
panel->addButton( (new glutgui::Button(105,"icons/buttonup_sq.jpg",

GUIPanel in mini-HUD mode

GUIPanel HUD mode

First a 20x20 (in 3D these are meters) panel is created. Then 1.0x1.0 button is created and it is placed to position (-4,5;9,5). Simple as that... All GLPanel components are under namespace glutgui (old remedy, none of the GLGUI classes require glut).

The panel has four buttons/icons:

  • move
  • rotate
  • HUD (head-up-display)
  • mini-HUD

In move mode, you can move the panel by clicking mouse on top of it and dragging the panel around. Mouse scroll will move the height. In rotation mode you can rotate the panel by clicking and moving mouse. The mouse scroll rotates around z. in HUD mode the panel is just a 2D projection in full screen mode. in mini HUD mode the panel is projected in 2D but leaves part of the 3D visible. In mini HUD mode you can move the panel in window and selecting the “move” mode will enable scaling by using the mouse scroll.

ID system

All Buttons, Screens, etc require an ID. The id should be unique for all objects. The Id is used when callback functions are called and it is the only way for you to know, which object is being pressed.


A button is, well button, for the GUIPanel. The button constructor wants texture (JPEG) files for up and down states, the size of the button and the position in the panel. Additionally, you may define if the button is state preserving. This means that when you press the button, it will switch state, but not switch back when you release. Pressing a button will cause a button event.


Radio button group is a special container for buttons. You may add any number of buttons into radio button group. The radio button group will then take care that one-and-only-one of those buttons is pressed at a time. When you press another one, the other is released. Pressing a button will cause a button event.


RGBScreen is a frame for displaying any RGB data. The rgb is given as char pointer and the screen takes care of the displaying the image (Note that RGB image is 3*Nx*Ny sized!!). There is a RGBImage class in the package, which is an helper class for drawing different things into RGB image. Clicking RGBScreen will cause position event. The position is returned relative to given RGBScreen size. The origin is in the center of the screen (positive x is left and positive y up).


Texture label is just a static texture that you may put into the panel. This partly correcting the fact that I haven't been able to do 3D fonts in system in depended way... probably never will.


You can, and you should, set callbacks for Button events and Screen position events. A button event will be reported when button changes state (when you press or release the button). A screen position event returns the position from RGB screen you clicked in the screen coordinates.

Input events for the panel

The panel needs mouse events from SDL. This part is not particularly beautiful at the moment, but I hope the example program clarifies:

if(event.button.button == SDL_BUTTON_LEFT)
else if(event.button.button ==5)
else if(event.button.button == 4) 
  if(event.button.button == SDL_BUTTON_LEFT) 
if(event.motion.state ==SDL_BUTTON_LEFT) 


  • No font support
  • Only JPEG images supported
  • All textures MUST be sized as 2^(n) x 2^(m) (2,4,16... you know)
  • Usability requires plenty of work
  • In HUD mode your panel should have same dimensions as your monitor, otherwise there will be some scaling (not serious, but might not look good)

Coordinate frame

The coordinate frame of OpenGL is not very intuitive, at least to my opinion. In GLGUI is most of the time used mathematical frame of reference. There are at least the Camera class that does not follow this rule. The example program shows the coordinate frame (positive x is right and positive z is the height).


API documentation can be found from GLGUI/html directory.