wx_BGI_Graphics
Classic BGI-compatible graphics API with modern OpenGL extension API
Loading...
Searching...
No Matches
Functions
2-D Camera Convenience API

A 2-D camera is an orthographic camera that looks straight down at the XY ground plane (Z = 0) in the Z-up world. More...

Functions

BGI_API int BGI_CALL wxbgi_cam2d_create (const char *name)
 Creates a 2-D overhead camera.
 
BGI_API void BGI_CALL wxbgi_cam2d_get_pan (const char *name, float *x, float *y)
 Retrieves the current pan position.
 
BGI_API void BGI_CALL wxbgi_cam2d_get_rotation (const char *name, float *angleDeg)
 Retrieves the current rotation in degrees.
 
BGI_API void BGI_CALL wxbgi_cam2d_get_zoom (const char *name, float *zoom)
 Retrieves the current zoom level.
 
BGI_API void BGI_CALL wxbgi_cam2d_pan_by (const char *name, float dx, float dy)
 Pans the 2-D camera by a world-space delta.
 
BGI_API void BGI_CALL wxbgi_cam2d_set_pan (const char *name, float x, float y)
 Sets the 2-D camera pan (world-space centre of the view).
 
BGI_API void BGI_CALL wxbgi_cam2d_set_rotation (const char *name, float angleDeg)
 Sets the 2-D view rotation around the Z axis.
 
BGI_API void BGI_CALL wxbgi_cam2d_set_world_height (const char *name, float worldUnitsHigh)
 Sets the number of world-units visible vertically at zoom = 1.
 
BGI_API void BGI_CALL wxbgi_cam2d_set_zoom (const char *name, float zoom)
 Sets the zoom level (1 = nominal, 2 = 2× magnification).
 
BGI_API void BGI_CALL wxbgi_cam2d_zoom_at (const char *name, float factor, float pivotX, float pivotY)
 Zooms around a pivot point in world space.
 

Detailed Description

A 2-D camera is an orthographic camera that looks straight down at the XY ground plane (Z = 0) in the Z-up world.

Pan, zoom, and rotation are managed through dedicated functions that keep the view always centred and aspect-correct.

Internally a 2-D camera is stored as a Camera3D with is2D = true; it participates in the same registry and all wxbgi_cam_* functions work on it as well.

Function Documentation

◆ wxbgi_cam2d_create()

BGI_API int BGI_CALL wxbgi_cam2d_create ( const char *  name)

Creates a 2-D overhead camera.

Returns an error if a camera with the same name already exists. The reserved name "default" is always rejected. The initial view is centred on world origin (0,0), zoom = 1, no rotation, and the window height in world-units visible vertically.

Parameters
nameCamera identifier string (must not be NULL).
Returns
1 on success, 0 on invalid input, -1 if no window is open, -2 if a camera with that name already exists (sets graphresult() to grDuplicateName).

◆ wxbgi_cam2d_get_pan()

BGI_API void BGI_CALL wxbgi_cam2d_get_pan ( const char *  name,
float *  x,
float *  y 
)

Retrieves the current pan position.

◆ wxbgi_cam2d_get_rotation()

BGI_API void BGI_CALL wxbgi_cam2d_get_rotation ( const char *  name,
float *  angleDeg 
)

Retrieves the current rotation in degrees.

◆ wxbgi_cam2d_get_zoom()

BGI_API void BGI_CALL wxbgi_cam2d_get_zoom ( const char *  name,
float *  zoom 
)

Retrieves the current zoom level.

◆ wxbgi_cam2d_pan_by()

BGI_API void BGI_CALL wxbgi_cam2d_pan_by ( const char *  name,
float  dx,
float  dy 
)

Pans the 2-D camera by a world-space delta.

Parameters
nameCamera name, or NULL for the active camera.

◆ wxbgi_cam2d_set_pan()

BGI_API void BGI_CALL wxbgi_cam2d_set_pan ( const char *  name,
float  x,
float  y 
)

Sets the 2-D camera pan (world-space centre of the view).

Parameters
nameCamera name, or NULL for the active camera.

◆ wxbgi_cam2d_set_rotation()

BGI_API void BGI_CALL wxbgi_cam2d_set_rotation ( const char *  name,
float  angleDeg 
)

Sets the 2-D view rotation around the Z axis.

Parameters
nameCamera name, or NULL for the active camera.
angleDegRotation in degrees (positive = counter-clockwise).

◆ wxbgi_cam2d_set_world_height()

BGI_API void BGI_CALL wxbgi_cam2d_set_world_height ( const char *  name,
float  worldUnitsHigh 
)

Sets the number of world-units visible vertically at zoom = 1.

Changing this value rescales the entire coordinate space without altering the zoom or pan. Default is 720 world-units (matching a 720-pixel-tall window at 1:1 scale).

Parameters
nameCamera name, or NULL for the active camera.
worldUnitsHighVisible world-unit height at zoom = 1.

◆ wxbgi_cam2d_set_zoom()

BGI_API void BGI_CALL wxbgi_cam2d_set_zoom ( const char *  name,
float  zoom 
)

Sets the zoom level (1 = nominal, 2 = 2× magnification).

The zoom is clamped to a minimum of 1e-6 to prevent division by zero.

Parameters
nameCamera name, or NULL for the active camera.

◆ wxbgi_cam2d_zoom_at()

BGI_API void BGI_CALL wxbgi_cam2d_zoom_at ( const char *  name,
float  factor,
float  pivotX,
float  pivotY 
)

Zooms around a pivot point in world space.

The world point under pivotX / pivotY remains stationary on screen while the zoom level is multiplied by factor.

Parameters
nameCamera name, or NULL for the active camera.
factorZoom multiplier (e.g. 1.1 to zoom in 10 %).
pivotXWorld X of the zoom pivot.
pivotYWorld Y of the zoom pivot.