|
Scarab
A thin, game-agnostic 2D engine host built on the sunlight tile-map engine
|
View-addressed camera/zoom/viewport Lua primitives. More...
#include <luaviewapi.h>
Static Public Member Functions | |
| static void | Register (lua_State *pLuaState) |
| Register the view-addressed Lua-callable functions. | |
View-addressed camera/zoom/viewport Lua primitives.
A view is a camera position, a viewport rectangle, a zoom and a scroll step. The renderer owns one built-in view, the default view (id 0, from renderer_get_default_view), and it is the one the older global camera_*, zoom_* and viewport_* functions act on — those keep working unchanged. The view_* functions here take the view first, so that when more views exist (several views in one window: a minimap, picture-in-picture, split screen) the same calls address any of them. view_create adds further views over the same world (a minimap, a close-up, picture-in-picture, split screen), each with its own rectangle, camera and zoom, and each drawn every frame.
View handles are opaque integers. Every function reports failure as nil, "message" (never a Lua error) — an unknown view is nil, "unknown view N".
Zoom is always a *factor*** — a whole multiple of ZOOM_STEP (0.0625) between ZOOM_FACTOR_MIN and ZOOM_FACTOR_MAX; 3.8125 is valid, 3.8 is rejected with the nearest valid factor named. **Changing a view's zoom or viewport does not move its camera: the camera position is not re-clamped, so set it again afterwards (view_set_camera_position).
What an extra view is for, and its limits. Every view shows the same map, sprites and layers — there is one world seen through several windows. A view can hide layers (view_show_layer, view_show_only_layers), be hidden (view_set_visible), be drawn above or below another (view_set_draw_order) and have its own backdrop (view_set_clear_background, view_set_background_color). Each visible extra view costs one more full pass over the map per frame. What is not per-view: collisions and input stay in the default view's space, and an ordinary sprite's position is relative to the view it is drawn in — a sprite meant to appear at the same map position in every view needs sprite_set_world_space. Image layers are drawn only in the default view.
|
static |
Register the view-addressed Lua-callable functions.