[renderer] Add function to destroy frame buffers

Needed for window resizing for fisheye and warp buffers (main buffers
will be taken care of by the drivers).
This commit is contained in:
Bill Currie 2022-09-21 23:47:14 +09:00
parent 4578b1af0d
commit fdfdf9056a
6 changed files with 41 additions and 1 deletions

View file

@ -422,7 +422,7 @@ QFGL_WANT (void, glPNTrianglesiATI, (GLint x, GLint y))
// frame buffers
QFGL_DONT_NEED (GLboolean, glIsFramebuffer, (GLuint framebuffer))
QFGL_NEED (void, glBindFramebuffer, (GLenum target, GLuint framebuffer))
QFGL_DONT_NEED (void, glDeleteFramebuffers, (GLsizei n, const GLuint *framebuffers))
QFGL_NEED (void, glDeleteFramebuffers, (GLsizei n, const GLuint *framebuffers))
QFGL_NEED (void, glGenFramebuffers, (GLsizei n, GLuint *framebuffers))
QFGL_DONT_NEED (GLenum, glCheckFramebufferStatus, (GLenum target))
QFGL_DONT_NEED (void, glFramebufferTexture1D, (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level))

View file

@ -129,6 +129,7 @@ typedef struct vid_render_funcs_s {
struct framebuffer_s *(*create_cube_map) (int side);
struct framebuffer_s *(*create_frame_buffer) (int width, int height);
void (*destroy_frame_buffer) (struct framebuffer_s *framebuffer);
void (*bind_framebuffer) (struct framebuffer_s *framebuffer);
void (*set_viewport) (const struct vrect_s *view);
// x and y are tan(f/2) for fov_x and fov_y

View file

@ -406,6 +406,18 @@ gl_create_frame_buffer (int width, int height)
return fb;
}
static void
gl_destroy_frame_buffer (framebuffer_t *framebuffer)
{
__auto_type fb = (gl_framebuffer_t *) framebuffer->buffer;
qfglDeleteFramebuffers (1, &fb->handle);
GLuint tex[2] = { fb->color, fb->depth };
qfglDeleteTextures (2, tex);
free (framebuffer);
}
static void
gl_bind_framebuffer (framebuffer_t *framebuffer)
{
@ -528,6 +540,7 @@ vid_render_funcs_t gl_vid_render_funcs = {
gl_create_cube_map,
gl_create_frame_buffer,
gl_destroy_frame_buffer,
gl_bind_framebuffer,
gl_set_viewport,
gl_set_fov,

View file

@ -353,6 +353,18 @@ glsl_create_frame_buffer (int width, int height)
return fb;
}
static void
glsl_destroy_frame_buffer (framebuffer_t *framebuffer)
{
__auto_type fb = (gl_framebuffer_t *) framebuffer->buffer;
qfeglDeleteFramebuffers (1, &fb->handle);
GLuint tex[2] = { fb->color, fb->depth };
qfeglDeleteTextures (2, tex);
free (framebuffer);
}
static void
glsl_bind_framebuffer (framebuffer_t *framebuffer)
{
@ -472,6 +484,7 @@ vid_render_funcs_t glsl_vid_render_funcs = {
glsl_create_cube_map,
glsl_create_frame_buffer,
glsl_destroy_frame_buffer,
glsl_bind_framebuffer,
glsl_set_viewport,
glsl_set_fov,

View file

@ -262,6 +262,12 @@ sw_create_frame_buffer (int width, int height)
return fb;
}
static void
sw_destroy_frame_buffer (framebuffer_t *framebuffer)
{
free (framebuffer);
}
static void sw_set_viewport (const vrect_t *view);
static void
@ -492,6 +498,7 @@ vid_render_funcs_t sw_vid_render_funcs = {
sw_create_cube_map,
sw_create_frame_buffer,
sw_destroy_frame_buffer,
sw_bind_framebuffer,
sw_set_viewport,
sw_set_fov,

View file

@ -476,6 +476,11 @@ vulkan_create_frame_buffer (int width, int height)
return 0;
}
static void
vulkan_destroy_frame_buffer (framebuffer_t *framebuffer)
{
}
static void
vulkan_bind_framebuffer (framebuffer_t *framebuffer)
{
@ -788,6 +793,7 @@ vid_render_funcs_t vulkan_vid_render_funcs = {
vulkan_create_cube_map,
vulkan_create_frame_buffer,
vulkan_destroy_frame_buffer,
vulkan_bind_framebuffer,
vulkan_set_viewport,
vulkan_set_fov,