naev 0.12.5
nlua_shader.h
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
4#pragma once
5
6#include "nlua.h"
7#include "opengl.h"
8
9#define SHADER_METATABLE "shader"
10
11#define SHADER_NAME_MAXLEN \
12 32
13
14/* Helper. */
15#define luaL_optshader( L, ind, def ) \
16 nluaL_optarg( L, ind, def, luaL_checkshader )
17
18typedef struct LuaUniform_s {
19 GLuint id;
20 GLint size;
21 GLenum type;
22 char name[SHADER_NAME_MAXLEN];
23 GLint tex;
25
26typedef struct LuaTexture_s {
27 GLenum active;
28 GLuint texid;
29 GLint uniform;
30 GLint value;
32
33typedef struct LuaShader_s {
34 GLuint program;
35 /* Shared Uniforms. */
36 GLint ViewSpaceFromLocal;
37 GLint ClipSpaceFromView;
38 GLint ClipSpaceFromLocal;
39 GLint ViewNormalFromLocal;
40 GLint love_ScreenSize;
41 /* Fragment Shader. */
42 GLint MainTex;
43 /* Vertex Shader. */
44 GLint VertexPosition;
45 GLint VertexTexCoord;
46 GLint VertexColour;
47 GLint ConstantColour;
48 /* Other uniforms. */
49 LuaUniform_t *uniforms;
50 GLint nuniforms;
51 /* Other stuff. */
52 LuaTexture_t *tex;
53 unsigned int pp_id;
55
56/*
57 * Library loading
58 */
59int nlua_loadShader( nlua_env env );
60
61/*
62 * Shader operations
63 */
64LuaShader_t *lua_toshader( lua_State *L, int ind );
65LuaShader_t *luaL_checkshader( lua_State *L, int ind );
66LuaShader_t *lua_pushshader( lua_State *L, LuaShader_t shader );
67int lua_isshader( lua_State *L, int ind );
LuaShader_t * lua_pushshader(lua_State *L, LuaShader_t shader)
Pushes a shader on the stack.
Definition nlua_shader.c:97
LuaShader_t * lua_toshader(lua_State *L, int ind)
Lua bindings to interact with shaders.
Definition nlua_shader.c:72
int nlua_loadShader(nlua_env env)
Loads the shader library.
Definition nlua_shader.c:54
LuaShader_t * luaL_checkshader(lua_State *L, int ind)
Gets shader at index or raises error if there is no shader at index.
Definition nlua_shader.c:83
int lua_isshader(lua_State *L, int ind)
Checks to see if ind is a shader.
unsigned int pp_id
Definition nlua_shader.h:53