ASW Lib
A.D.S. Games SDL Wrapper Library. A library targeted at Allegro4 users who want to switch to SDL3 and use modern c++.
Loading...
Searching...
No Matches
assets.h
Go to the documentation of this file.
1
8
9#ifndef ASW_ASSETS_H
10#define ASW_ASSETS_H
11
12#include <string>
13
14#include "./types.h"
15#include "./util.h"
16
17namespace asw::assets {
18
19// --- Paths ---
20
26std::string get_path(const std::string& filename);
27
28// --- Texture ---
29
38asw::Texture load_texture(const std::string& filename);
39
47asw::Texture load_texture(const std::string& filename, const std::string& key);
48
54asw::Texture get_texture(const std::string& key);
55
60void unload_texture(const std::string& key);
61
68asw::Texture create_texture(int w, int h);
69
70// --- Font ---
71
79asw::Font load_font(const std::string& filename, float size);
80
88asw::Font load_font(const std::string& filename, float size, const std::string& key);
89
95asw::Font get_font(const std::string& key);
96
101void unload_font(const std::string& key);
102
103// --- Sample ---
104
111asw::Sample load_sample(const std::string& filename);
112
119asw::Sample load_sample(const std::string& filename, const std::string& key);
120
126asw::Sample get_sample(const std::string& key);
127
132void unload_sample(const std::string& key);
133
134// --- Music ---
135
142asw::Music load_music(const std::string& filename);
143
150asw::Music load_music(const std::string& filename, const std::string& key);
151
157asw::Music get_music(const std::string& key);
158
163void unload_music(const std::string& key);
164
165// --- Global ---
166
170void clear_all();
171
172} // namespace asw::assets
173
174#endif // ASW_ASSETS_H
asw::Sample get_sample(const std::string &key)
Get a cached sample.
Definition assets.cpp:152
asw::Texture create_texture(int w, int h)
Create a Texture given the specified dimensions.
Definition assets.cpp:76
void unload_music(const std::string &key)
Remove a cached music.
Definition assets.cpp:200
std::string get_path(const std::string &filename)
Get the full path to an asset given its filename. This assumes that all assets are located in an "ass...
Definition assets.cpp:23
asw::Texture get_texture(const std::string &key)
Get a cached texture.
Definition assets.cpp:62
void unload_sample(const std::string &key)
Remove a cached sample.
Definition assets.cpp:161
void unload_font(const std::string &key)
Remove a cached font.
Definition assets.cpp:122
asw::Music load_music(const std::string &filename)
Loads a music file from a file. Formats supported are WAV, AIFF, RIFF, OGG and VOC....
Definition assets.cpp:168
void clear_all()
Clear all cached assets. This will remove all cached textures, fonts, samples, and music.
Definition assets.cpp:207
void unload_texture(const std::string &key)
Remove a cached texture.
Definition assets.cpp:71
asw::Music get_music(const std::string &key)
Get a cached music.
Definition assets.cpp:191
asw::Font load_font(const std::string &filename, float size)
Loads a TTF font from a file. This will abort if the file is not found.
Definition assets.cpp:90
asw::Sample load_sample(const std::string &filename)
Loads a sample from a file. Formats supported are WAV, AIFF, RIFF, OGG and VOC. This will abort if th...
Definition assets.cpp:129
asw::Font get_font(const std::string &key)
Get a cached font.
Definition assets.cpp:113
asw::Texture load_texture(const std::string &filename)
Loads a texture from a file. Formats supported are PNG, ICO, CUR, BMP, GIF, JPG, LBM,...
Definition assets.cpp:36
std::shared_ptr< Mix_Chunk > Sample
Alias for a shared pointer to an Mix_Chunk.
Definition types.h:44
std::shared_ptr< TTF_Font > Font
Alias for a shared pointer to an TTF_Font.
Definition types.h:41
std::shared_ptr< Mix_Music > Music
Alias for a shared pointer to an Mix_Music.
Definition types.h:47
std::shared_ptr< SDL_Texture > Texture
Alias for a shared pointer to an SDL_Texture.
Definition types.h:38
Types used throughout the ASW library.
General utility functions.