12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- /*
- * 3D Engine
- * texture.c:
- * Based on pikuma.com 3D software renderer in C
- * Copyright (c) 2021 986-Studio. All rights reserved.
- *
- * Created by Manoël Trapier on 07/03/2021.
- */
- #include <stdlib.h>
- #include <upng.h>
- #include <texture.h>
- /***********************************************************************************************************************
- * Public functions
- **********************************************************************************************************************/
- void loadTextureDateFromPng(texture_t *tex, const char *filepath)
- {
- if (tex->png != NULL)
- {
- upng_free(tex->png);
- tex->png = NULL;
- }
- tex->png = upng_new_from_file(filepath);
- if (tex->png != NULL)
- {
- upng_decode(tex->png);
- if (upng_get_error(tex->png) == UPNG_EOK)
- {
- tex->data = (colour_t *)upng_get_buffer(tex->png);
- tex->width = upng_get_width(tex->png);
- tex->height = upng_get_height(tex->png);
- }
- }
- }
- void textureCleanup(texture_t *tex)
- {
- if (tex->png != NULL)
- {
- upng_free(tex->png);
- tex->png = NULL;
- }
- /* uPNG do free the buffer for us. */
- tex->data = NULL;
- }
- colour_t getTextureColour(texture_t *texture, tex2_t position)
- {
- return 0;
- }
|