summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/camera.h9
-rw-r--r--src/renderer/cleanroom/immediate.c18
-rw-r--r--src/renderer/cleanroom/immediate.h (renamed from src/renderer/cleanroom/simda.h)12
-rw-r--r--src/renderer/cleanroom/types.h3
-rw-r--r--src/scene.h30
-rw-r--r--src/systems/physics.h8
-rw-r--r--src/systems/terrain.h18
7 files changed, 87 insertions, 11 deletions
diff --git a/src/camera.h b/src/camera.h
index f7bc6eb..ec867c5 100644
--- a/src/camera.h
+++ b/src/camera.h
@@ -24,4 +24,11 @@ camera camera_create(vec3 pos, vec3 front, vec3 up, f32 fov);
/** @brief get a 4x4 transform matrix for the view and perspective projection */
void camera_view_projection(camera *c, f32 screen_height, f32 screen_width, mat4 *out_view,
- mat4 *out_proj); \ No newline at end of file
+ mat4 *out_proj);
+
+// TODO: Basic reusable camera controls
+/*
+Right click + move = pan
+Left click = orbit camera
+WASD = forward/backward/left/right
+*/ \ No newline at end of file
diff --git a/src/renderer/cleanroom/immediate.c b/src/renderer/cleanroom/immediate.c
new file mode 100644
index 0000000..8e4bf7e
--- /dev/null
+++ b/src/renderer/cleanroom/immediate.c
@@ -0,0 +1,18 @@
+#include "immediate.h"
+#include "maths.h"
+#include "primitives.h"
+#include "render.h"
+#include "types.h"
+
+void imm_draw_sphere(vec3 pos, f32 radius, vec4 colour) {
+ // Create the vertices
+ geometry_data geometry = geo_create_uvsphere(radius, 16, 16);
+ geo_set_vertex_colours(&geometry, colour);
+
+ // Upload to GPU
+ mat4 model = mat4_translation(pos);
+
+ // Set pipeline
+
+ // Draw
+} \ No newline at end of file
diff --git a/src/renderer/cleanroom/simda.h b/src/renderer/cleanroom/immediate.h
index d0b4794..6d93c53 100644
--- a/src/renderer/cleanroom/simda.h
+++ b/src/renderer/cleanroom/immediate.h
@@ -1,18 +1,20 @@
#pragma once
+#include "geometry.h"
#include "maths_types.h"
// 3. SIMA (simplified immediate mode api) / render.h
// - dont need to worry about uploading mesh data
// - very useful for debugging
-void imm_draw_cuboid();
+void imm_draw_cuboid(vec3 pos, quat rotation, f32x3 extents, vec4 colour);
void imm_draw_sphere(vec3 pos, f32 radius, vec4 colour);
void imm_draw_camera_frustum();
-static void imm_draw_model(
- const char* model_filepath); // tracks internally whether the model is loaded
-static void imm_draw_model(const char* model_filepath) {
+// static void imm_draw_model(
+// const char* model_filepath); // tracks internally whether the model is loaded
+
+// static void imm_draw_model(const char* model_filepath) {
// check that model is loaded
// if not loaded, load model and upload to gpu - LRU cache for models
// else submit draw call
-} \ No newline at end of file
+// } \ No newline at end of file
diff --git a/src/renderer/cleanroom/types.h b/src/renderer/cleanroom/types.h
index b18b5b8..7a6cfbd 100644
--- a/src/renderer/cleanroom/types.h
+++ b/src/renderer/cleanroom/types.h
@@ -96,8 +96,11 @@ typedef struct geometry_data {
vertex_darray vertices;
bool has_indices;
u32_darray indices;
+ vec3 colour; /** Optional: set vertex colours */
} geometry_data;
+void geo_set_vertex_colours(geometry_data* geo, vec4 colour);
+
typedef struct mesh {
buffer_handle vertex_buffer;
buffer_handle index_buffer;
diff --git a/src/scene.h b/src/scene.h
new file mode 100644
index 0000000..2cc4d8a
--- /dev/null
+++ b/src/scene.h
@@ -0,0 +1,30 @@
+/**
+ * @file scene.h
+ * @author your name (you@domain.com)
+ * @brief
+ * @version 0.1
+ * @date 2024-04-27
+ *
+ * @copyright Copyright (c) 2024
+ *
+ */
+#include "defines.h"
+#include "types.h"
+
+typedef struct scene {
+ // directional_light dir_light;
+ // point_light point_lights[4];
+ // size_t n_point_lights;
+} scene;
+
+bool scene_add_directional_light(scene* s /* TODO */);
+bool scene_add_point_light(scene* s /* TODO */);
+
+// There can only be one heightmap terrain at a time right now.
+bool scene_add_heightmap(scene* s /* TODO */);
+bool scene_delete_heightmap(scene* s);
+
+bool scene_add_model(scene *s, model_handle model);
+void scene_remove_model(scene *s, model_handle model);
+
+// TODO: functions to load and save scenes from disk \ No newline at end of file
diff --git a/src/systems/physics.h b/src/systems/physics.h
index 61d2008..7239ab5 100644
--- a/src/systems/physics.h
+++ b/src/systems/physics.h
@@ -1,5 +1,6 @@
#pragma once
+#include "geometry.h"
#include "maths_types.h"
// 'system' means that it gets called per frame
@@ -17,11 +18,18 @@ enum collider_type {
typedef struct physics_collider {
u64 id; // ? Replace with handle?
enum collider_type shape;
+ union collider_data {
+ cuboid cuboid;
+ sphere sphere;
+ } geometry;
transform transform;
u8 layer;
bool on_ground;
} physics_collider;
+// What else do I need?
+// intersection methods
+
typedef struct physics_world {
physics_settings settings;
} physics_world;
diff --git a/src/systems/terrain.h b/src/systems/terrain.h
index 6558202..3d6f1c1 100644
--- a/src/systems/terrain.h
+++ b/src/systems/terrain.h
@@ -20,19 +20,23 @@ Future:
#include "maths_types.h"
#include "mem.h"
-typedef struct terrain_state {
-} terrain_state;
-
typedef struct heightmap {
+ str8 filepath;
u32x2 size;
void* image_data;
+ bool is_uploaded;
} heightmap;
+typedef struct terrain_state {
+ arena terrain_allocator;
+ heightmap* heightmap; // NULL = no heightmap
+} terrain_state;
+
bool terrain_system_init(terrain_state* state);
void terrain_system_shutdown(terrain_state* state);
void terrain_system_render_hmap(renderer* rend, terrain_state* state);
-heightmap heightmap_from_image(const char* filepath);
+heightmap heightmap_from_image(str8 filepath);
heightmap heightmap_from_perlin(/* TODO: perlin noise generation parameters */);
/** @brief Get the height (the Y component) for a vertex at a particular coordinate in the heightmap
@@ -43,4 +47,8 @@ f32 heightmap_height_at_xz(heightmap* hmap, f32 x, f32 z);
vec3 heightmap_normal_at_xz(heightmap* hmap, f32 x, f32 z);
/** @brief Generate the `geometry_data` for a heightmap ready to be uploaded to the GPU */
-geometry_data geo_heightmap(arena* a, heightmap heightmap); \ No newline at end of file
+geometry_data geo_heightmap(arena* a, heightmap heightmap);
+
+// somewhere there will be an easy way to add a heightmap
+
+// scene_add_heightmap \ No newline at end of file