diff options
author | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-08-11 23:40:13 +1000 |
---|---|---|
committer | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-08-11 23:40:13 +1000 |
commit | 272cc9563315566061bbbd7078f76c76a3484e4b (patch) | |
tree | 3264c6acef2e3d3a7dab1c806233062395a5b5f3 /examples | |
parent | 3a151b1d1f99b59dfd6d98c1e7520b48b57d6f5e (diff) |
removing example targets from xmake.lua and fix identation
Diffstat (limited to 'examples')
-rw-r--r-- | examples/game_demo/game_demo.c | 24 | ||||
-rw-r--r-- | examples/input/ex_input.c | 120 | ||||
-rw-r--r-- | examples/skinned_animation/ex_skinned_animation.c | 2 |
3 files changed, 14 insertions, 132 deletions
diff --git a/examples/game_demo/game_demo.c b/examples/game_demo/game_demo.c index 1b86028..b3fa70d 100644 --- a/examples/game_demo/game_demo.c +++ b/examples/game_demo/game_demo.c @@ -107,18 +107,18 @@ int main() { // Shadow_Run(entities, entity_count); // Quat rot = quat_from_axis_angle(VEC3_X, HALF_PI, true); - Immdraw_Sphere(transform_create(VEC3_ZERO, quat_ident(), 0.5), vec4(1.0, 0.0, 0.0, 1.0), false); - Immdraw_Cuboid(transform_create(vec3(2.0, 0.0, 0.0), quat_ident(), 1.0), - vec4(1.0, 0.0, 0.0, 1.0), false); - - // if (draw_debug) { - // // draw the player model with shadows - // Render_RenderEntities(render_entities->data, render_entities->len); - // // Render_DrawTerrain(); - // Skybox_Draw(&skybox, cam); - // } else { - // Shadow_DrawDebugQuad(); - // } + // Immdraw_Sphere(transform_create(VEC3_ZERO, quat_ident(), 0.5), vec4(1.0, 0.0, 0.0, 1.0), + // false); Immdraw_Cuboid(transform_create(vec3(2.0, 0.0, 0.0), quat_ident(), 1.0), + // vec4(1.0, 0.0, 0.0, 1.0), false); + + if (draw_debug) { + // draw the player model with shadows + Render_RenderEntities(render_entities->data, render_entities->len); + // Render_DrawTerrain(); + Skybox_Draw(&skybox, cam); + } else { + Shadow_DrawDebugQuad(); + } // Terrain_Draw(terrain); // Grid_Draw(); diff --git a/examples/input/ex_input.c b/examples/input/ex_input.c deleted file mode 100644 index 576b364..0000000 --- a/examples/input/ex_input.c +++ /dev/null @@ -1,120 +0,0 @@ -#include <glfw3.h> - -#include "camera.h" -#include "core.h" -#include "input.h" -#include "keys.h" -#include "maths.h" -#include "maths_types.h" -#include "primitives.h" -#include "render.h" -#include "render_backend.h" -#include "render_types.h" - -typedef struct game_state { - camera camera; - vec3 camera_euler; - bool first_mouse_update; // so the camera doesnt lurch when you run the first - // process_camera_rotation -} game_state; - -void update_camera_rotation(input_state* input, game_state* game, camera* cam); - -int main() { - core* core = core_bringup(); - - vec3 cam_pos = vec3_create(5, 5, 5); - game_state game = { - .camera = camera_create(cam_pos, vec3_negate(cam_pos), VEC3_Y, deg_to_rad(45.0)), - .camera_euler = vec3_create(90, 0, 0), - .first_mouse_update = true, - }; - - // load a texture - texture tex = texture_data_load("assets/models/obj/cube/container.jpg", false); - texture_data_upload(&tex); - - printf("Starting look direction: "); - print_vec3(game.camera.front); - - // Main loop - const f32 camera_lateral_speed = 0.2; - const f32 camera_zoom_speed = 0.15; - - while (!should_exit(core)) { - input_update(&core->input); - - vec3 translation = VEC3_ZERO; - if (key_is_pressed(KEYCODE_W) || key_is_pressed(KEYCODE_KEY_UP)) { - printf("Move Forwards\n"); - translation = vec3_mult(game.camera.front, camera_zoom_speed); - } else if (key_is_pressed(KEYCODE_S) || key_is_pressed(KEYCODE_KEY_DOWN)) { - printf("Move Backwards\n"); - translation = vec3_mult(game.camera.front, -camera_zoom_speed); - } else if (key_is_pressed(KEYCODE_A) || key_is_pressed(KEYCODE_KEY_LEFT)) { - printf("Move Left\n"); - vec3 lateral = vec3_normalise(vec3_cross(game.camera.front, game.camera.up)); - translation = vec3_mult(lateral, -camera_lateral_speed); - } else if (key_is_pressed(KEYCODE_D) || key_is_pressed(KEYCODE_KEY_RIGHT)) { - printf("Move Right\n"); - vec3 lateral = vec3_normalise(vec3_cross(game.camera.front, game.camera.up)); - translation = vec3_mult(lateral, camera_lateral_speed); - } - game.camera.position = vec3_add(game.camera.position, translation); - // update_camera_rotation(&core->input, &game, &game.camera); - - // UNUSED: threadpool_process_results(&core->threadpool, 1); - - render_frame_begin(&core->renderer); - - mat4 model = mat4_translation(VEC3_ZERO); - - gfx_backend_draw_frame(&core->renderer, &game.camera, model, &tex); - - render_frame_end(&core->renderer); - } - - core_shutdown(core); - - return 0; -} - -void update_camera_rotation(input_state* input, game_state* game, camera* cam) { - float xoffset = -input->mouse.x_delta; // xpos - lastX; - float yoffset = -input->mouse.y_delta; // reversed since y-coordinates go from bottom to top - if (game->first_mouse_update) { - xoffset = 0.0; - yoffset = 0.0; - game->first_mouse_update = false; - } - - float sensitivity = 0.2f; // change this value to your liking - xoffset *= sensitivity; - yoffset *= sensitivity; - - // x = yaw - game->camera_euler.x += xoffset; - // y = pitch - game->camera_euler.y += yoffset; - // we dont update roll - - f32 yaw = game->camera_euler.x; - f32 pitch = game->camera_euler.y; - - // make sure that when pitch is out of bounds, screen doesn't get flipped - if (game->camera_euler.y > 89.0f) game->camera_euler.y = 89.0f; - if (game->camera_euler.y < -89.0f) game->camera_euler.y = -89.0f; - - vec3 front = cam->front; - front.x = cos(deg_to_rad(yaw) * cos(deg_to_rad(pitch))); - front.y = sin(deg_to_rad(pitch)); - front.z = sin(deg_to_rad(yaw)) * cos(deg_to_rad(pitch)); - - front = vec3_normalise(front); - // save it back - cam->front.x = front.x; - cam->front.y = front.y; - // roll is static - - print_vec3(cam->front); -} diff --git a/examples/skinned_animation/ex_skinned_animation.c b/examples/skinned_animation/ex_skinned_animation.c index 7704b99..25fc097 100644 --- a/examples/skinned_animation/ex_skinned_animation.c +++ b/examples/skinned_animation/ex_skinned_animation.c @@ -66,6 +66,8 @@ int main() { // quat rot = quat_ident(); Transform tf = transform_create(VEC3_ZERO, quat_ident(), 1.0); + // TODO: Drawing should still just use the PBR pipeline + // draw_skinned_model(&core->renderer, &game.camera, simple_skin, tf, &our_scene); Frame_End(); |