summaryrefslogtreecommitdiff
path: root/src/rendering.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/rendering.c')
-rw-r--r--src/rendering.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/rendering.c b/src/rendering.c
index 0643c70..8c3846d 100644
--- a/src/rendering.c
+++ b/src/rendering.c
@@ -4,6 +4,7 @@
#include <GLFW/glfw3.h>
#include <cglm/cam.h>
#include <cglm/vec2.h>
+#include <cglm/ivec3.h>
#include <cglm/mat4.h>
@@ -707,6 +708,24 @@ void r_init_renderstack(
window_init_renderstack(GLOBAL_PLATFORM->window, num_fbuf, num_buf, fb_params, buffer_params);
}
+void r_setup_framebuffer(void *restrict ctx, u32 framebuffer_id, FramebufferParameters param, u32 *restrict buffer_array, u32 *restrict buffer_parameters) {
+ r_create_textures(ctx, buffer_array,
+ buffer_parameters,
+ &param.dimensions,
+ param.num_textures);
+
+ r_create_renderbuffers(ctx, &buffer_array[param.num_textures],
+ &buffer_parameters[param.num_textures],
+ &param.dimensions,
+ param.num_renderbuffers);
+
+ r_attach_buffers(ctx,
+ framebuffer_id,
+ buffer_array,
+ buffer_parameters,
+ param.num_textures + param.num_renderbuffers);
+}
+
void r_create_framebuffers(void* restrict ctx, u32* restrict framebuffer_array,
usize num_targets) {
const GladGLContext* gl = (GladGLContext*)ctx;
@@ -764,7 +783,7 @@ void r_create_textures(void* restrict ctx, u32* restrict texture_array,
gl->CreateTextures(GL_TEXTURE_1D, num_targets, texture_array);
ASSERT(!gl->GetError());
for (usize i = 0; i < num_targets; i++) {
- gl->TextureStorage1D(texture_array[i], 1, gl_texture_format(BUFFERPARAMETER_FMT_GET(texture_parameters[i])), texture_sz[0]);
+ gl->TextureStorage1D(texture_array[i], 1, gl_texture_format(BUFFERPARAMETER_GET_PARAMETER(texture_parameters[i])), texture_sz[0]);
}
break;
@@ -772,7 +791,7 @@ void r_create_textures(void* restrict ctx, u32* restrict texture_array,
gl->CreateTextures(GL_TEXTURE_2D, num_targets, texture_array);
ASSERT(!gl->GetError());
for (usize i = 0; i < num_targets; i++) {
- gl->TextureStorage2D(texture_array[i], 1, gl_texture_format(BUFFERPARAMETER_FMT_GET(texture_parameters[i])), texture_sz[0], texture_sz[1]);
+ gl->TextureStorage2D(texture_array[i], 1, gl_texture_format(BUFFERPARAMETER_GET_PARAMETER(texture_parameters[i])), texture_sz[0], texture_sz[1]);
}
break;
@@ -780,7 +799,7 @@ void r_create_textures(void* restrict ctx, u32* restrict texture_array,
gl->CreateTextures(GL_TEXTURE_3D, num_targets, texture_array);
ASSERT(!gl->GetError());
for (usize i = 0; i < num_targets; i++) {
- gl->TextureStorage3D(texture_array[i], 1, gl_texture_format(BUFFERPARAMETER_FMT_GET(texture_parameters[i])), texture_sz[0], texture_sz[1], texture_sz[2]);
+ gl->TextureStorage3D(texture_array[i], 1, gl_texture_format(BUFFERPARAMETER_GET_PARAMETER(texture_parameters[i])), texture_sz[0], texture_sz[1], texture_sz[2]);
}
break;
@@ -834,7 +853,7 @@ void r_create_renderbuffers(void *restrict ctx, u32* restrict buffer_array, u32*
for (usize i = 0; i < num_buffers; i++) {
gl->NamedRenderbufferStorage(
buffer_array[i],
- gl_texture_format(BUFFERPARAMETER_FMT_GET(buffer_types[i])),
+ gl_texture_format(BUFFERPARAMETER_GET_PARAMETER(buffer_types[i])),
buffer_sizes[i][0],
buffer_sizes[i][1]
);