Graphics Setup
Before you can use pystk2 you need to setup the OpenGL rendering engine and graphics settings.
There are three default settings GraphicsConfig::ld (lowest), GraphicsConfig::sd (medium), GraphicsConfig::hd (high).
Depending on your graphics hardware each setting might perform slightly differently (ld fastest, hd slowest).
To setup pystk2 call:
pystk2.init(pystk2.GraphicsConfig.hd())
# Only call init once per process
... # use pystk2
pystk2.clean() # Optional, will be called atexit
# Do not call pystk2 after clean
Headless rendering
If you want GPU rendering (to access render_data) but don’t need the on-screen window to update,
set display=False on the graphics config:
config = pystk2.GraphicsConfig.hd()
config.display = False
pystk2.init(config)
This initializes the full OpenGL context and render targets, so race.render_data will
contain color, depth, and instance segmentation buffers, but the display window is not
refreshed each step. This is useful for RL training where you only need pixel observations
without visual output.
To fully disable rendering (no OpenGL context at all), use GraphicsConfig.none().
- class pystk2.GraphicsConfig
SuperTuxKart graphics configuration.
- static hd() pystk2.GraphicsConfig
High-definitaiton graphics settings
- static ld() pystk2.GraphicsConfig
Low-definition graphics settings
- static none() pystk2.GraphicsConfig
Disable graphics and rendering
- static sd() pystk2.GraphicsConfig
Standard-definition graphics settings
- property animated_characters bool property
Animate characters
- property bloom bool property
Enable the bloom effect
- property degraded_IBL bool property
Disable specular IBL
- property display_adapter int property
GPU to use (Linux only)
- property dof bool property
Depth of field effect
- property dynamic_lights bool property
Enable dynamic lighting
- property glow bool property
Enable glow around pickup objects
- property high_definition_textures int property
Enable high definition textures 0 / 2
- property light_shaft bool property
Enable light shafts
- property mlaa bool property
Enable anti-aliasing
- property motionblur bool property
Enable motion blur
- property particles_effects int property
Particle effect 0 (none) to 2 (full)
- property render bool property
Is rendering enabled?
- property display bool property
Is on-screen display enabled? When
render=Trueanddisplay=False, GPU rendering runs but the window is not updated.
- property screen_height int property
Height of the rendering surface
- property screen_width int property
Width of the rendering surface
- property ssao bool property
Enable screen space ambient occlusion
- property texture_compression bool property
Use texture compression
- pystk2.init(config: pystk2.GraphicsConfig) None
Initialize Python SuperTuxKart - this will download the game assets if not already done. Only call this function once per process. Calling it twice will cause a crash.
- pystk2.clean() None
Free Python SuperTuxKart, call this once at exit (optional). Will be called atexit otherwise.