klampt.vis.glutbackend module

class klampt.vis.backends.glutbackend.GLUTWindow(name)[source]

Bases: object

A GLUT window. Should not be used directly.

name

title of the window (only has an effect before calling run())

Type

str

index

the GLUT index

Type

int

width, height

width/height of the window (only has an effect before calling run(), and these are updated when the user resizes the window.

Type

int

glutInitialized

true if GLUT has been initialized

Type

bool

Note: must be called after GLUT is initialized.

initialize()[source]
add_action(*args)[source]
setProgram(program)[source]
modifiers()[source]

Call this to retrieve modifiers. Called by frontend.

refresh()[source]

Call this to redraw the screen on the next event loop. Called by frontend.

idlesleep(duration=inf)[source]

Sleeps the idle callback for t seconds. If t is not provided, the idle callback is slept forever. Called by frontend.

reshape(w, h)[source]

Resizes the GL window. Called by frontend.

draw_text(point, text, size=12, color=None)[source]

Renders text at the given point (may be 2d or 3d). Frontend should call this to draw text in either the display or display_screen method.

Parameters
  • point (list of floats) – either a 2d or 3d point at which to draw the text

  • text (str) – the text to draw

  • size (int, optional) – if given, it renders a font in the given size.

  • color (list of 3 or 4 floats) –

close()[source]
class klampt.vis.backends.glutbackend.GLUTBackend[source]

Bases: object

A basic OpenGL program using GLUT. Set up your GLProgramInterface class, call addPlugin(plugin), then call run() to start the GLUT main loop.

NOTE: the run() call may not return depending on your GLUT system.

For more control over windowing, you can use the createWindow function to construct new windows and addPlugin to add plugins to those windows.

IMPORTANT NOTE: only one window may be created for a given world. If you want to use multiple windows, then a new world should be loaded for each world.

initialize(program_name)[source]
createWindow(name)[source]
run()[source]

Starts the main loop. NOTE: if freeglut is not installed, this will not return.