peng3d.window - Windowing with batteries included

class peng3d.window.PengWindow(peng, *args, **kwargs)[source]

Main window class for peng3d and subclass of pyglet.window.Window().

This class should not be instantiated directly, use the Peng.createWindow() method.

addMenu(menu)[source]

Adds a menu to the list of menus.

changeMenu(menu)[source]

Changes to the given menu.

menu must be a valid menu name that is currently known.

Changed in version 1.2a1: The push/pop handlers have been deprecated in favor of the new Menu.on_enter(), Menu.on_exit(), etc. events.

dispatch_event(event_type, *args)[source]

Internal event handling method.

This method extends the behavior inherited from pyglet.window.Window.dispatch_event() by calling the various handleEvent() methods.

By default, Peng.handleEvent(), handleEvent() and Menu.handleEvent() are called in this order to handle events.

Note that some events may not be handled by all handlers during early startup.

menu

Property for accessing the currently active menu.

Always equals self.menus[self.activeMenu].

This property is read-only.

on_draw()[source]

Clears the screen and draws the currently active menu.

run(evloop=None)[source]

Runs the application in the current thread.

This method should not be called directly, especially when using multiple windows, use Peng.run() instead.

Note that this method is blocking as rendering needs to happen in the main thread. It is thus recommendable to run your game logic in another thread that should be started before calling this method.

evloop may optionally be a subclass of pyglet.app.base.EventLoop to replace the default event loop.

set2d()[source]

Configures OpenGL to draw in 2D.

Note that wireframe mode is always disabled in 2D-Mode, but can be re-enabled by calling glPolygonMode(GL_FRONT_AND_BACK, GL_LINE).

set3d(cam)[source]

Configures OpenGL to draw in 3D.

This method also applies the correct rotation and translation as set in the supplied camera cam. It is discouraged to use glTranslatef() or glRotatef() directly as this may cause visual glitches.

If you need to configure any of the standard parameters, see the docs about Configuration Options for peng3d.

The graphics.wireframe config value can be used to enable a wireframe mode, useful for debugging visual glitches.

set_fps(fps)[source]

Sets the new FPS limit.

This limit will be used until the application closes or this method is called again.

A value of None will cause the FPS limit to be disabled.

Note that this is only a limit, which may or may not be fulfilled depending on available resources.

Note

By default, pyglet only redraws the window when an event arrives. To force a certain redraw rate (which still respects system performance), call pyglet.clock.schedule_interval() once during initialization with a dummy function and your desired refresh rate in seconds.

Parameters:fps
Returns:
setup()[source]

Sets up the OpenGL state.

This method should be called once after the config has been created and before the main loop is started. You should not need to manually call this method, as it is automatically called by run().

Repeatedly calling this method has no effects.

setupFog()[source]

Sets the fog system up.

The specific options available are documented under graphics.fogSettings.

setupLight()[source]

Sets the light system up.

The specific options available are documented under graphics.lightSettings.

Note that this feature is currently not implemented.

toggle_exclusivity(override=None)[source]

Toggles mouse exclusivity via pyglet’s set_exclusive_mouse() method.

If override is given, it will be used instead.

You may also read the current exclusivity state via exclusive.