naev 0.12.5
nlua_bkg.c
Go to the documentation of this file.
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
10#include <lauxlib.h>
12
13#include "nlua_bkg.h"
14
15#include "background.h"
16#include "nlua_colour.h"
17#include "nlua_tex.h"
18
19/* Background methods. */
20static int bkgL_clear( lua_State *L );
21static int bkgL_image( lua_State *L );
22
23static const luaL_Reg bkgL_methods[] = { { "clear", bkgL_clear },
24 { "image", bkgL_image },
25 { 0, 0 } };
26
33int nlua_loadBackground( nlua_env env )
34{
35 nlua_register( env, "bkg", bkgL_methods, 0 );
36 return 0;
37}
38
53static int bkgL_clear( lua_State *L )
54{
55 (void)L;
57 return 0;
58}
59
86static int bkgL_image( lua_State *L )
87{
88 glTexture *tex;
89 double x, y, move, scale, angle;
90 const glColour *col, *radiosity;
91 unsigned int id;
92 int foreground;
93
94 /* Parse parameters. */
95 tex = luaL_checktex( L, 1 );
96 x = luaL_checknumber( L, 2 );
97 y = luaL_checknumber( L, 3 );
98 move = luaL_optnumber( L, 4, 0. );
99 scale = luaL_optnumber( L, 5, 1. );
100 angle = luaL_optnumber( L, 6, 0. );
101 col = luaL_optcolour( L, 7, &cWhite );
102 foreground = lua_toboolean( L, 8 );
103 radiosity = luaL_optcolour( L, 9, &cTransparent );
104
105 /* Create image. */
106 id = background_addImage( tex, x, y, move, scale, angle, col, foreground,
107 radiosity );
108 lua_pushnumber( L, id );
109 return 1;
110}
void background_clear(void)
Cleans up the background stuff.
Definition background.c:570
unsigned int background_addImage(const glTexture *image, double x, double y, double move, double scale, double angle, const glColour *col, int foreground, const glColour *radiosity)
Adds a new background image.
Definition background.c:328
static int bkgL_image(lua_State *L)
Adds a background image.
Definition nlua_bkg.c:86
static const luaL_Reg bkgL_methods[]
Definition nlua_bkg.c:23
static int bkgL_clear(lua_State *L)
Lua bindings to interact with the background.
Definition nlua_bkg.c:53
int nlua_loadBackground(nlua_env env)
Loads the graphics library.
Definition nlua_bkg.c:33
glTexture * luaL_checktex(lua_State *L, int ind)
Gets texture at index or raises error if there is no texture at index.
Definition nlua_tex.c:97
Abstraction for rendering sprite sheets.
Definition opengl_tex.h:43