summaryrefslogtreecommitdiff
path: root/src/new_render
diff options
context:
space:
mode:
authoromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-07-20 19:47:25 +1000
committeromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-07-20 19:47:25 +1000
commit58a748dcd77d0caacc9d6ef7a7e7e073ac849ad3 (patch)
tree054108cf40ad4e9c147db4e8723485e72d9a7b98 /src/new_render
parent0a984656f5fec68c90acc612b01f897918c0070b (diff)
resize viewport and fix skybox
Diffstat (limited to 'src/new_render')
-rw-r--r--src/new_render/pbr.c3
-rw-r--r--src/new_render/render.c10
-rw-r--r--src/new_render/render.h1
-rw-r--r--src/new_render/skybox.c3
4 files changed, 15 insertions, 2 deletions
diff --git a/src/new_render/pbr.c b/src/new_render/pbr.c
index 46c621f..0a19ee1 100644
--- a/src/new_render/pbr.c
+++ b/src/new_render/pbr.c
@@ -71,7 +71,8 @@ void PBR_Execute(PBR_Storage* storage, Camera camera, TextureHandle shadowmap_te
// Feed shader data
Mat4 view, proj;
- Camera_ViewProj(&camera, 1000, 1000, &view, &proj);
+ u32x2 dimensions = GPU_Swapchain_GetDimensions();
+ Camera_ViewProj(&camera, (f32)dimensions.x, (f32)dimensions.y, &view, &proj);
Binding_Camera camera_data = { .view = view,
.projection = proj,
.viewPos = vec4(camera.position.x, camera.position.y,
diff --git a/src/new_render/render.c b/src/new_render/render.c
index 07913f8..11f7e0a 100644
--- a/src/new_render/render.c
+++ b/src/new_render/render.c
@@ -81,6 +81,9 @@ bool Renderer_Init(RendererConfig config, Renderer* ren, GLFWwindow** out_window
glfwMakeContextCurrent(ren->window);
+ DEBUG("Set up GLFW window callbacks");
+ glfwSetWindowSizeCallback(window, Render_WindowSizeChanged);
+
// set the RAL backend up
if (!GPU_Backend_Init(config.window_name, window, ren->resource_pools)) {
return false;
@@ -116,6 +119,13 @@ void Renderer_Shutdown(Renderer* ren) {
}
size_t Renderer_GetMemReqs() { return sizeof(Renderer); }
+void Render_WindowSizeChanged(GLFWwindow* window, i32 new_width, i32 new_height) {
+ (void)window;
+ INFO("Window size changed callback");
+ // Renderer* ren = Core_GetRenderer(&g_core);
+ GPU_Swapchain_Resize(new_width, new_height);
+}
+
void Render_FrameBegin(Renderer* ren) {
arena_free_all(&ren->frame_arena);
ren->frame_aborted = false;
diff --git a/src/new_render/render.h b/src/new_render/render.h
index 13c626d..52aecfc 100644
--- a/src/new_render/render.h
+++ b/src/new_render/render.h
@@ -30,6 +30,7 @@ typedef struct RenderCtx {
PUB bool Renderer_Init(RendererConfig config, Renderer* renderer, GLFWwindow** out_window);
PUB void Renderer_Shutdown(Renderer* renderer);
PUB size_t Renderer_GetMemReqs();
+void Render_WindowSizeChanged(GLFWwindow* window, i32 new_width, i32 new_height);
// internal init functions
void DefaultPipelinesInit(Renderer* renderer);
diff --git a/src/new_render/skybox.c b/src/new_render/skybox.c
index 8ac8356..b054366 100644
--- a/src/new_render/skybox.c
+++ b/src/new_render/skybox.c
@@ -128,7 +128,8 @@ void Skybox_Draw(Skybox* skybox, Camera camera) {
// Shader data
Mat4 view, proj;
- Camera_ViewProj(&camera, 1000, 1000, &view, &proj);
+ u32x2 dimensions = GPU_Swapchain_GetDimensions();
+ Camera_ViewProj(&camera, dimensions.x, dimensions.y, &view, &proj);
Mat4 new = mat4_ident();
new.data[0] = view.data[0];
new.data[1] = view.data[1];