Add backbuffer

This commit is contained in:
2025-08-22 23:30:23 -05:00
parent 995bbe1acd
commit 1bf6fe6eaf
13 changed files with 413 additions and 2 deletions

View File

@@ -0,0 +1,75 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "display/display.h"
#include "display/texture/texture.h"
typedef struct {
#if DUSK_DISPLAY_SDL2
// OpenGL Framebuffer Object ID
GLuint id;
#endif
} framebuffer_t;
extern framebuffer_t FRAMEBUFFER_BACKBUFFER;
extern const framebuffer_t *FRAMEBUFFER_BOUND;
void frameBufferInitBackbuffer();
/**
* Gets the width of the framebuffer.
*
* @param framebuffer The framebuffer to get the width of.
* @return The width of the framebuffer, or 0 if the framebuffer is NULL.
*/
int32_t frameBufferGetWidth(const framebuffer_t *framebuffer);
/**
* Gets the height of the framebuffer.
*
* @param framebuffer The framebuffer to get the height of.
* @return The height of the framebuffer, or 0 if the framebuffer is NULL.
*/
int32_t frameBufferGetHeight(const framebuffer_t *framebuffer);
/**
* Binds the framebuffer for rendering, or the backbuffer if the framebuffer
* provided is NULL.
*
* @param framebuffer The framebuffer to bind, or NULL to bind the backbuffer.
*/
void frameBufferBind(const framebuffer_t *framebuffer);
/**
* Disposes of the framebuffer using EXT methods.
*
* @param framebuffer The framebuffer to dispose of.
*/
void frameBufferDispose(framebuffer_t *framebuffer);
// #if RENDER_USE_FRAMEBUFFER
// typedef struct {
// GLuint id;
// texture_t texture;
// } framebuffer_t;
// /**
// * Initializes a framebuffer using EXT methods.
// *
// * @param framebuffer The framebuffer to initialize.
// * @param width The width of the framebuffer.
// * @param height The height of the framebuffer.
// * @return An error code indicating success or failure.
// */
// void frameBufferInit(
// framebuffer_t *framebuffer,
// const uint32_t width,
// const uint32_t height
// );
// #endif