summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-03-14 21:55:25 +1100
committeromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-03-14 21:55:25 +1100
commitb240374c23365e33727d78ca74e901bcb383e077 (patch)
tree09836fab6ddc9012a5f4437f2139ab0a704b3a78
parent6c581ff56dfcc22c25538e305e58efd967dd640a (diff)
chore: format
-rw-r--r--examples/obj_loading/ex_obj_loading.c28
-rw-r--r--src/renderer/render.c6
-rw-r--r--src/resources/obj.c8
3 files changed, 20 insertions, 22 deletions
diff --git a/examples/obj_loading/ex_obj_loading.c b/examples/obj_loading/ex_obj_loading.c
index 02ed606..6f1f12a 100644
--- a/examples/obj_loading/ex_obj_loading.c
+++ b/examples/obj_loading/ex_obj_loading.c
@@ -9,10 +9,10 @@
#include "render_types.h"
const vec3 pointlight_positions[4] = {
- {0.7, 0.2, 2.0},
- {2.3, -3.3, -4.0},
- {-4.0, 2.0, -12.0},
- {0.0, 0.0, -3.0},
+ { 0.7, 0.2, 2.0 },
+ { 2.3, -3.3, -4.0 },
+ { -4.0, 2.0, -12.0 },
+ { 0.0, 0.0, -3.0 },
};
point_light point_lights[4];
@@ -34,28 +34,24 @@ int main() {
// 4. create lights
// directional (sun) light setup
- directional_light dir_light = {.direction = (vec3){-0.2, -1.0, -0.3},
- .ambient = (vec3){0.2, 0.2, 0.2},
- .diffuse = (vec3){0.5, 0.5, 0.5},
- .specular = (vec3){1.0, 1.0, 1.0}};
+ directional_light dir_light = { .direction = (vec3){ -0.2, -1.0, -0.3 },
+ .ambient = (vec3){ 0.2, 0.2, 0.2 },
+ .diffuse = (vec3){ 0.5, 0.5, 0.5 },
+ .specular = (vec3){ 1.0, 1.0, 1.0 } };
// point lights setup
for (int i = 0; i < 4; i++) {
point_lights[i].position = pointlight_positions[i];
- point_lights[i].ambient = (vec3){0.05, 0.05, 0.05};
- point_lights[i].diffuse = (vec3){0.8, 0.8, 0.8};
- point_lights[i].specular = (vec3){1.0, 1.0, 1.0};
+ point_lights[i].ambient = (vec3){ 0.05, 0.05, 0.05 };
+ point_lights[i].diffuse = (vec3){ 0.8, 0.8, 0.8 };
+ point_lights[i].specular = (vec3){ 1.0, 1.0, 1.0 };
point_lights[i].constant = 1.0;
point_lights[i].linear = 0.09;
point_lights[i].quadratic = 0.032;
}
- scene our_scene = {
- .dir_light = dir_light,
- .n_point_lights = 4
- };
+ scene our_scene = { .dir_light = dir_light, .n_point_lights = 4 };
memcpy(&our_scene.point_lights, &point_lights, sizeof(point_light[4]));
-
// --- Enter Main loop
while (!glfwWindowShouldClose(core->renderer.window)) {
input_update(&core->input);
diff --git a/src/renderer/render.c b/src/renderer/render.c
index 1c979e5..7884db6 100644
--- a/src/renderer/render.c
+++ b/src/renderer/render.c
@@ -92,7 +92,7 @@ void draw_model(renderer* ren, camera* camera, model* model, transform tf, scene
uniform_vec3f(ren->blinn_phong.program_id, "viewPos", &camera->position);
// set light uniforms
dir_light_upload_uniforms(ren->blinn_phong, &scene->dir_light);
- for (int i = 0; i < scene->n_point_lights; i ++) {
+ for (int i = 0; i < scene->n_point_lights; i++) {
point_light_upload_uniforms(ren->blinn_phong, &scene->point_lights[i], '0' + i);
}
@@ -264,14 +264,14 @@ void texture_data_upload(texture* tex) {
// stbi_image_free(tex->image_data); // data is on gpu now so we dont need it around
}
-void dir_light_upload_uniforms(shader shader, directional_light *light) {
+void dir_light_upload_uniforms(shader shader, directional_light* light) {
uniform_vec3f(shader.program_id, "dirLight.direction", &light->direction);
uniform_vec3f(shader.program_id, "dirLight.ambient", &light->ambient);
uniform_vec3f(shader.program_id, "dirLight.diffuse", &light->diffuse);
uniform_vec3f(shader.program_id, "dirLight.specular", &light->specular);
}
-void point_light_upload_uniforms(shader shader, point_light *light, char index) {
+void point_light_upload_uniforms(shader shader, point_light* light, char index) {
char position_str[] = "pointLights[x].position";
position_str[12] = (char)index;
char ambient_str[] = "pointLights[x].ambient";
diff --git a/src/resources/obj.c b/src/resources/obj.c
index 221e3aa..710d5f0 100644
--- a/src/resources/obj.c
+++ b/src/resources/obj.c
@@ -279,7 +279,7 @@ void create_submesh(mesh_darray *meshes, vec3_darray *tmp_positions, vec3_darray
mesh_darray_push(meshes, m);
}
-bool load_material_lib(const char *path,str8 relative_path, material_darray *materials) {
+bool load_material_lib(const char *path, str8 relative_path, material_darray *materials) {
TRACE("BEGIN load material lib at %s", path);
const char *file_string = string_from_file(path);
@@ -340,7 +340,8 @@ bool load_material_lib(const char *path,str8 relative_path, material_darray *mat
char diffuse_map_filename[1024];
sscanf(pch + offset, "%s", diffuse_map_filename);
char diffuse_map_path[1024];
- snprintf(diffuse_map_path, sizeof(diffuse_map_path), "%s/%s", relative_path.buf, diffuse_map_filename);
+ snprintf(diffuse_map_path, sizeof(diffuse_map_path), "%s/%s", relative_path.buf,
+ diffuse_map_filename);
printf("load from %s\n", diffuse_map_path);
// --------------
@@ -355,7 +356,8 @@ bool load_material_lib(const char *path,str8 relative_path, material_darray *mat
char specular_map_filename[1024];
sscanf(pch + offset, "%s", specular_map_filename);
char specular_map_path[1024];
- snprintf(specular_map_path, sizeof(specular_map_path), "%s/%s", relative_path.buf, specular_map_filename);
+ snprintf(specular_map_path, sizeof(specular_map_path), "%s/%s", relative_path.buf,
+ specular_map_filename);
printf("load from %s\n", specular_map_path);
// --------------
texture specular_texture = texture_data_load(specular_map_path, true);