aboutsummaryrefslogtreecommitdiff
path: root/src/obj.c
diff options
context:
space:
mode:
authorjvech <jmvalenciae@unal.edu.co>2022-11-03 14:50:17 -0500
committerjvech <jmvalenciae@unal.edu.co>2022-11-03 14:50:17 -0500
commit02b8093bf0c09b838650f96d3d86be5d3231490e (patch)
treea4fd3fe3d31fc963c500a7eaf8d2146e043b7db7 /src/obj.c
parent45584a1c39c699e2bc68638fe2402e590631e3a3 (diff)
add: material and illumnation render implemented
shaders now render the models using ambient, diffuse and specular properties and react to directional light.
Diffstat (limited to 'src/obj.c')
-rw-r--r--src/obj.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/obj.c b/src/obj.c
index 5554b46..d832604 100644
--- a/src/obj.c
+++ b/src/obj.c
@@ -398,8 +398,10 @@ appendMtl(char *line, Material **mtl, int index)
if (index == 0)
*mtl = (Material *)calloc(1, sizeof(Material));
- else
+ else {
*mtl = (Material *)realloc(*mtl, (index + 1) * sizeof(Material));
+ memset(*mtl + index, 0, sizeof(Material));
+ }
sscanf(line, "%s", name);
strncpy((*mtl + index)->name, name, OBJ_LINE_MAX);
Feel free to download, copy and edit any repo