Abstract base for an application window. Subclasses bind a specific platform/renderer pair (see WindowGlfw, WindowSdl) and forward lifecycle hooks back to the owning Application via #owner. Direct subclassing is supported but the supported integration path is to e
| 9 | * {@link Application} and select a backend through {@link Configuration#setBackend(Backend)}. |
| 10 | */ |
| 11 | public abstract class Window { |
| 12 | /** |
| 13 | * Background color of the window. |
| 14 | */ |
| 15 | protected final Color colorBg = new Color(.5f, .5f, .5f, 1); |
| 16 | |
| 17 | /** |
| 18 | * Application owning this window. Set by {@link Application#launch(Application)} prior to |
| 19 | * {@link #init(Configuration)}. Concrete windows invoke its lifecycle hooks |
| 20 | * ({@link Application#initImGui(Configuration)}, {@link Application#preProcess()}, |
| 21 | * {@link Application#process()}, {@link Application#postProcess()}, |
| 22 | * {@link Application#disposeImGui()}). |
| 23 | */ |
| 24 | protected Application owner; |
| 25 | |
| 26 | /** |
| 27 | * Wires the owning application. Package-private; called by {@link Application#launch(Application)}. |
| 28 | * |
| 29 | * @param owner application driving this window |
| 30 | */ |
| 31 | final void setOwner(final Application owner) { |
| 32 | this.owner = owner; |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Initializes the window and its platform/renderer backends. |
| 37 | * |
| 38 | * @param config configuration object with basic window information |
| 39 | */ |
| 40 | protected abstract void init(Configuration config); |
| 41 | |
| 42 | /** |
| 43 | * Releases all resources owned by the window and its backends. |
| 44 | */ |
| 45 | protected abstract void dispose(); |
| 46 | |
| 47 | /** |
| 48 | * Main application loop. Drives {@link #runFrame()} until the window is asked to close. |
| 49 | */ |
| 50 | protected abstract void run(); |
| 51 | |
| 52 | /** |
| 53 | * Renders a single frame: pumps platform events, calls back into {@link #owner}'s |
| 54 | * {@link Application#preProcess()} / {@link Application#process()} / {@link Application#postProcess()} |
| 55 | * hooks, and submits the frame to the renderer. |
| 56 | */ |
| 57 | protected abstract void runFrame(); |
| 58 | |
| 59 | /** |
| 60 | * @return {@link Color} instance, which represents background color for the window |
| 61 | */ |
| 62 | public final Color getColorBg() { |
| 63 | return colorBg; |
| 64 | } |
| 65 | } |
nothing calls this directly
no outgoing calls
no test coverage detected