![]() |
naev 0.12.5
|
Handles the Lua texture bindings. More...
#include "physfsrwops.h"#include "nlua_tex.h"#include "ndata.h"#include "nlua_data.h"#include "nlua_file.h"#include "nluadef.h"#include "physics.h"
Go to the source code of this file.
Functions | |
| static uint32_t | get_pixel (SDL_Surface *surface, int x, int y) |
| static int | texL_close (lua_State *L) |
| Frees the texture. | |
| static int | texL_new (lua_State *L) |
| Opens a texture. | |
| static int | texL_readData (lua_State *L) |
| Reads image data from a file. | |
| static int | texL_writeData (lua_State *L) |
| Saves texture data as a png. | |
| static int | texL_dim (lua_State *L) |
| Gets the dimensions of the texture. | |
| static int | texL_sprites (lua_State *L) |
| Gets the number of sprites in the texture. | |
| static int | texL_spriteFromDir (lua_State *L) |
| Gets the sprite that corresponds to a direction. | |
| static int | texL_setFilter (lua_State *L) |
| Sets the texture minification and magnification filters. | |
| static int | texL_setWrap (lua_State *L) |
| Sets the texture wrapping. | |
| int | nlua_loadTex (nlua_env env) |
| Loads the texture library. | |
| glTexture * | lua_totex (lua_State *L, int ind) |
| Lua bindings to interact with OpenGL textures. | |
| glTexture * | luaL_checktex (lua_State *L, int ind) |
| Gets texture at index or raises error if there is no texture at index. | |
| glTexture * | luaL_validtex (lua_State *L, int ind, const char *searchpath) |
| Gets texture directly or from a filename (string) at index or raises error if there is no texture at index. | |
| glTexture ** | lua_pushtex (lua_State *L, glTexture *texture) |
| Pushes a texture on the stack. | |
| int | lua_istex (lua_State *L, int ind) |
| Checks to see if ind is a texture. | |
Variables | |
| static int | nlua_tex_counter = 0 |
| static const luaL_Reg | texL_methods [] |
Handles the Lua texture bindings.
Definition in file nlua_tex.c.
|
inlinestatic |
Definition at line 266 of file nlua_tex.c.
| int lua_istex | ( | lua_State * | L, |
| int | ind ) |
Checks to see if ind is a texture.
| L | Lua state to check. |
| ind | Index position to check. |
Definition at line 144 of file nlua_tex.c.
Pushes a texture on the stack.
| L | Lua state to push texture into. |
| texture | Texture to push. |
Definition at line 129 of file nlua_tex.c.
| glTexture * lua_totex | ( | lua_State * | L, |
| int | ind ) |
Lua bindings to interact with OpenGL textures.
This will allow you to load textures.
An example would be:
Lua module: tex
Gets texture at index.
| L | Lua state to get texture from. |
| ind | Index position to find the texture. |
Definition at line 86 of file nlua_tex.c.
| glTexture * luaL_checktex | ( | lua_State * | L, |
| int | ind ) |
Gets texture at index or raises error if there is no texture at index.
| L | Lua state to get texture from. |
| ind | Index position to find texture. |
Definition at line 97 of file nlua_tex.c.
| glTexture * luaL_validtex | ( | lua_State * | L, |
| int | ind, | ||
| const char * | searchpath ) |
Gets texture directly or from a filename (string) at index or raises error if there is no texture at index.
| L | Lua state to get texture from. |
| ind | Index position to find texture. |
| searchpath | Path to search for files. |
Definition at line 113 of file nlua_tex.c.
| int nlua_loadTex | ( | nlua_env | env | ) |
Loads the texture library.
| env | Environment to load texture library into. |
Definition at line 59 of file nlua_tex.c.
|
static |
Frees the texture.
Lua function parameter: Tex t Texture to free.
| L | Lua State |
Lua function: __gc
Definition at line 166 of file nlua_tex.c.
|
static |
Gets the dimensions of the texture.
Lua usage parameter: w,h, sw,sh = t:dim()
Lua function parameter: Tex t Texture to get dimensions of. Lua return parameter: number The width the total image. Lua return parameter: number The height the total image. Lua return parameter: number The width the sprites. Lua return parameter: number The height the sprites.
| L | Lua State |
Lua function: dim
Definition at line 427 of file nlua_tex.c.
|
static |
Opens a texture.
Lua usage parameter: t = tex.open( "no_sprites.png" ) Lua usage parameter: t = tex.open( "spritesheet.png", 6, 6 )
Lua function parameter: string|File|Data path Path, File, or Data to open. Lua function parameter:[opt=1] number w Width when Data or optional number of x sprites otherwise. Lua function parameter:[opt=1] number h Height when Data or optional number of y sprites otherwise. Lua function parameter:[opt=1] number sx Optional number of x sprites when path is Data. Lua function parameter:[opt=1] number sy Optional number of y sprites when path is Data. Lua return parameter: Tex The opened texture or nil on error.
| L | Lua State |
Lua function: open
Definition at line 196 of file nlua_tex.c.
|
static |
Reads image data from a file.
Lua function parameter: file File|string File or filename of the file to read the data from. Lua return parameter: Data Data containing the image data. Lua return parameter: number Width of the loaded data. Lua return parameter: number Height of the loaded data.
| L | Lua State |
Lua function: readData
Definition at line 307 of file nlua_tex.c.
|
static |
Sets the texture minification and magnification filters.
Lua function parameter: Tex tex Texture to set filter. Lua function parameter: string min Minification filter ("nearest" or "linear") Lua function parameter:[opt] string mag Magnification filter ("nearest" or "linear"). Defaults to min.
| L | Lua State |
Lua function: setFilter
Definition at line 495 of file nlua_tex.c.
|
static |
Sets the texture wrapping.
Lua function parameter: Tex tex Texture to set filter. Lua function parameter: string horiz Horizontal wrapping ("clamp", "repeat", or "mirroredrepeat" ) Lua function parameter:[opt] string vert Vertical wrapping ("clamp", "repeat", or "mirroredrepeat" ) Lua function parameter:[opt] string depth Depth wrapping ("clamp", "repeat", or "mirroredrepeat" )
| L | Lua State |
Lua function: setWrap
Definition at line 529 of file nlua_tex.c.
|
static |
Gets the sprite that corresponds to a direction.
Lua usage parameter: sx, sy = t:spriteFromDir( math.pi )
Lua function parameter: Tex t Texture to get sprite of. Lua function parameter: number a Direction to have sprite facing (in radians). Lua return parameter: number The x position of the sprite. Lua return parameter: number The y position of the sprite.
| L | Lua State |
Lua function: spriteFromDir
Definition at line 470 of file nlua_tex.c.
|
static |
Gets the number of sprites in the texture.
Lua usage parameter: sprites, sx,sy = t:sprites()
Lua function parameter: Tex t Texture to get sprites of. Lua return parameter: number The total number of sprites. Lua return parameter: number The number of X sprites. Lua return parameter: number The number of Y sprites.
| L | Lua State |
Lua function: sprites
Definition at line 449 of file nlua_tex.c.
|
static |
Saves texture data as a png.
Lua function parameter: Tex t Texture to convert to string. Lua return parameter: string Texture as a string.
| L | Lua State |
Lua function: toData
Definition at line 373 of file nlua_tex.c.
|
static |
Definition at line 24 of file nlua_tex.c.
|
static |
Texture metatable methods.
Definition at line 40 of file nlua_tex.c.