summaryrefslogtreecommitdiff
path: root/src/shader/shader.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/shader/shader.h')
-rw-r--r--src/shader/shader.h137
1 files changed, 60 insertions, 77 deletions
diff --git a/src/shader/shader.h b/src/shader/shader.h
index 07cc22d..95956ea 100644
--- a/src/shader/shader.h
+++ b/src/shader/shader.h
@@ -7,111 +7,94 @@
#define HONEY_SHADER_H
#include "../common.h"
-#include "../light/light.h"
-typedef int honey_shader;
+/** @brief Push the shader table to the lua stack.
+ */
+void honey_setup_shader(lua_State* L);
-/** @brief Load a shader.
+/** @brief Create a new shader from source.
*
- * @param[out] shader Pointer to the shader destination
+ * @param[in] vertex_source The GLSL code for the vertex shader.
+ * @param[in] fragment_source The GLSL code for the fragment shader.
*
- * @param[in] vertex_shader_path The path to the vertex shader source code
- * @param[in] fragment_shader_path The path to the fragment shader source code
- *
- * @return The result of the shader load.
+ * @returns OpenGL handle for the compiled shader.
*/
-honey_result honey_shader_load(honey_shader* shader,
- char* vertex_shader_path,
- char* fragment_shader_path);
+int honey_shader_new(lua_State* L);
-/** @brief Create a shader from code strings.
+/** @brief Set a shader as the current OpenGL shader.
*
- * @param[out] shader Pointer to the shader destination.
- * @param[in] vertex_shader_code Zero-terminated string containing the vertex shader code to compile
- * @param[in] fragment_shader_code Zero-terminated string containing the fragment shader code to compile
+ * @param[in] shader The OpenGL handle to a shader, as generated by honey.shader.new
*
- * @return The result of the shader creation.
+ * @returns Nothing.
*/
-honey_result honey_shader_new(honey_shader* shader,
- char* vertex_shader_code,
- char* fragment_shader_code);
+int honey_shader_use(lua_State* L);
-/** @brief Set an integer uniform.
+/** @brief Set an integer uniform on a shader.
*
- * @param[in] shader The shader to which the uniform belongs
- * @param[in] int_name The name of the integer uniform
- * @param[in] value The value of the integer uniform
- */
-void honey_shader_set_int(honey_shader shader,
- char* int_name,
- int value);
-
-/** @brief Set a float uniform.
+ * @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.
*
- * @param[in] shader The shader to which the uniform belongs
- * @param[in] float_name The name of the float uniform
- * @param[in] value The value of the float uniform
+ * @returns Nothing.
*/
-void honey_shader_set_float(honey_shader shader,
- char* float_name,
- float value);
+int honey_shader_set_int(lua_State* L);
-/** @brief Set a vec3 uniform.
- * @param[in] shader The shader to which the uniform belongs
- * @param[in] vector_name The name of the vec3 uniform
- * @param[in] value The value of the vector uniform
- */
-void honey_shader_set_vec3(honey_shader shader,
- char* vector_name,
- vec3 value);
-
-
-/** @brief Set a mat3 uniform.
+/** @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.
*
- * @param[in] shader The shader to which the uniform belongs
- * @param[in] matrix_name The name of the matrix uniform
- * @param[in] value The value of the matrix uniform
+ * @returns Nothing.
*/
-void honey_shader_set_mat3(honey_shader shader,
- char* matrix_name,
- mat3 value);
+int honey_shader_set_float(lua_State* L);
-/** @brief Set a mat4 uniform.
+/** @brief Set a vec3 uniform on a shader.
*
- * @param[in] shader The shader to which the uniform belongs
- * @param[in] matrix_name The name of the matrix uniform
- * @param[in] value The value of the matrix uniform
+ * @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.
*/
-void honey_shader_set_mat4(honey_shader shader,
- char* matrix_name,
- mat4 value);
+int honey_shader_set_vec3(lua_State* L);
-/** @brief Set a point_light uniform.
+/** @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.
*
- * @param[in] shader The shader to which the uniform belongs
- * @param[in] point_light_index The index of the light to set
- * @param[in] light The honey_point_light to set
+ * @returns Nothing.
*/
-void honey_shader_set_point_light(honey_shader shader,
- int point_light_index,
- honey_point_light light);
+int honey_shader_set_vec4(lua_State* L);
-/** @brief Set a directional_light uniform.
+/** @brief Set a mat3 uniform on a shader.
*
- * @param[in] shader The shader to which the uniform belongs
- * @param[in] directional_light_index The index of the light to set
- * @param[in] light The honey_directional_light to set
+ * @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.
*/
-void honey_shader_set_directional_light(honey_shader shader,
- int directional_light_index,
- honey_directional_light light);
+int honey_shader_set_mat3(lua_State* L);
-/** @brief Use a shader.
+/** @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.
*/
-#define honey_shader_use glUseProgram
+int honey_shader_set_mat4(lua_State* L);
-/** @brief delete a shader.
+/** @brief Delete a shader.
+ *
+ * @param[in] shader An OpenGL shader handle.
+ *
+ * @returns Nothing.
*/
-#define honey_shader_delete glDeleteProgram
+int honey_shader_delete(lua_State* L);
#endif