summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authoromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-03-09 16:35:08 +1100
committeromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-03-09 16:35:08 +1100
commit428e68c9464de6c2d340d67c7fb6a3ac688bb74a (patch)
treefb552f4a8c3a6ca4089b130a1c98822867d5a02f /examples
parent437c5bead579765b37139b8c2c5e50f269eb8c8f (diff)
create basic scene and draw obj
Diffstat (limited to 'examples')
-rw-r--r--examples/obj_loading/ex_obj_loading.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/examples/obj_loading/ex_obj_loading.c b/examples/obj_loading/ex_obj_loading.c
index 87aeb2d..d250857 100644
--- a/examples/obj_loading/ex_obj_loading.c
+++ b/examples/obj_loading/ex_obj_loading.c
@@ -1,13 +1,26 @@
#include <glfw3.h>
+#include "camera.h"
#include "core.h"
+#include "maths.h"
+#include "maths_types.h"
#include "render.h"
+#include "render_types.h"
int main() {
core* core = core_bringup();
- // Set up our scene
- model_handle cube = model_load_obj(core, "assets/models/obj/cube/cube.obj", true);
+ // --- Set up our scene
+
+ // 1. load model from disk
+ model_handle cube_handle = model_load_obj(core, "assets/models/obj/cube/cube.obj", true);
+ model* cube = &core->models->data[cube_handle.raw];
+ // 2. upload vertex data to gpu
+ model_upload_meshes(&core->renderer, cube);
+ // 3. create a camera
+ vec3 camera_pos = vec3(3., 4., 10.);
+ vec3 camera_front = vec3_normalise(vec3_negate(camera_pos));
+ camera cam = camera_create(camera_pos, camera_front, VEC3_Y, deg_to_rad(45.0));
// Main loop
while (!glfwWindowShouldClose(core->renderer.window)) {
@@ -16,7 +29,10 @@ int main() {
render_frame_begin(&core->renderer);
- // insert work here
+ // Draw the cube
+ transform cube_tf =
+ transform_create(VEC3_ZERO, quat_ident(), 2.5); // make the cube a bit bigger
+ draw_model(&core->renderer, &cam, cube, cube_tf);
render_frame_end(&core->renderer);
}