summaryrefslogtreecommitdiff
path: root/src/renderer/render.h
diff options
context:
space:
mode:
authorJoshua Rowe <17525998+omnisci3nce@users.noreply.github.com>2024-05-20 10:50:11 +1000
committerGitHub <noreply@github.com>2024-05-20 10:50:11 +1000
commite904c22003c3a134201b222e6619e782fbe63947 (patch)
tree5295c8ce5f855ca4a0f1bebe50beee80bae66682 /src/renderer/render.h
parent02e84ee4d18e705e3362be1e327fdb6f1397a032 (diff)
parent73d4145f46d2305f45761b8e456df692d1962dfb (diff)
Merge pull request #14 from omnisci3nce/realign
Realign
Diffstat (limited to 'src/renderer/render.h')
-rw-r--r--src/renderer/render.h92
1 files changed, 63 insertions, 29 deletions
diff --git a/src/renderer/render.h b/src/renderer/render.h
index 1a35488..c193ff9 100644
--- a/src/renderer/render.h
+++ b/src/renderer/render.h
@@ -1,39 +1,73 @@
+/**
+ * @file render.h
+ * @author your name (you@domain.com)
+ * @brief Renderer frontend
+ * @version 0.1
+ * @date 2024-03-21
+ *
+ * @copyright Copyright (c) 2024
+ *
+ */
#pragma once
-#include "camera.h"
-#include "loaders.h"
+#include "ral_types.h"
#include "render_types.h"
-#include "transform_hierarchy.h"
-// --- Lifecycle
-/** @brief initialise the render system frontend */
bool renderer_init(renderer* ren);
-/** @brief shutdown the render system frontend */
void renderer_shutdown(renderer* ren);
-// --- Frame
-
void render_frame_begin(renderer* ren);
+void render_frame_update_globals(renderer* ren);
void render_frame_end(renderer* ren);
+void render_frame_draw(renderer* ren);
+
+// ! TEMP
+typedef struct camera camera;
+void gfx_backend_draw_frame(renderer* ren, camera* camera, mat4 model, texture* tex);
+
+typedef struct render_ctx {
+ mat4 view;
+ mat4 projection;
+} render_ctx;
+
+// frontend -- these can be called from say a loop in an example, or via FFI
+texture_handle texture_create(const char* debug_name, texture_desc description, const u8* data);
+
+// Frontend Resources
+texture_data texture_data_load(const char* path, bool invert_y);
+
+/**
+ * @brief
+ *
+ * @param data
+ * @param free_on_upload frees the CPU-side pixel data stored in `data`
+ * @return texture_handle
+ */
+texture_handle texture_data_upload(texture_data data, bool free_on_upload);
+
+buffer_handle buffer_create(const char* debug_name, u64 size);
+bool buffer_destroy(buffer_handle buffer);
+sampler_handle sampler_create();
+
+void shader_hot_reload(const char* filepath);
+
+// models and meshes are implemented **in terms of the above**
+
+/**
+ * @brief Creates buffers and returns a struct that holds handles to our resources
+ *
+ * @param geometry
+ * @param free_on_upload frees the CPU-side vertex/index data stored in `geometry` when we
+ successfully upload that data to the GPU-side buffer
+ * @return mesh
+ */
+mesh mesh_create(geometry_data* geometry, bool free_on_upload);
+
+void draw_mesh(mesh* mesh, mat4* model); //, mat4* view, mat4* proj); // TODO: material
+
+model_handle model_load(const char* debug_name, const char* filepath);
+
+void geo_free_data(geometry_data* geo);
+void geo_set_vertex_colours(geometry_data* geo, vec4 colour);
-// --- models meshes
-void model_upload_meshes(renderer* ren, model* model);
-void draw_model(renderer* ren, camera* camera, model* model, mat4* tf, scene* scene);
-void draw_mesh(renderer* ren, mesh* mesh, mat4* tf, material* mat, mat4* view, mat4* proj);
-void draw_scene(arena* frame, model_darray* models, renderer* ren, camera* camera,
- transform_hierarchy* tfh, scene* scene);
-
-// ---
-texture texture_data_load(const char* path, bool invert_y); // #frontend
-void texture_data_upload(texture* tex); // #backend
-
-// --- Uniforms
-
-/** @brief upload a vec3 of f32 to a uniform */
-void uniform_vec3f(u32 program_id, const char* uniform_name, vec3* value);
-/** @brief upload a single f32 to a uniform */
-void uniform_f32(u32 program_id, const char* uniform_name, f32 value);
-/** @brief upload a integer to a uniform */
-void uniform_i32(u32 program_id, const char* uniform_name, i32 value);
-/** @brief upload a mat4 of f32 to a uniform */
-void uniform_mat4f(u32 program_id, const char* uniform_name, mat4* value); \ No newline at end of file
+vertex_description static_3d_vertex_description();