summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsanine-a <sanine.not@pm.me>2020-05-23 11:56:10 -0500
committersanine-a <sanine.not@pm.me>2020-05-23 11:56:10 -0500
commit018b7ce3f7d94af92fa4fab32ffdde451da7fcb9 (patch)
tree54a320cd0a18d0cabf4caee3f784c5414c11d6f4
parenta247c0adac7b3e50c72fde9b197ef6eabfd38b0b (diff)
refactor: rename number, vector, etc in honey_shader_set_* to value
-rw-r--r--demo.c2
-rw-r--r--demo.fs2
-rw-r--r--include/shader.h22
-rw-r--r--src/shader.c22
4 files changed, 33 insertions, 15 deletions
diff --git a/demo.c b/demo.c
index dd55e7f..1719914 100644
--- a/demo.c
+++ b/demo.c
@@ -153,8 +153,6 @@ int main() {
honey_shader_set_int(shader, "box_texture", 0);
honey_shader_set_int(shader, "happy_texture", 1);
- honey_shader_set_vec3(shader, "extra_color", (vec3){0, 0, 1});
-
glm_mat4_identity(model);
//glm_rotate_x(model, glm_rad(-55), model);
honey_shader_set_mat4(shader, "model", model);
diff --git a/demo.fs b/demo.fs
index af6e190..791149c 100644
--- a/demo.fs
+++ b/demo.fs
@@ -12,6 +12,6 @@ out vec4 FragColor;
void main()
{
FragColor = mix(texture(box_texture, texture_coordinate),
- vec4(extra_color.xyz, 1.0),
+ texture(happy_texture, texture_coordinate),
0.2);
}
diff --git a/include/shader.h b/include/shader.h
index 262b153..40561d4 100644
--- a/include/shader.h
+++ b/include/shader.h
@@ -38,30 +38,40 @@ enum honey_shader_result honey_shader_load(honey_shader* shader,
*
* @param[in] shader The shader to which the uniform belongs
* @param[in] int_name The name of the integer uniform
- * @param[in] number The value 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 number);
+ int value);
+
+/** @brief Set a float uniform.
+ *
+ * @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
+ */
+void honey_shader_set_float(honey_shader shader,
+ char* float_name,
+ float value);
/** @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] vector The value of the vector uniform
+ * @param[in] value The value of the vector uniform
*/
void honey_shader_set_vec3(honey_shader shader,
char* vector_name,
- vec3 vector);
+ vec3 value);
/** @brief Set a mat4 uniform.
*
* @param[in] shader The shader to which the uniform belongs
* @param[in] matrix_name The name of the matrix uniform
- * @param[in] matrix The value of the matrix uniform
+ * @param[in] value The value of the matrix uniform
*/
void honey_shader_set_mat4(honey_shader shader,
char* matrix_name,
- mat4 matrix);
+ mat4 value);
/** @brief Use a shader.
*/
diff --git a/src/shader.c b/src/shader.c
index 530cc8f..e9d79a6 100644
--- a/src/shader.c
+++ b/src/shader.c
@@ -91,30 +91,40 @@ enum honey_shader_result honey_shader_load(honey_shader* shader,
void honey_shader_set_int(honey_shader shader,
char* int_name,
- int number) {
+ int value) {
honey_shader_use(shader);
unsigned int int_location = glGetUniformLocation(shader, int_name);
- glUniform1i(int_location, number);
+ glUniform1i(int_location, value);
+}
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+
+void honey_shader_set_float(honey_shader shader,
+ char* float_name,
+ float value) {
+ honey_shader_use(shader);
+ unsigned int float_location = glGetUniformLocation(shader, float_name);
+ glUniform1f(float_location, value);
}
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
void honey_shader_set_vec3(honey_shader shader,
char* vector_name,
- vec3 vector) {
+ vec3 value) {
honey_shader_use(shader);
unsigned int vector_location = glGetUniformLocation(shader, vector_name);
- glUniform3fv(vector_location, 1, (float*) vector);
+ glUniform3fv(vector_location, 1, (float*) value);
}
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
void honey_shader_set_mat4(honey_shader shader,
char* matrix_name,
- mat4 matrix) {
+ mat4 value) {
glUseProgram(shader);
unsigned int matrix_location = glGetUniformLocation(shader, matrix_name);
- glUniformMatrix4fv(matrix_location, 1, GL_FALSE, (float*) matrix);
+ glUniformMatrix4fv(matrix_location, 1, GL_FALSE, (float*) value);
}
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */