Skip to content

Pi3D Display

tipam edited this page Jul 3, 2012 · 6 revisions

The following describes Pi3D's display functions:

pi3d.display

Parameters: display()

Return: display_object

Example:

display = pi3d.display()

Description:

Initiates the pi3d module and returns a display object for creating a window.

display_object.create2D

Parameters: create2D( x = 0, y = 0, width = screen_width, height = screen_height, bitDepth = 24)

Return: None

Examples:

display.create2D(100,100,600,400,32) # A window at 100,100, size 640x400 with a 32bit z-buffer

display.create2D() # A full screen window with 24bit z-buffer as default

Description:

Creates a 2D window with an x,y position (top-left), width and height. The z-buffer can also be specified. The window is pixel resolution with X,Y axis originating from the bottom left corner.

display_object.create3D

Parameters: create3D( x = 0, y = 0, width = screen_width, height = screen_height, bitDepth = 24)

Return: None

Examples:

display.create3D(100,100,600,400,32) # A window at 100,100, size 640x400 with a 32bit z-buffer

display.create3D() # A full screen window with 24bit z-buffer as default

Description:

Creates a 3D window with an x,y position (top-left), width and height. The z-buffer can also be specified. The window will draw objects in 3D perspective. The origin is in the centre of the window ranging from 0 to 500 in the z-buffer.

display_object.destroy

Parameters: destroy()

Return: None

Examples:

display.destroy() #destroy the current OpenGL context and window

Description:

Destroys the current window and all it's contents (including vertices, textures and so on). The window must be recreated and have the context reassigned to the new window. This routine is used for repositioning, resizing and closing the window.

display_object.swapBuffers

Parameters: swapBuffers()

Return: None

Examples:

display.swapBuffers() #swap the display buffers after drawing a scene

Description:

Swaps between two display buffers. A scene is drawn into one of the buffers which is hidden. When this routine is called, the buffer is then displayed. The second buffer is then hidden, waiting to be drawn into and so on.

display_object.clear

Parameters: clear()

Return: None

Examples:

display.clear() #Clear the display buffer before anything is drawn into it (both colour and z-buffers cleared)

Description:

Clears the hidden display buffer and must be called before anything is drawn into it. The background colour is set with display.setBackColour.

display_object.setBackColour

Parameters: setBackColour(red = 1, green = 1, blue = 1, alpha = 1)

Return: None

Examples:

display.setBackColour(0.0, 0.0, 1.0, 1.0) #Back colour set to solid blue

Description:

Sets the background colour for clearing the window. Note that if alpha is set to 0.0, the window is completely transparent and the scene will be drawn over the desktop. If alpha is set to 1.0, the window is completely opaque.

display_object.screenshot

Parameters: screenshot( filestring )

Return: None

Examples:

display.screenshot("screenshot3d.jpg")

Description:

Snapshot the display and save it as an image file (jpg, png for example)

See the Python Imaging Library for more information on save file types