#pragma once #include #include #include "textureunit.h" #include /*! \file rendertarget.h \brief Provides functions for handling render-targets. */ #ifdef __cplusplus extern "C" { #endif typedef enum kinc_g4_render_target_format { KINC_G4_RENDER_TARGET_FORMAT_32BIT, KINC_G4_RENDER_TARGET_FORMAT_64BIT_FLOAT, KINC_G4_RENDER_TARGET_FORMAT_32BIT_RED_FLOAT, KINC_G4_RENDER_TARGET_FORMAT_128BIT_FLOAT, KINC_G4_RENDER_TARGET_FORMAT_16BIT_DEPTH, KINC_G4_RENDER_TARGET_FORMAT_8BIT_RED, KINC_G4_RENDER_TARGET_FORMAT_16BIT_RED_FLOAT } kinc_g4_render_target_format_t; typedef struct kinc_g4_render_target { int width; int height; int texWidth; int texHeight; bool isCubeMap; bool isDepthAttachment; kinc_g4_render_target_impl_t impl; } kinc_g4_render_target_t; /// /// Allocates and initializes a regular render-target. The contents of the render-target are undefined. /// /// /// /// /// /// /// KINC_FUNC void kinc_g4_render_target_init(kinc_g4_render_target_t *renderTarget, int width, int height, kinc_g4_render_target_format_t format, int depthBufferBits, int stencilBufferBits); /// /// Allocates and initializes a multi-sampled render-target if possible - otherwise it falls back to a regular render-target. The contents of the render-target /// are undefined. /// /// /// /// /// /// /// /// KINC_FUNC void kinc_g4_render_target_init_with_multisampling(kinc_g4_render_target_t *renderTarget, int width, int height, kinc_g4_render_target_format_t format, int depthBufferBits, int stencilBufferBits, int samples_per_pixel); /// /// Allocates and initializes a render-target-cube-map. The contents of the render-target are undefined. /// /// /// /// /// /// KINC_FUNC void kinc_g4_render_target_init_cube(kinc_g4_render_target_t *renderTarget, int cubeMapSize, kinc_g4_render_target_format_t format, int depthBufferBits, int stencilBufferBits); /// /// Allocates and initializes a multi-sampled render-target-cube-map. Can fall back to a non-multi-sampled cube-map. The contents of the render-target are /// undefined. /// /// /// /// /// /// /// KINC_FUNC void kinc_g4_render_target_init_cube_with_multisampling(kinc_g4_render_target_t *renderTarget, int cubeMapSize, kinc_g4_render_target_format_t format, int depthBufferBits, int stencilBufferBits, int samples_per_pixel); /// /// Deallocates and destroys a render-target. /// /// The render-target to destroy KINC_FUNC void kinc_g4_render_target_destroy(kinc_g4_render_target_t *renderTarget); #ifdef KINC_KONG /// /// Uses the color-component of a render-target as a texture. /// /// The render-target to use /// The texture-unit to assign the render-target to KINC_FUNC void kinc_g4_render_target_use_color_as_texture(kinc_g4_render_target_t *renderTarget, uint32_t unit); #else /// /// Uses the color-component of a render-target as a texture. /// /// The render-target to use /// The texture-unit to assign the render-target to KINC_FUNC void kinc_g4_render_target_use_color_as_texture(kinc_g4_render_target_t *renderTarget, kinc_g4_texture_unit_t unit); #endif /// /// Uses the depth-component of a render-target as a texture. /// /// The render-target to use /// The texture-unit to assign the render-target to KINC_FUNC void kinc_g4_render_target_use_depth_as_texture(kinc_g4_render_target_t *renderTarget, kinc_g4_texture_unit_t unit); /// /// Copies the depth and stencil-components of one render-target into another one. /// /// The render-target to copy the data into /// The render-target from which to copy the data /// KINC_FUNC void kinc_g4_render_target_set_depth_stencil_from(kinc_g4_render_target_t *renderTarget, kinc_g4_render_target_t *source); /// /// Copies out the color-data from a render-target. Beware, this is very slow. /// /// The render-target to copy the color-data from /// A pointer to where the data will be copied to KINC_FUNC void kinc_g4_render_target_get_pixels(kinc_g4_render_target_t *renderTarget, uint8_t *data); /// /// Generates the mipmap-chain for a render-target. /// /// The render-target to create the mipmaps for /// The number of mipmap-levels to generate KINC_FUNC void kinc_g4_render_target_generate_mipmaps(kinc_g4_render_target_t *renderTarget, int levels); #ifdef __cplusplus } #endif