ExampleApp
struct · #include <rayrai/example_common.hpp>
Minimal SDL/ImGui wrapper for RayraiWindow examples.
Nested classes
structViewport — The viewer image of a frame and the pointer over it (see beginViewport()).
Public member functions
init
bool init(const char *title, int width, int height, bool visible=true)Initialize SDL, OpenGL context, and ImGui backends.
Requests a 4.3 core context and falls back to 3.3; enables vsync.
Parameters
| Parameter | Description |
|---|---|
title | Window title. |
width | Window width. |
height | Window height. |
visible | False creates a hidden window (e.g. for headless captures). |
Returns True on success.
shutdown
void shutdown()Shutdown ImGui/SDL resources.
processEvents
void processEvents()Poll SDL events and update quit flag.
beginFrame
void beginFrame()Begin a new ImGui frame.
beginViewport
Viewport beginViewport()Lay the viewer image out across the window and return the pointer over it.
An example that handles the pointer itself does so between this and endViewport().
endViewport
void endViewport(
raisin::RayraiWindow &viewer,
const Viewport &viewport,
bool pointerMovesCamera=true,
bool clickSelects=true)Render the viewer at the viewport's size and draw it.
Parameters
| Parameter | Description |
|---|---|
pointerMovesCamera | The pointer orbits, pans and zooms the camera while it is over the image. |
clickSelects | A click selects the body under the pointer. |
renderViewer
void renderViewer(raisin::RayraiWindow &viewer)Render the RayraiWindow output into an ImGui window across the whole window.
The pointer orbits the camera and a click selects a body, as in beginViewport() and endViewport() with their defaults.
Parameters
| Parameter | Description |
|---|---|
viewer | RayraiWindow instance to render. |
endFrame
void endFrame()End the ImGui frame and swap buffers.
Public attributes
window
SDL_Window *windowMain window (null before init()).
context
SDL_GLContext contextOpenGL context of window.
quit
bool quitSet by processEvents() when the window is closed.