summaryrefslogtreecommitdiff
path: root/src/ral
diff options
context:
space:
mode:
Diffstat (limited to 'src/ral')
-rw-r--r--src/ral/backends/opengl/backend_opengl.c14
-rw-r--r--src/ral/ral_common.h4
-rw-r--r--src/ral/ral_impl.h2
3 files changed, 18 insertions, 2 deletions
diff --git a/src/ral/backends/opengl/backend_opengl.c b/src/ral/backends/opengl/backend_opengl.c
index 10a21d1..97c86dd 100644
--- a/src/ral/backends/opengl/backend_opengl.c
+++ b/src/ral/backends/opengl/backend_opengl.c
@@ -1,4 +1,5 @@
#include "backend_opengl.h"
+#include "maths_types.h"
#if defined(CEL_REND_BACKEND_OPENGL)
#include <assert.h>
#include "log.h"
@@ -14,6 +15,7 @@
typedef struct OpenglCtx {
GLFWwindow* window;
arena pool_arena;
+ GPU_Swapchain swapchain;
GPU_CmdEncoder main_encoder;
GPU_BackendPools gpu_pools;
ResourcePools* resource_pools;
@@ -48,12 +50,13 @@ bool GPU_Backend_Init(const char* window_name, struct GLFWwindow* window,
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
+ context.swapchain = (GPU_Swapchain){ .dimensions = u32x2(1000, 1000) };
+
return true;
}
// All of these are no-ops in OpenGL
-void GPU_Backend_Shutdown() { /* TODO */
-}
+void GPU_Backend_Shutdown() { /* TODO */ }
bool GPU_Device_Create(GPU_Device* out_device) { return true; }
void GPU_Device_Destroy(GPU_Device* device) {}
bool GPU_Swapchain_Create(GPU_Swapchain* out_swapchain) { return true; }
@@ -64,6 +67,12 @@ void GPU_CmdEncoder_EndRender(GPU_CmdEncoder* encoder) {}
GPU_CmdEncoder* GPU_GetDefaultEncoder() { return &context.main_encoder; }
void GPU_QueueSubmit(GPU_CmdBuffer* cmd_buffer) {}
+void GPU_Swapchain_Resize(i32 new_width, i32 new_height) {
+ context.swapchain.dimensions = u32x2(new_width, new_height);
+}
+
+u32x2 GPU_Swapchain_GetDimensions() { return context.swapchain.dimensions; }
+
GPU_Renderpass* GPU_Renderpass_Create(GPU_RenderpassDesc description) {
// allocate new pass
GPU_Renderpass* renderpass = Renderpass_pool_alloc(&context.gpu_pools.renderpasses, NULL);
@@ -382,6 +391,7 @@ 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);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
return true;
diff --git a/src/ral/ral_common.h b/src/ral/ral_common.h
index 63816b1..2bcc013 100644
--- a/src/ral/ral_common.h
+++ b/src/ral/ral_common.h
@@ -41,6 +41,10 @@ void ResourcePools_Init(arena* a, struct ResourcePools* res_pools);
PUB GPU_Renderpass* GPU_GetDefaultRenderpass(); // returns a renderpass that draws directly to
// default framebuffer with default depth
+// --
+// window resize callback
+void GPU_WindowResizedCallback(u32 x, u32 y);
+
// --- Vertex formats
VertexDescription static_3d_vertex_description();
diff --git a/src/ral/ral_impl.h b/src/ral/ral_impl.h
index 6676b6c..5376920 100644
--- a/src/ral/ral_impl.h
+++ b/src/ral/ral_impl.h
@@ -29,6 +29,8 @@ void GPU_Device_Destroy(GPU_Device* device);
bool GPU_Swapchain_Create(GPU_Swapchain* out_swapchain);
void GPU_Swapchain_Destroy(GPU_Swapchain* swapchain);
+void GPU_Swapchain_Resize(i32 new_width, i32 new_height);
+u32x2 GPU_Swapchain_GetDimensions();
PUB GPU_Renderpass* GPU_Renderpass_Create(GPU_RenderpassDesc description);
PUB void GPU_Renderpass_Destroy(GPU_Renderpass* pass);