#ifndef _loader_h_#define _loader_h_#include <SDL2/SDL.h>#include <SDL2/SDL_image.h>#include <SDL2/SDL_mixer.h>/*Copyright (c) 2013-2021 Devine Lu Linvega2018 web port by rezmason2021 C89 port by rezmasonPermission to use, copy, modify, and distribute this software for anypurpose with or without fee is hereby granted, provided that the abovecopyright notice and this permission notice appear in all copies.THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIESWITH REGARD TO THIS SOFTWARE.*//* The loader module is a utility for creating and destroying assets, and separately, for loading and unloading their data from disk. It encapsulates SDL calls to load and process these assets. Most of these assets are created when the game initializes, but some are so large, and are presented so infrequently, that they are loaded only when needed. These different load policies are represented by the LoadType enum.*/typedef enum { LOADTYPE_MANUAL, LOADTYPE_LAZY, LOADTYPE_LAZIER} LoadType;typedef struct { int w, h; char *filePath; SDL_Texture *texture; LoadType loadType;} Image;typedef struct { char *path; Mix_Chunk *chunk; float volume;} Sound;void Loader_Init(SDL_Renderer *renderer);void Loader_Quit(void);Image *Loader_CreateImage(Image **ptr, LoadType loadType, char *path);int Loader_LoadImage(Image *image);void Loader_UnloadImage(Image *image);void Loader_DestroyImage(Image *image);Sound *Loader_CreateSound(Sound **ptr, char *path, float volume);int Loader_LoadSound(Sound *sound);void Loader_UnloadSound(Sound *sound);void Loader_DestroySound(Sound *sound);int Loader_LoadText(char **ptr, char *path);int Loader_LoadCursor(SDL_Cursor **ptr, char *path);#endif
#ifndef _loader_h_
#define _loader_h_
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_mixer.h>
/*
Copyright (c) 2013-2021 Devine Lu Linvega
2018 web port by rezmason
2021 C89 port by rezmason
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE.
*/
/*
The loader module is a utility for creating
and destroying assets, and separately, for
loading and unloading their data from disk.
It encapsulates SDL calls to load and process
these assets.
Most of these assets are created when the game
initializes, but some are so large,
and are presented so infrequently, that they
are loaded only when needed. These different
load policies are represented
by the LoadType enum.
*/
typedef enum {
LOADTYPE_MANUAL,
LOADTYPE_LAZY,
LOADTYPE_LAZIER
} LoadType;
typedef struct {
int w, h;
char *filePath;
SDL_Texture *texture;
LoadType loadType;
} Image;
typedef struct {
char *path;
Mix_Chunk *chunk;
float volume;
} Sound;
void Loader_Init(SDL_Renderer *renderer);
void Loader_Quit(void);
Image *Loader_CreateImage(Image **ptr, LoadType loadType, char *path);
int Loader_LoadImage(Image *image);
void Loader_UnloadImage(Image *image);
void Loader_DestroyImage(Image *image);
Sound *Loader_CreateSound(Sound **ptr, char *path, float volume);
int Loader_LoadSound(Sound *sound);
void Loader_UnloadSound(Sound *sound);
void Loader_DestroySound(Sound *sound);
int Loader_LoadText(char **ptr, char *path);
int Loader_LoadCursor(SDL_Cursor **ptr, char *path);
#endif