natiny_render_viewport_begin

C
void natiny_render_viewport_begin(int x, int y, int width, int height);

Sets a rectangular viewport on the current window or surface render target. The viewport becomes the local drawing area: its top-left corner is (0, 0), and its dimensions are used by 2D drawing and cameras bound afterwards.

Parameters

Name Type Description
x int Left edge in render-target pixels
y int Top edge in render-target pixels
width int Width in pixels
height int Height in pixels

Example

C
natiny_render_viewport_begin(0, 0, 320, 180);
draw_scene();
natiny_render_viewport_end();

Notes

  • The rectangle is clamped to the render target. If the clamped width or height is not positive, no viewport is set.
  • Viewports do not nest. A call made while a viewport is active is ignored; end the active viewport first.
  • Setting a viewport clears the existing scissor stack. Scissor coordinates used afterwards are relative to the viewport and are clipped to it.
  • natiny_render_cover() covers the viewport. Bind a camera after setting the viewport to use the viewport's aspect ratio.
  • The viewport is cleared automatically when the render target changes or a window is bound for a new frame.