Search Contact information
University of Cambridge Home Department of Engineering
University of Cambridge >  Engineering Department >  computing help

GLUE

Note: C++ doesn't have graphics. The graphics routines that we've added might not be used elsewhere. You won't be examined on them.

GLUE is a Graphics Library for Undergraduate Education which is designed for use by students learning C++.

When you write a graphical program, you need to cope with the user resizing or uncovering the window at any moment. In practise it means that graphical programs will be structured differently to non-graphical ones, ready to react to the user's actions. With GLUE all you need to do is to define which function to run in these circumstances - GLUE will call it for you at the right time. GLUE offers you the chance to respond to key-presses and mouse-clicks too. Here's a simple example - the code on the left and the program on the right.

// Compile using
// g++ -I/usr/local/include -I/usr/include/GL -L/usr/local/lib 
//     ... -lglue -lglui -lglut -lGLU -lGL
#include "glue.h"

void mygraphics(int w, int h) {
  color(BLUE);
  text("hello", 150,h/2);
}

int main() {
  glueWindow();  
  graphicsfunction (mygraphics);
  glueGo();
}
glue

Coordinates

A note about C++ parameter default values

In C++ you don't always need to supply all the parameters to a function. The routines below use this facility to help make your programs shorter. Any parameter mentioned below with a = sign after it can be left out as long as there are no more following parameters. The omitted parameters are given the stated default values. So glueWindow(500,500) is legal, setting the window's width and height to 500, but using the default values for the other parameters.

Routines

See Also

Back to top
© Cambridge University Engineering Dept
Information provided by Professor Roberto Cipolla
Last updated: May 2008