#include "resource_texture.h"

/* Initializes texture resource. */
bool
resource_texture_init(Resources* self, TextureType type)
{
	if (!texture_init(&self->textures[type], TEXTURE_PATHS[type]))
	{
		printf(STRING_RESOURCE_ERROR, TEXTURE_PATHS[type]);
		return false;
	}

	printf(STRING_RESOURCE_INIT, TEXTURE_PATHS[type]);

	return true;
}

/* Frees texture resources. */
void
resource_texture_free(Resources* self, TextureType type)
{
	if (self->textures[type].isInit)
	{
		texture_free(&self->textures[type]);

		printf(STRING_RESOURCE_FREE, TEXTURE_PATHS[type]);
	}
}

/* Given an array, initializes texture resources. */
void
resource_texture_state_init(Resources* self, const TextureType* types, u32 count)
{
	for (s32 i = 0; i < (s32)count; i++)
		resource_texture_init(self, types[i]);
}

/* Frees texture resources. */
void
resource_texture_state_free(Resources* self, const TextureType* types, u32 count)
{
	for (s32 i = 0; i < (s32)count; i++)
		resource_texture_free(self, types[i]);
}
