#pragma once #include #include #include "textureunit.h" #include /*! \file texture.h \brief Provides functions for handling textures. */ #ifdef __cplusplus extern "C" { #endif typedef struct kinc_g5_texture { int texWidth; int texHeight; kinc_image_format_t format; Texture5Impl impl; } kinc_g5_texture_t; /// /// Allocates and initializes a texture without copying any data into it. /// /// The texture to initialize /// The width of the texture to create /// The height of the texture to create /// The format of the texture to create KINC_FUNC void kinc_g5_texture_init(kinc_g5_texture_t *texture, int width, int height, kinc_image_format_t format); /// /// Allocates and initializes a 3d-texture without copying any data into it. /// /// The texture to initialize /// The width of the texture to create /// The height of the texture to create /// The depth of the texture to create /// The format of the texture to create KINC_FUNC void kinc_g5_texture_init3d(kinc_g5_texture_t *texture, int width, int height, int depth, kinc_image_format_t format); /// /// Allocates and initializes a texture and copies image-data into it. /// /// The texture to initialize /// The image which's data is copied into the texture KINC_FUNC void kinc_g5_texture_init_from_image(kinc_g5_texture_t *texture, kinc_image_t *image); // void kinc_g5_texture_init_from_encoded_data(kinc_g5_texture_t *texture, void *data, int size, const char *format, bool readable); // void kinc_g5_texture_init_from_data(kinc_g5_texture_t *texture, void *data, int width, int height, int format, bool readable); KINC_FUNC void kinc_g5_texture_init_non_sampled_access(kinc_g5_texture_t *texture, int width, int height, kinc_image_format_t format); /// /// Deallocates and destroys a texture. /// /// The texture to destroy KINC_FUNC void kinc_g5_texture_destroy(kinc_g5_texture_t *texture); #ifdef KINC_ANDROID KINC_FUNC void kinc_g5_texture_init_from_id(kinc_g5_texture_t *texture, unsigned texid); #endif KINC_FUNC uint8_t *kinc_g5_texture_lock(kinc_g5_texture_t *texture); KINC_FUNC void kinc_g5_texture_unlock(kinc_g5_texture_t *texture); /// /// Clears parts of a texture to a color. /// KINC_FUNC void kinc_g5_texture_clear(kinc_g5_texture_t *texture, int x, int y, int z, int width, int height, int depth, unsigned color); #if defined(KINC_IOS) || defined(KINC_MACOS) KINC_FUNC void kinc_g5_texture_upload(kinc_g5_texture_t *texture, uint8_t *data); #endif /// /// Generates the mipmap-chain for a texture. /// /// The render-target to create the mipmaps for /// The number of mipmap-levels to generate KINC_FUNC void kinc_g5_texture_generate_mipmaps(kinc_g5_texture_t *texture, int levels); KINC_FUNC void kinc_g5_texture_set_mipmap(kinc_g5_texture_t *texture, kinc_image_t *mipmap, int level); /// /// Returns the stride of the first mipmap-layer of the texture in bytes. /// /// The texture to figure out the stride for /// The stride of the first mipmap-layer in bytes KINC_FUNC int kinc_g5_texture_stride(kinc_g5_texture_t *texture); #ifdef __cplusplus } #endif