#ifndef RESOURCES_H
#define RESOURCES_H

#include "raylib.h"
#include "stdint.h"
#include "stdbool.h"

typedef struct ResourceContainer* ResourceHandle;
#define ResourceType(T) typedef struct T##Resource { ResourceHandle handle; T *resource; } T##Resource
#define ResourceEmpty(T) ((T##Resource){.handle = NULL, .resource = NULL})

ResourceType(Model);
ResourceType(Texture);
ResourceType(Shader);

//! Allocate and initialize memory required to operate resource subsystem
extern void InitializeResourceSubsystem();
//! Clean and shut down resource subsystem, all resource calls are invalid after this
extern void CleanResourceSubsystem();
//! Get model from resources.
extern bool GetModelResource(char const *path, ModelResource *out);
//! Get indexed texture from resources.
extern bool GetTextureResource(char const *path, TextureResource *out);
//! Get indexed shader from resources.
extern bool GetShaderResource(char const *path, ShaderResource *out);

//! Check if a resource is loaded or not.
extern bool IsResourceLoaded(ResourceHandle handle);
//! Load a resource using a handle returned from Get{Type}Resource, increments use count.
extern void LoadResource(ResourceHandle resource);
//! Release a resource using a handle returned from Get{Type}Resource, increments use count.
extern void ReleaseResource(ResourceHandle handle);

#endif // !RESOURCES_H
