summaryrefslogtreecommitdiff
path: root/src/shader.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/shader.c')
-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;
}
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */