public abstract class Application extends Window
The entry point for ImGui applications is the Application class and launch(Application)
method.
It initializes application instance and starts the main application loop.
configure(Configuration)
It's called before window creation, so only basic application setups are expected.Window.initWindow(Configuration)
Method creates application window.Window.initImGui(Configuration)
Method initializes Dear ImGui context. Could be used to do Dear ImGui setup as well.preRun()
Method called once, before application loop.Window.preProcess()
Method called every frame, before Window.process()
.Window.process()
Method is meant to be overridden with user application logic.Window.postProcess()
Method called every frame, after Window.process()
.postRun()
Method called once, after application loop.Window.disposeImGui()
Destroys Dear ImGui context.Window.disposeWindow()
Destroys application window.As it could be seen, ImGui application differs from the classic one in the way of its life-cycle flow. Instead of creating widgets and adding listeners to them we have an application loop where everything is handled right away. Read more about Immediate GUI mode to understand that paradigm better.
The simplest application example could be done in the next way:
import imgui.ImGui;
import imgui.app.Application;
public class Main extends Application {
@Override
public void process() {
ImGui.text("Hello, World!");
}
public static void main(final String[] args) {
launch(new Main());
}
}
As its said, Window.process()
method is meant to be overridden. All your application logic should go there.
Unlike other Java applications, ImGui is about "one thread for everything". You still can use multi-threading, but be careful.
For example, large list of computations could be separated between application ticks. Window.process()
method is called constantly.
Use that wisely and remember that all GUI should be in the main thread.
Constructor and Description |
---|
Application() |
Modifier and Type | Method and Description |
---|---|
protected void |
configure(Configuration config)
Method called before window creation.
|
static void |
launch(Application app)
Entry point of any ImGui application.
|
protected void |
postRun()
Method called once, after application run loop.
|
protected void |
preRun()
Method called once, before application run loop.
|
dispose, disposeImGui, disposeWindow, endFrame, getColorBg, getHandle, init, initImGui, initWindow, postProcess, preProcess, process, run, runFrame, startFrame
protected void configure(Configuration config)
config
- configuration object with basic window informationprotected void preRun()
protected void postRun()
public static void launch(Application app)
app
- application instance to run