/**
 * Copyright (c) 2021 Dominic Masters
 * 
 * This software is released under the MIT License.
 * https://opensource.org/licenses/MIT
 */

#pragma once
#include <dawn/dawn.h>
#include "texture.h"

/**
 * Initializes frame buffer that can be rendered to.
 * @param frameBuffer Frame buffer to initialize.
 * @param width Width of the frame buffer (in pixels).
 * @param height Height of the frame buffer (in pixels).
 * @return A renderable frame buffer.
 */
void frameBufferInit(framebuffer_t *buffer, int32_t width, int32_t height);

/**
 * Use a given frame buffer as the current rendering context.
 * 
 * @param frameBuffer Frame buffer to use.
 * @param clear Whether or not to clear the frame buffer prior to rendering.
 */
void frameBufferUse(framebuffer_t *frameBuffer, bool clear);

/**
 * Resize an existing frame buffer. This will do the check if resizing is even
 * necessary for you.
 * 
 * @param frameBuffer Frame buffer to resize.
 * @param width New width of the frame buffer.
 * @param height New height of the frame buffer.
 */
void frameBufferResize(framebuffer_t *frameBuffer,int32_t width,int32_t height);

/**
 * Unbind the currently bound frame buffer.
 * 
 * @param render Render manager
 * @param clear Whether or not to clear the back buffer.
 */
void frameBufferUnbind(render_t *render, bool clear);

/**
 * Dispose/cleanup a previously created frame buffer.
 * 
 * @param frameBuffer Frame Buffer to clean.
 */
void frameBufferDispose(framebuffer_t *frameBuffer);