MXVK Vulkan Framework 0.35.0
C++20 Vulkan rendering framework for practical 2D and 3D application development with SDL3.
Loading...
Searching...
No Matches
main.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2## @file main.py
3## @brief Minimal standalone MXVK Python window example.
4## @details Creates a @c Window directly, sets a clear color, runs the event
5## loop with vsync, and explicitly releases Vulkan resources on shutdown.
6## This is the starting point for applications that do not need custom sprite,
7## input, or model callbacks.
8##
9## @section window_run Running the example
10## @code{.sh}
11## python3 python-examples/window/main.py
12## @endcode
13## @section window_lifecycle Lifecycle
14## The @c finally clause calls @c release() even if the event loop raises, which
15## is the required explicit shutdown step for a directly constructed window.
16"""Open a minimal MXVK window from Python."""
17
18try:
19 import mxvk_ext as mxvk
20except ImportError as error:
21 raise SystemExit(
22 "Could not import mxvk_ext. Build with -DPYTHON_MODULE=ON and run with:\n"
23 " PYTHONPATH=build python3 python-examples/window/main.py"
24 ) from error
25
26
27def main() -> None:
28 window = mxvk.Window(
29 "MXVK Python Window",
30 960,
31 540,
32 fullscreen=False,
33 validation=False,
34 present_mode=mxvk.PresentModePreference.vsync,
35 runtime_mode=mxvk.RuntimeMode.windowed,
36 )
37 window.set_clear_color(0.06, 0.09, 0.16, 1.0)
38
39 try:
40 window.loop()
41 finally:
42 window.release()
43
44
45if __name__ == "__main__":
46 main()
Definition main.py:1