demosys.context.headless.Window¶
-
demosys.context.headless.
Window
¶ Headless window using a standalone
moderngl.Context
.
Methods¶
-
Window.
__init__
()¶ Creates a standalone
moderngl.Context
. The headless window currently have no event input from keyboard or mouse.Using this window require either
settings
values to be present:HEADLESS_FRAMES
: How many frames should be rendered before closing the windowHEADLESS_DURATION
: How many seconds rendering should last before the window closes
-
Window.
draw
(current_time, frame_time)¶ Calls the superclass
draw()
methods and checksHEADLESS_FRAMES
/HEADLESS_DURATION
-
Window.
use
()¶ Binds the framebuffer representing this window
-
Window.
should_close
() → bool¶ Checks if the internal close state is set
-
Window.
close
()¶ Sets the internal close state
-
Window.
resize
(width, height)¶ Resizing is not supported by the headless window. We simply override with an empty method.
-
Window.
swap_buffers
()¶ Headless window currently don’t support double buffering. We only increment the frame counter here.
-
Window.
terminate
()¶ No teardown is needed. We override with an empty method
Other Inherited Methods¶
-
Window.
set_default_viewport
()¶ Calculates the viewport based on the configured aspect ratio in settings. Will add black borders if the window do not match the viewport.
-
Window.
cursor_event
(x, y, dx, dy)¶ The standard mouse movement event method. Can be overriden to add new functionality. By default this feeds the system camera with new values.
Parameters: - x – The current mouse x position
- y – The current mouse y position
- dx – Delta x postion (x position difference from the previous event)
- dy – Delta y postion (y position difference from the previous event)
-
Window.
keyboard_event
(key, action, modifier)¶ Handles the standard keyboard events such as camera movements, taking a screenshot, closing the window etc.
Can be overriden add new keyboard events. Ensure this method is also called if you want to keep the standard features.
Parameters: - key – The key that was pressed or released
- action – The key action. Can be ACTION_PRESS or ACTION_RELEASE
- modifier – Modifiers such as holding shift or ctrl
-
Window.
clear
()¶ Clear the window buffer
-
Window.
clear_values
(red=0.0, green=0.0, blue=0.0, alpha=0.0, depth=1.0)¶ Sets the clear values for the window buffer.
Parameters: - red (float) – red compoent
- green (float) – green compoent
- blue (float) – blue compoent
- alpha (float) – alpha compoent
- depth (float) – depth value
-
Window.
print_context_info
()¶ Prints moderngl context info.
Attributes¶
-
Window.
size
¶ (width, height) tuple containing the window size.
Note that for certain displays we rely on
buffer_size()
to get the actual window buffer size. This is fairly common for retina and 4k displays where the UI scale is > 1.0
-
Window.
buffer_size
¶ (width, heigh) buffer size of the window.
This is the actual buffer size of the window taking UI scale into account. A 1920 x 1080 window running in an environment with UI scale 2.0 would have a 3840 x 2160 window buffer.
-
Window.
keys
= None¶