naev 0.11.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>
11
12#include "naev.h"
15#include "nlua_bkg.h"
16
17#include "background.h"
18#include "log.h"
19#include "nlua_colour.h"
20#include "nlua_tex.h"
21#include "nluadef.h"
22
23/* Background methods. */
24static int bkgL_clear( lua_State *L );
25static int bkgL_image( lua_State *L );
26static const luaL_Reg bkgL_methods[] = {
27 { "clear", bkgL_clear },
28 { "image", bkgL_image },
29 {0,0}
30};
38int nlua_loadBackground( nlua_env env )
39{
40 nlua_register(env, "bkg", bkgL_methods, 0);
41 return 0;
42}
43
58static int bkgL_clear( lua_State *L )
59{
60 (void) L;
62 return 0;
63}
64
86static int bkgL_image( lua_State *L )
87{
88 glTexture *tex;
89 double x,y, move, scale, angle;
90 const glColour *col;
91 unsigned int id;
92 int foreground;
93
94
95 /* Parse parameters. */
96 tex = luaL_checktex(L,1);
97 x = luaL_checknumber(L,2);
98 y = luaL_checknumber(L,3);
99 move = luaL_optnumber(L,4,0.);
100 scale = luaL_optnumber(L,5,1.);
101 angle = luaL_optnumber(L,6,0.);
102 col = luaL_optcolour(L,7,&cWhite);
103 foreground = lua_toboolean(L,8);
104
105 /* Create image. */
106 id = background_addImage( tex, x, y, move, scale, angle, col, foreground );
107 lua_pushnumber(L,id);
108 return 1;
109}
void background_clear(void)
Cleans up the background stuff.
Definition background.c:489
unsigned int background_addImage(const glTexture *image, double x, double y, double move, double scale, double angle, const glColour *col, int foreground)
Adds a new background image.
Definition background.c:307
Header file with generic functions and naev-specifics.
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:26
static int bkgL_clear(lua_State *L)
Lua bindings to interact with the background.
Definition nlua_bkg.c:58
int nlua_loadBackground(nlua_env env)
Loads the graphics library.
Definition nlua_bkg.c:38
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:100
Abstraction for rendering sprite sheets.
Definition opengl_tex.h:36