1 #include "nta/ContextData.h"
2 #include "nta/ResourceManager.h"
3 #include "nta/Logger.h"
8 std::string full_path = (
m_glsl_folder + progPath).to_string();
10 m_glslMap[full_path].compileShaders(full_path);
15 std::string full_vert_path = (
m_glsl_folder + vert).to_string(),
18 m_glslMap[name].compileShaders(full_vert_path, full_frag_path);
25 std::string path_str = full_path.to_string();
29 Logger::writeToLog(
"RawTexture \"" + path_str +
"\" doesn't have a GLTexture in this context.");
43 std::pair<utils::Path, int> key = std::make_pair(
m_font_folder + fontPath, fontSize);
45 std::string path_str = key.first.to_string();
46 auto ttf_font = ResourceManager::getFont(path_str, fontSize);
47 if (ttf_font.is_err())
return ttf_font.convert_error<
SpriteFont*>();
70 pair.second.destroy();
75 pair.second.destroy();
80 pair.second.destroy();
represents a program written in GLSL comprised of a vertex shader and a fragment shader
void destroy()
Deletes all data (does not reset folder paths)
static void writeToLog(crstring entry)
writes an entry in the log
static Result< RawTexture > getTexture(crstring imagePath, crvec2 dimensions)
returns the resource with the given path, loading it if need be
A (case-sensitive) Path in a file system.
void reloadShaders()
Reloads all known shaders.
static void unindent(size_t tab_size=TAB_SIZE)
unindents entries
std::map< utils::Path, GLTexture > m_textureMap
a map file names to textures
utils::Path m_texture_folder
Folder containing textures.
static Result new_err(const Error &err)
Result< utils::Path > getTextureFile(GLTexture tex)
Gets the name of the file used the create tex.
static Result new_ok(const T &data)
std::map< std::string, GLSLProgram > m_glslMap
Collection of GLSLProgram.
represents a texture (tied to a specific GL context)
Result< GLTexture > getTexture(const utils::Path &path, crvec2 dimensions=glm::vec2(0))
Gets a GLTexture representing the image at the given path.
std::map< GLTexture, utils::Path > m_textureFiles
Inverse map to m_textureMap.
Result< SpriteFont * > getSpriteFont(const utils::Path &fontPath, int fontSize=32)
Gets SpriteFont created from the given font with the given size.
utils::Path m_glsl_folder
Folder containing shaders.
GLSLProgram * getGLSLProgram(const utils::Path &progPath)
utils::Path m_font_folder
Folder containing fonts.
std::string to_string(const T &input, std::size_t precision=0)
converts input to a std::string
static Error writeErrorToLog(crstring error, ErrorType type=OTHER)
writes entry in log and then notifies ErrorManager
Loads in a .ttf file, creates a font texture from it which is then used to render text.
static void indent(size_t tab_size=TAB_SIZE)
indents entries
std::map< std::pair< utils::Path, int >, SpriteFont > m_fontMap
Map front (font name, font size) -> SpriteFont.
void reloadTextures()
Reloads all known texture.