summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsanine-a <sanine.not@pm.me>2020-05-24 20:53:24 -0500
committersanine-a <sanine.not@pm.me>2020-05-24 20:53:24 -0500
commit2b6ddb0810a60b159501d60dbeaea5fd1b24daa7 (patch)
tree3b77d52f8526681ffe6c03b1b08f814aff28eaca /src
parente147d9409ce56f63c1a45199ff262c079bd557a4 (diff)
add honey_shader_new()
Diffstat (limited to 'src')
-rw-r--r--src/shader.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/shader.c b/src/shader.c
index cba83f7..b7f2916 100644
--- a/src/shader.c
+++ b/src/shader.c
@@ -37,7 +37,24 @@ enum honey_shader_result honey_shader_load(honey_shader* shader,
/* load fragment shader code */
char* fragment_shader_code = read_file(fragment_shader_path);
- /* compile shaders */
+ result = honey_shader_new(shader,
+ vertex_shader_code,
+ fragment_shader_code);
+
+ free(vertex_shader_code);
+ free(fragment_shader_code);
+
+ return result;
+}
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+
+enum honey_shader_result honey_shader_new(honey_shader* shader,
+ char* vertex_shader_code,
+ char* fragment_shader_code) {
+ enum honey_shader_result result;
+
+ /* compile shaders */
int success;
char error[512];
@@ -79,12 +96,7 @@ enum honey_shader_result honey_shader_load(honey_shader* shader,
glDeleteShader(vertex_shader);
glDeleteShader(fragment_shader);
- free(vertex_shader_code);
- free(fragment_shader_code);
-
result = SHADER_OK;
-
- return result;
}
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */