naev 0.11.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"
11#define SHADER_NAME_MAXLEN 32
13/* Helper. */
14#define luaL_optshader(L,ind,def) nluaL_optarg(L,ind,def,luaL_checkshader)
15
16typedef struct LuaUniform_s {
17 GLuint id;
18 GLint size;
19 GLenum type;
20 char name[SHADER_NAME_MAXLEN];
21 GLint tex;
23
24typedef struct LuaTexture_s {
25 GLenum active;
26 GLuint texid;
27 GLint uniform;
28 GLint value;
30
31typedef struct LuaShader_s {
32 GLuint program;
33 /* Shared Uniforms. */
34 GLint ViewSpaceFromLocal;
35 GLint ClipSpaceFromView;
36 GLint ClipSpaceFromLocal;
37 GLint ViewNormalFromLocal;
38 GLint love_ScreenSize;
39 /* Fragment Shader. */
40 GLint MainTex;
41 /* Vertex Shader. */
42 GLint VertexPosition;
43 GLint VertexTexCoord;
44 GLint VertexColour;
45 GLint ConstantColour;
46 /* Other uniforms. */
47 LuaUniform_t *uniforms;
48 GLint nuniforms;
49 /* Other stuff. */
50 LuaTexture_t *tex;
51 unsigned int pp_id;
53
54/*
55 * Library loading
56 */
57int nlua_loadShader( nlua_env env );
58
59/*
60 * Shader operations
61 */
62LuaShader_t* lua_toshader( lua_State *L, int ind );
63LuaShader_t* luaL_checkshader( lua_State *L, int ind );
64LuaShader_t* lua_pushshader( lua_State *L, LuaShader_t shader );
65int lua_isshader( lua_State *L, int ind );
LuaShader_t * lua_pushshader(lua_State *L, LuaShader_t shader)
Pushes a shader on the stack.
LuaShader_t * lua_toshader(lua_State *L, int ind)
Lua bindings to interact with shaders.
Definition nlua_shader.c:75
int nlua_loadShader(nlua_env env)
Loads the shader library.
Definition nlua_shader.c:57
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:86
int lua_isshader(lua_State *L, int ind)
Checks to see if ind is a shader.
unsigned int pp_id
Definition nlua_shader.h:51