/** * Copyright (c) 2025 Dominic Masters * * This software is released under the MIT License. * https://opensource.org/licenses/MIT */ #pragma once #include "display/texture/texture.h" #define FRAMEBUFFER_CLEAR_COLOR (1 << 0) #define FRAMEBUFFER_CLEAR_DEPTH (1 << 1) typedef struct { #if DISPLAY_SDL2 == 1 // OpenGL Framebuffer Object ID GLuint id; texture_t texture; #else #error "Framebuffers not implemented on this platform." #endif } framebuffer_t; extern framebuffer_t FRAMEBUFFER_BACKBUFFER; extern const framebuffer_t *FRAMEBUFFER_BOUND; /** * Initializes the backbuffer framebuffer. */ void frameBufferInitBackbuffer(void); /** * Initializes a framebuffer. * * @param framebuffer The framebuffer to initialize. * @param width The width of the framebuffer. * @param height The height of the framebuffer. */ #if DISPLAY_SIZE_DYNAMIC == 1 void frameBufferInit( framebuffer_t *framebuffer, const uint32_t width, const uint32_t height ); #endif /** * 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); /** * Clears the currently bound framebuffer. * * @param flags The clear flags. * @param color The color to clear the color buffer to (if clearing color). */ void frameBufferClear(uint8_t flags, color_t color); /** * 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