/** * Copyright (c) 2021 Dominic Masters * * This software is released under the MIT License. * https://opensource.org/licenses/MIT */ #pragma once #include "../libs.h" #include "../display/primitive/primitive.h" #include "../display/primitive/quad.h" #include "../display/texture.h" #include "../display/shader.h" typedef struct { texture_t *texture; primitive_t quad; float width, height; } image_t; /** * Initialize an image. * * @param image Image to initialize. */ void imageInit(image_t *image); /** * Set the texture for an image. This will also initialize the underlying quad. * * @param image Image to set the texture for. * @param texture Texture to use. */ void imageSetTexture(image_t *image, texture_t *texture); /** * Set the texture for an image. This will also initialize the underlying quad. * Also allows cropping of the texture image. * * @param image Image to set the texture for. * @param texture Texture to use. * @param x X position of the crop. * @param y Y position of the crop. * @param width Width of the crop. * @param height Height of the crop. */ void imageSetTextureAndCrop(image_t *image, texture_t *texture, float x, float y, float width, float height ); /** * Render an image * * @param image Image to render. * @param shader Shader to use while rendering. * @param x X position. * @param y Y position. */ void imageRender(image_t *image, shader_t *shader, float x, float y); /** * Cleanup a previously initialized image. * * @param image Image to dispose. */ void imageDispose(image_t *image);