summaryrefslogtreecommitdiff
path: root/src/shader.h
blob: e1c97b76b4d417b05034d9058900aaeaac33bb7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/** @file shader.h
 * 
 * @brief Functions to create, manipulate, and destroy GLSL shaders. 
 */

#ifndef HONEY_SHADER_H
#define HONEY_SHADER_H

#include "common.h"

extern int honey_shader_mt_ref;

/** @brief Push the shader table to the lua stack.
 */
void honey_setup_shader(lua_State* L);

/** @brief Create a new shader from source.
 *
 * @param[in] vertex_source The GLSL code for the vertex shader.
 * @param[in] fragment_source The GLSL code for the fragment shader.
 *
 * @returns OpenGL handle for the compiled shader.
 */
int honey_shader_new(lua_State* L);

/** @brief Set a shader as the current OpenGL shader.
 *
 * @param[in] shader The OpenGL handle to a shader, as generated by honey.shader.new
 *
 * @returns Nothing.
 */
int honey_shader_use(lua_State* L);

/** @brief Set an integer uniform on a shader.
 *
 * @param[in] shader The OpenGL shader handle.
 * @param[in] name The name of the shader uniform as a string.
 * @param[in] value The value to set the uniform to.
 *
 * @returns Nothing.
 */
int honey_shader_set_int(lua_State* L);

/** @brief Set a float uniform on a shader.
 *
 * @param[in] shader The OpenGL shader handle.
 * @param[in] name The name of the shader uniform as a string.
 * @param[in] value The value to set the uniform to.
 *
 * @returns Nothing.
 */
int honey_shader_set_float(lua_State* L);

/** @brief Set a vec3 uniform on a shader.
 *
 * @param[in] shader The OpenGL shader handle.
 * @param[in] name The name of the shader uniform as a string.
 * @param[in] value The value to set the uniform to.
 *
 * @returns Nothing.
 */
int honey_shader_set_vec3(lua_State* L);

/** @brief Set a vec4 uniform on a shader.
 *
 * @param[in] shader The OpenGL shader handle.
 * @param[in] name The name of the shader uniform as a string.
 * @param[in] value The value to set the uniform to.
 *
 * @returns Nothing.
 */
int honey_shader_set_vec4(lua_State* L);

/** @brief Set a mat3 uniform on a shader.
 *
 * @param[in] shader The OpenGL shader handle.
 * @param[in] name The name of the shader uniform as a string.
 * @param[in] value The value to set the uniform to.
 *
 * @returns Nothing.
 */
int honey_shader_set_mat3(lua_State* L);

/** @brief Set a mat4 uniform on a shader.
 *
 * @param[in] shader The OpenGL shader handle.
 * @param[in] name The name of the shader uniform as a string.
 * @param[in] value The value to set the uniform to.
 *
 * @returns Nothing.
 */
int honey_shader_set_mat4(lua_State* L);

/** @brief Delete a shader.
 *
 * @param[in] shader An OpenGL shader handle.
 *
 * @returns Nothing.
 */
int honey_shader_delete(lua_State* L);

#endif