KROYSDOCS
HomeWhat's newv0.1.0
C/C++ SDK / C ABI · Viewport (editor, 2.1; capability viewport-tools) / KroysViewportApi

KroysViewportApi

Viewport tools, the viewport camera and 3D drawing (capability viewport-tools). Editor target only.

Kindstruct
Headerkroys/kroys_plugin.h
Members11
Functions9
DECLARATION

Declaration

Declared in kroys/kroys_plugin.h.

kroys_plugin.h
typedef struct KroysViewportApi { ... } KroysViewportApi;
REFERENCE

Members

Fields
#uint32_t structSize;

Size of this struct as the writer compiled it (sizeof); the reader uses it to detect members appended by later minor versions.

field
#uint32_t reserved;

Padding reserved for later use; leave it 0.

field
Functions
#KroysResult (KROYS_CALL* RegisterTool)(KroysContext context, const KroysViewportToolDesc* desc, const KroysViewportToolCallbacks* callbacks, KroysHandle* outHandle);

Capability viewport-tools: a tool on the viewport's plugin toolbar.

function pointer
#KroysResult (KROYS_CALL* ActivateTool)(KroysContext context, const char* toolId);

Activates a tool by local id (null: none).

function pointer
#KroysResult (KROYS_CALL* GetCamera)(KroysContext context, KroysCameraInfo* outCamera);

The viewport camera.

function pointer
#int32_t (KROYS_CALL* WorldToScreen)(KroysContext context, const float* world, float* outScreen);

Projects world[3] to outScreen[2] (pixels from the viewport's top-left); 0 when the point is behind the camera.

function pointer
#void (KROYS_CALL* DrawLine)(KroysContext context, const float* from, const float* to, uint32_t color, float thickness);

Draw primitives: inside a tool's Draw only. Colors are packed RGBA8.

function pointer
#void (KROYS_CALL* DrawCircle)(KroysContext context, const float* center, const float* normal, float radius, uint32_t color, float thickness);

A circle around normal.

function pointer
#void (KROYS_CALL* DrawBox)(KroysContext context, const float* minimum, const float* maximum, uint32_t color, float thickness);

An axis-aligned box from minimum[3] to maximum[3].

function pointer
#void (KROYS_CALL* DrawPoint)(KroysContext context, const float* position, float size, uint32_t color);

A point of size pixels.

function pointer
#void (KROYS_CALL* DrawLabel)(KroysContext context, const float* position, const char* text, uint32_t color);

Text at a world position.

function pointer
Members
uint32_t structSize;
uint32_t reserved;
KroysResult (KROYS_CALL* RegisterTool)(KroysContext context, const KroysViewportToolDesc* desc, const KroysViewportToolCallbacks* callbacks, KroysHandle* outHandle);
KroysResult (KROYS_CALL* ActivateTool)(KroysContext context, const char* toolId);
KroysResult (KROYS_CALL* GetCamera)(KroysContext context, KroysCameraInfo* outCamera);
int32_t (KROYS_CALL* WorldToScreen)(KroysContext context, const float* world, float* outScreen);
void (KROYS_CALL* DrawLine)(KroysContext context, const float* from, const float* to, uint32_t color, float thickness);
void (KROYS_CALL* DrawCircle)(KroysContext context, const float* center, const float* normal, float radius, uint32_t color, float thickness);
void (KROYS_CALL* DrawBox)(KroysContext context, const float* minimum, const float* maximum, uint32_t color, float thickness);
void (KROYS_CALL* DrawPoint)(KroysContext context, const float* position, float size, uint32_t color);
void (KROYS_CALL* DrawLabel)(KroysContext context, const float* position, const char* text, uint32_t color);

KroysEngine 0.1.0 documentation, built from the engine repository by Tools/BuildDocsSite.py.