Skip to content

Texture

Loads an image file (PNG, JPG, WebP) from the mounted project into a GPU texture. Used by Sprite. The path is resolved inside the game’s asset bundle (the same place Resource and shaders load from).

Returns: Texture — A texture handle (check valid).

Parameters:

  • path (String) — Image path within the mounted project, e.g. "textures/hero.png".
import "engine" for Texture
var tex = Texture.load("textures/hero.png")
if (!tex.valid) System.print("failed to load")
  • width — Image width in pixels (0 if the load failed).
  • height — Image height in pixels.
  • valid — true if the image loaded successfully.
System.print("%(tex.width) x %(tex.height)")

Textures are cached by the renderer; loading the same path is cheap. See Sprite for drawing a texture as a billboarded quad.

Static method.

Returns: Num — a cube handle for Graphics.setEnvironmentMap; 0 on failure (falsy — check it).

Parameters:

  • paths (List) — exactly 6 image paths, one per cube face, in order +X, -X, +Y, -Y, +Z, -Z. All faces must be the same square size; any size mismatch or read/decode failure returns 0.

Load six face images into an environment cubemap (engine PLM-241 / ADR 0076). Feed the returned handle to Graphics.setEnvironmentMap and select the cubemap sky with Graphics.setSky(name, 1, []).

import "engine" for Texture, Graphics
var cube = Texture.loadCubemap([
"textures/cube/px.png", "textures/cube/nx.png", // +X, -X
"textures/cube/py.png", "textures/cube/ny.png", // +Y, -Y
"textures/cube/pz.png", "textures/cube/nz.png"]) // +Z, -Z
if (cube == 0) System.print("cubemap failed to load")
Graphics.setEnvironmentMap(cube)

The cube currently feeds the cubemap sky; sampling it from lit shaders for reflections (IBL) is a follow-up (ADR 0076 §5). Cube handles live in their own map, separate from the 2D Texture.load path.