Naev

Module tex

Lua bindings to interact with OpenGL textures.

This will allow you to load textures.

An example would be:

 t  = tex.open( GFX_PATH"foo/bar.png" ) -- Loads the texture
 w,h, sw,sh = t:dim()
 sprites, sx,sy = t:sprites()
 

Functions

__gc (t) Frees the texture.
open (path[, sx=1[, sy=1]]) Opens a texture.
dim (t) Gets the dimensions of the texture.
sprites (t) Gets the number of sprites in the texture.
spriteFromDir (t, a[, b=false]) Gets the sprite that corresponds to a direction.


Functions

__gc (t)
Frees the texture. ( t )

Parameters:

  • t Tex Texture to free.
open (path[, sx=1[, sy=1]])
Opens a texture. ( path, sx, sy )

Parameters:

  • path string Path to open.
  • sx number Optional number of x sprites. (default 1)
  • sy number Optional number of y sprites. (default 1)

Returns:

    Tex The opened texture or nil on error.

Usage:

  • t = tex.open( "no_sprites.png" )
  • t = tex.open( "spritesheet.png", 6, 6 )
dim (t)
Gets the dimensions of the texture. ( t )

Parameters:

  • t Tex Texture to get dimensions of.

Returns:

  1. number The width the total image.
  2. number The height the total image.
  3. number The width the sprites.
  4. number The height the sprites.

Usage:

    w,h, sw,sh = t:dim()
sprites (t)
Gets the number of sprites in the texture. ( t )

Parameters:

  • t Tex Texture to get sprites of.

Returns:

  1. number The total number of sprites.
  2. number The number of X sprites.
  3. number The number of Y sprites.

Usage:

    sprites, sx,sy = t:sprites()
spriteFromDir (t, a[, b=false])
Gets the sprite that corresponds to a direction. ( t, a, b )

Parameters:

  • t Tex Texture to get sprite of.
  • a number Direction to have sprite facing (in degrees).
  • b boolean Whether radians should be used instead of degrees. (default false)

Usage:

    sx, sy = t:spriteFromdir( math.pi )
generated by LDoc 1.4.6 Last updated 2020-10-01 02:30:07