jubilant-funicular
Public Member Functions | Private Attributes | List of all members
nta::ContextData Class Reference

#include <ContextData.h>

Collaboration diagram for nta::ContextData:
Collaboration graph
[legend]

Public Member Functions

GLSLProgramgetGLSLProgram (const utils::Path &progPath)
 
GLSLProgramgetGLSLProgram (crstring name, const utils::Path &vert, const utils::Path &frag)
 
Result< GLTexturegetTexture (const utils::Path &path, crvec2 dimensions=glm::vec2(0))
 Gets a GLTexture representing the image at the given path.
 
Result< utils::PathgetTextureFile (GLTexture tex)
 Gets the name of the file used the create tex.
 
Result< SpriteFont * > getSpriteFont (const utils::Path &fontPath, int fontSize=32)
 Gets SpriteFont created from the given font with the given size.
 
void reloadShaders ()
 Reloads all known shaders.
 
void reloadTextures ()
 Reloads all known texture. More...
 
void reload ()
 Reloads everything.
 
void setTextureFolder (const utils::Path &fldr)
 Sets the texture folder.
 
void setGLSLFolder (const utils::Path &fldr)
 Sets the shader folder.
 
void setFontFolder (const utils::Path &fldr)
 Sets the font folder.
 
void destroy ()
 Deletes all data (does not reset folder paths)
 

Private Attributes

std::map< std::string, GLSLProgramm_glslMap
 Collection of GLSLProgram.
 
std::map< utils::Path, GLTexturem_textureMap
 a map file names to textures
 
std::map< GLTexture, utils::Pathm_textureFiles
 Inverse map to m_textureMap.
 
std::map< std::pair< utils::Path, int >, SpriteFontm_fontMap
 Map front (font name, font size) -> SpriteFont.
 
utils::Path m_texture_folder = "./"
 Folder containing textures.
 
utils::Path m_glsl_folder = "./"
 Folder containing shaders.
 
utils::Path m_font_folder = "./"
 Folder containing fonts.
 

Detailed Description

Certain pieces of data are tied to a specific GL context (e.g. a Window). This class manages all such data specific to one context.

Generally, there should be one ContextData per ScreenManager.

Definition at line 17 of file ContextData.h.

Member Function Documentation

◆ getGLSLProgram() [1/2]

GLSLProgram * nta::ContextData::getGLSLProgram ( const utils::Path progPath)

Gets GLSLProgram at specified path

Assumes vertex shader is (progPath + ".vert") and fragment shader is (progPath + ".frag")

Todo:
call resolve (?)

Definition at line 6 of file ContextData.cpp.

◆ getGLSLProgram() [2/2]

GLSLProgram * nta::ContextData::getGLSLProgram ( crstring  name,
const utils::Path vert,
const utils::Path frag 
)

Gets GLSLProgram, specifying explicitly where the vertex and fragment shaders are.

Uses name as the key in the map

Definition at line 14 of file ContextData.cpp.

◆ reloadTextures()

void nta::ContextData::reloadTextures ( )

Reloads all known texture.

Todo:
Implement

Definition at line 62 of file ContextData.cpp.

Referenced by reload().


The documentation for this class was generated from the following files: