/* * 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 #include #include /*********************************************************************************************************************** * 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; }