summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-08-10 02:59:59 +1000
committeromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-08-10 02:59:59 +1000
commitdcb9f65b25e59edb21c9c3cac7b32d70ca19eb72 (patch)
treece99b01a070c57ecc6f3f4073b8298608706f9a0 /src
parenta0592bdb9966b204373bc4a258da47a603c70969 (diff)
wip
Diffstat (limited to 'src')
-rw-r--r--src/core/core.c6
-rw-r--r--src/core/core.h2
-rw-r--r--src/maths/primitives.c2
-rw-r--r--src/new_render/render.c8
-rw-r--r--src/new_render/render.h6
-rw-r--r--src/ral/backends/opengl/backend_opengl.c4
-rw-r--r--src/resources/gltf.c5
7 files changed, 23 insertions, 10 deletions
diff --git a/src/core/core.c b/src/core/core.c
index bb30ced..12aa33f 100644
--- a/src/core/core.c
+++ b/src/core/core.c
@@ -20,11 +20,11 @@ Core g_core; /** @brief global `Core` that other files can use */
/** @brief Gets the global `Core` singleton */
inline Core* GetCore() { return &g_core; }
-void Core_Bringup(struct GLFWwindow* optional_window) {
+void Core_Bringup(const char* window_name, struct GLFWwindow* optional_window) {
INFO("Initiate Core bringup");
memset(&g_core, 0, sizeof(Core));
- RendererConfig conf = { .window_name = { "Celeritas Engine Core" },
+ RendererConfig conf = { .window_name = window_name,
.scr_width = SCR_WIDTH,
.scr_height = SCR_HEIGHT,
.clear_colour = (Vec3){ .08, .08, .1 } };
@@ -80,4 +80,4 @@ GLFWwindow* Core_GetGlfwWindowPtr(Core* core) { return g_core.window; }
struct Renderer* Core_GetRenderer(Core* core) { return core->renderer; }
-Model* Model_Get(ModelHandle h) { return Model_pool_get(&g_core.models, h); } \ No newline at end of file
+Model* Model_Get(ModelHandle h) { return Model_pool_get(&g_core.models, h); }
diff --git a/src/core/core.h b/src/core/core.h
index 86f5b01..4e7ff03 100644
--- a/src/core/core.h
+++ b/src/core/core.h
@@ -32,7 +32,7 @@ Core* get_global_core();
@param [in] optional_window - Leave NULL if you want Celeritas to instantiate its own window with
GLFW, if you want to provide the glfw window then pass it in here.
*/
-void Core_Bringup(GLFWwindow* optional_window);
+void Core_Bringup(const char* window_name, GLFWwindow* optional_window);
void Core_Shutdown();
bool ShouldExit();
diff --git a/src/maths/primitives.c b/src/maths/primitives.c
index ceae260..4a4d55f 100644
--- a/src/maths/primitives.c
+++ b/src/maths/primitives.c
@@ -144,7 +144,7 @@ Vec3 spherical_to_cartesian_coords(f32 rho, f32 theta, f32 phi) {
return vec3(x, y, z);
}
-Geometry geo_create_uvsphere(f32 radius, u32 north_south_lines, u32 east_west_lines) {
+Geometry Geo_CreateUVsphere(f32 radius, u32 north_south_lines, u32 east_west_lines) {
assert(east_west_lines >= 3); // sphere will be degenerate and look gacked without at least 3
assert(north_south_lines >= 3);
diff --git a/src/new_render/render.c b/src/new_render/render.c
index fd5e1c2..c180597 100644
--- a/src/new_render/render.c
+++ b/src/new_render/render.c
@@ -284,6 +284,12 @@ void Geometry_Destroy(Geometry* geometry) {
Vertex_darray_free(geometry->vertices);
}
}
+PUB MeshHandle Mesh_Insert(Mesh* mesh) {
+ return Mesh_pool_insert(Render_GetMeshPool(), mesh);
+}
+PUB MaterialHandle Material_Insert(Material* material) {
+ return Material_pool_insert(Render_GetMaterialPool(), material);
+}
size_t ModelExtractRenderEnts(RenderEnt_darray* entities, ModelHandle model_handle, Mat4 affine,
RenderEntityFlags flags) {
@@ -348,4 +354,4 @@ Material_pool* Render_GetMaterialPool() {
void Render_SetRenderMode(RenderMode mode) {
Renderer* ren = Core_GetRenderer(&g_core);
ren->render_mode = mode;
-} \ No newline at end of file
+}
diff --git a/src/new_render/render.h b/src/new_render/render.h
index 8f3ac2a..7fbc0a7 100644
--- a/src/new_render/render.h
+++ b/src/new_render/render.h
@@ -13,7 +13,7 @@
typedef struct Renderer Renderer;
typedef struct GLFWwindow GLFWwindow;
typedef struct RendererConfig {
- char window_name[256];
+ const char* window_name;
u32 scr_width, scr_height;
Vec3 clear_colour;
} RendererConfig;
@@ -62,6 +62,8 @@ PUB ModelHandle ModelLoad(const char* debug_name, const char* filepath);
PUB Mesh Mesh_Create(Geometry* geometry, bool free_on_upload);
PUB void Mesh_Delete(Mesh* mesh);
void Geometry_Destroy(Geometry* geometry);
+MeshHandle Mesh_Insert(Mesh* mesh);
+MaterialHandle Material_Insert(Material* material);
/** @brief gets render entities from a model and pushes them into a dynamic array for rendering */
size_t ModelExtractRenderEnts(RenderEnt_darray* entities, ModelHandle model_handle, Mat4 affine, RenderEntityFlags flags);
@@ -92,4 +94,4 @@ Mesh_pool* Render_GetMeshPool();
Material_pool* Render_GetMaterialPool();
// --- Setters
-void Render_SetRenderMode(RenderMode mode); \ No newline at end of file
+void Render_SetRenderMode(RenderMode mode);
diff --git a/src/ral/backends/opengl/backend_opengl.c b/src/ral/backends/opengl/backend_opengl.c
index 6ebe4e6..5e08cf3 100644
--- a/src/ral/backends/opengl/backend_opengl.c
+++ b/src/ral/backends/opengl/backend_opengl.c
@@ -419,11 +419,11 @@ void GPU_EncodeDrawIndexed(GPU_CmdEncoder* encoder, u64 index_count) {
bool GPU_Backend_BeginFrame() {
glViewport(0, 0, context.swapchain.dimensions.x * 2, context.swapchain.dimensions.y * 2);
- glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
+ glClearColor(0.8f, 0.8f, 0.8f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
return true;
}
void GPU_Backend_EndFrame() { glfwSwapBuffers(context.window); }
-#endif \ No newline at end of file
+#endif
diff --git a/src/resources/gltf.c b/src/resources/gltf.c
index 91816d8..ce6a83b 100644
--- a/src/resources/gltf.c
+++ b/src/resources/gltf.c
@@ -554,11 +554,14 @@ size_t GLTF_LoadMaterials(cgltf_data *data, Str8 relative_path, Material_darray
} else {
our_material.albedo_map = Render_GetWhiteTexture();
WARN("GLTF model has no albedo map");
+ our_material.base_colour = vec3_create(pbr.base_color_factor[0],pbr.base_color_factor[1], pbr.base_color_factor[2]);
}
// -- metallic
cgltf_texture_view metal_rough_tex_view = pbr.metallic_roughness_texture;
// bool has_metal_
+ printf("Metal factor: %f\n", pbr.metallic_factor);
+ printf("Roughness factor: %f\n", pbr.roughness_factor);
if (metal_rough_tex_view.texture != NULL) {
char metal_rough_map_path[1024];
snprintf(metal_rough_map_path, sizeof(metal_rough_map_path), "%s/%s", relative_path.buf,
@@ -566,6 +569,8 @@ size_t GLTF_LoadMaterials(cgltf_data *data, Str8 relative_path, Material_darray
our_material.metallic_roughness_map = TextureLoadFromFile(metal_rough_map_path);
} else {
WARN("GLTF model has no metal/roughness map");
+ our_material.metallic = pbr.metallic_factor;
+ our_material.roughness = pbr.roughness_factor;
}
cgltf_texture_view normal_tex_view = gltf_material.normal_texture;