klampt.vis.glutbackend module

class klampt.vis.glutbackend.GLUTBackend[source]

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.

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

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

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

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
clearColor

the RGBA floating point values of the background color.

Type:list of 4 floats
glutInitialized

true if GLUT has been initialized

Type:bool

Note: must be called after GLUT is initialized.

add_action(*args)[source]
close()[source]
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) –
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.

initialize()[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.

reshape(w, h)[source]

Resizes the GL window. Called by frontend.

setProgram(program)[source]