Kraken Logo

Kraken Engine

DocumentationGuidesShowcaseCommunity
Ctrl
K
Navigating the Docs
Building Docs
Overview
Camera
Color
Draw
Ease
Event
Fx
Gamepad
Input
Log
Math
Mixer
Mouse
Physics
Pixel Array
Renderer
Shaders
Time
Transform
Ui
Viewport
Window

Built bydurkisneer1.Kraken Engine is open source and available onGitHub.

  1. Docs
  2. Functions
  3. Renderer

Renderer

Functions for rendering graphics


Set Default Filter Mode

set_default_filter_mode(filter: FilterMode) → Noneset_default_filter_mode(filter: FilterMode) → None

Set the default FilterMode for new textures. The factory default is FilterMode::Default.

Args

  • filter : The default scaling/filtering mode to use for new textures.

Get Default Filter Mode

get_default_filter_mode() → FilterModeget_default_filter_mode() → FilterMode

Get the current default FilterMode for new textures.

Returns

FilterMode : The current default scaling/filtering mode.

Clear

clear(color: Color = ...) → Noneclear(color: Color = ...) → None

Clear the renderer with the specified color.

Args

  • color : The color to clear with. Defaults to black (0, 0, 0, 255).

Raises

  • ValueError : If color values are not between 0 and 255.

Present

present() → Nonepresent() → None

Present the rendered content to the screen. This finalizes the current frame and displays it. Should be called after all drawing operations for the frame are complete.

Set Virtual Resolution

set_virtual_resolution(width: int, height: int) → Noneset_virtual_resolution(width: int, height: int) → None

Set a virtual resolution for rendering. This creates an internal render target of the specified size, and all rendering will be done to that target, which is then scaled up to the actual screen resolution when presented.

Args

  • width : The width of the render target in pixels.
  • height : The height of the render target in pixels.

Raises

  • ValueError : If width or height are not positive integers.

Unset Virtual Resolution

unset_virtual_resolution() → Noneunset_virtual_resolution() → None

Unset any previously configured virtual resolution and restore rendering directly to the output.

Set Render Backend

set_render_backend(backend: RenderBackend) → Noneset_render_backend(backend: RenderBackend) → None

Set the renderer backend to use for future initialization. This must be called before creating the window/renderer, otherwise it will have no effect.

Args

  • backend : One of the RenderBackend enum values.

Get Virtual Resolution

get_virtual_resolution() → Vec2get_virtual_resolution() → Vec2

Get the currently configured virtual resolution (the internal render target size). If no virtual resolution is set, this returns the current output resolution.

Returns

Vec2 : The width and height of the virtual resolution in pixels.

Get Output Resolution

get_output_resolution() → Vec2get_output_resolution() → Vec2

Get the renderer's output/presenting resolution (the actual window or output size).

Returns

Vec2 : The output width and height in pixels.

Get Current Resolution

get_current_resolution() → Vec2get_current_resolution() → Vec2

Get the resolution of the current render target for rendering. If a custom render target is set, this will return the size of it. Otherwise, it returns the presenting resolution of the renderer.

Returns

Vec2 : The width and height of the current resolution.

Set Target

set_target(target: Texture | None = None) → Noneset_target(target: Texture | None = None) → None

Set the current render target to the provided Texture.

Args

  • target : A Texture created with TextureAccess.TARGET, or None to unset.

Raises

  • RuntimeError : If the texture is not a TARGET texture.

Draw 9Slice

draw_9slice(texture: Texture, dst: Rect, slice: Rect, anchor: Vec2 = ..., pivot: Vec2 = ...) → Nonedraw_9slice(texture: Texture, dst: Rect, slice: Rect, anchor: Vec2 = ..., pivot: Vec2 = ...) → None

Render a texture using 9-slice scaling (9-grid). The camera's transform is not applied to this draw.

This divides the texture into 9 regions: 4 corners (unscaled), 4 edges (scaled in one axis), and 1 center (scaled in both axes).

Args

  • texture : The source texture.
  • dst : The destination rectangle on screen.
  • slice : A rectangle defining the slice widths/heights (left_width, top_height, right_width, bottom_height).
  • anchor : The anchor point. Defaults to top left.
  • pivot : The rotation pivot. Defaults to center.

Read Pixels

read_pixels(src: Rect = ...) → PixelArrayread_pixels(src: Rect = ...) → PixelArray

Read pixel data from the renderer within the specified rectangle.

Args

  • src : The rectangle area to read pixels from. Defaults to entire renderer if None or area has no width or height.

Returns

PixelArray : An array containing the pixel data.

Raises

  • RuntimeError : If reading pixels fails.
PreviousPixel Array
NextShaders

On this page

Set Default Filter ModeGet Default Filter ModeClearPresentSet Virtual ResolutionUnset Virtual ResolutionSet Render BackendGet Virtual ResolutionGet Output ResolutionGet Current ResolutionSet TargetDraw 9SliceRead Pixels