Skip to content

ExampleApp ​

struct · #include <rayrai/example_common.hpp>

Minimal SDL/ImGui wrapper for RayraiWindow examples.

Nested classes ​

  • struct Viewport — The viewer image of a frame and the pointer over it (see beginViewport()).

Public member functions ​

init ​

cpp
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

ParameterDescription
titleWindow title.
widthWindow width.
heightWindow height.
visibleFalse creates a hidden window (e.g. for headless captures).

Returns True on success.

shutdown ​

cpp
void shutdown()

Shutdown ImGui/SDL resources.

processEvents ​

cpp
void processEvents()

Poll SDL events and update quit flag.

beginFrame ​

cpp
void beginFrame()

Begin a new ImGui frame.

beginViewport ​

cpp
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 ​

cpp
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

ParameterDescription
pointerMovesCameraThe pointer orbits, pans and zooms the camera while it is over the image.
clickSelectsA click selects the body under the pointer.

renderViewer ​

cpp
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

ParameterDescription
viewerRayraiWindow instance to render.

endFrame ​

cpp
void endFrame()

End the ImGui frame and swap buffers.

Public attributes ​

window ​

cpp
SDL_Window *window

Main window (null before init()).

context ​

cpp
SDL_GLContext context

OpenGL context of window.

quit ​

cpp
bool quit

Set by processEvents() when the window is closed.

RaiSim — physics for robotics and AI.