SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLAssetManager.h
Go to the documentation of this file.
1 /**
2  * \file SLAssetManager.h
3  * \authors Michael Goettlicher
4  * \date Feb 2020
5  * \authors Marcus Hudritsch
6  * \copyright http://opensource.org/licenses/GPL-3.0
7  * \remarks Please use clangformat to format the code. See more code style on
8  * https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style
9 */
10 
11 #ifndef SLASSETMANAGER_H
12 #define SLASSETMANAGER_H
13 
14 #include <SL.h>
15 #include <SLMaterial.h>
16 #include <SLMesh.h>
17 #include <SLGLProgramGeneric.h>
18 
19 class SLTexFont;
20 class SLCamera;
21 class SLInputManager;
22 class SLAnimManager;
23 
24 //-----------------------------------------------------------------------------
25 //! Toplevel holder of the assets meshes, materials, textures and shaders
26 /*! All these assets can be shared among instances of SLScene, SLNode and
27  * SLMaterial. Shared assets are meshes (SLMesh), materials (SLMaterial),
28  * textures (SLGLTexture) and shader programs (SLGLProgram).
29  * One instance of SLAssetManager must be owned and destroyed by the app
30  * (see e.g. AppCommon.h).
31  */
33 {
34 public:
36 
37  void generateStaticFonts(SLstring fontPath);
38 
39  void clear();
40 
41  //! for all assets, clear gpu data
42  void deleteDataGpu();
43 
44  //! Removes the specified mesh from the meshes resource vector.
45  bool removeMesh(SLMesh* mesh);
46 
47  //! Removes the specified mesh from the meshes resource vector.
48  bool removeProgram(SLGLProgram* program);
49 
50  //! Returns the pointer to shader program if found by name
51  SLGLProgram* getProgramByName(const string& programName);
52 
53  //! merge other asset manager into this
54  void merge(SLAssetManager& other);
55 
56  // Getters
57  SLVMesh& meshes() { return _meshes; }
61 
62  // Static method & font pointers
63  // These fonts can be used inside a 2D or 3D scene, not within ImGui
64  static void generateFonts(SLstring fontPath,
65  SLGLProgram& fontTexProgram);
66  static void deleteFonts();
67  static SLTexFont* getFont(SLfloat heightMM, SLint dpi);
68 
69  static SLTexFont* font07; //!< 7 pixel high fixed size font
70  static SLTexFont* font08; //!< 8 pixel high fixed size font
71  static SLTexFont* font09; //!< 9 pixel high fixed size font
72  static SLTexFont* font10; //!< 10 pixel high fixed size font
73  static SLTexFont* font12; //!< 12 pixel high fixed size font
74  static SLTexFont* font14; //!< 14 pixel high fixed size font
75  static SLTexFont* font16; //!< 16 pixel high fixed size font
76  static SLTexFont* font18; //!< 18 pixel high fixed size font
77  static SLTexFont* font20; //!< 20 pixel high fixed size font
78  static SLTexFont* font22; //!< 22 pixel high fixed size font
79  static SLTexFont* font24; //!< 24 pixel high fixed size font
80 
81 protected:
82  SLVMesh _meshes; //!< Vector of all meshes
83  SLVMaterial _materials; //!< Vector of all materials pointers
84  SLVGLTexture _textures; //!< Vector of all texture pointers
85  SLVGLProgram _programs; //!< Vector of all shader program pointers
86 };
87 //-----------------------------------------------------------------------------
88 #endif // SLASSETMANAGER_H
static SLint dpi
Dot per inch resolution of screen.
Definition: AppGLFW.cpp:41
float SLfloat
Definition: SL.h:173
string SLstring
Definition: SL.h:158
int SLint
Definition: SL.h:170
vector< SLGLProgram * > SLVGLProgram
STL vector of SLGLProgram pointers.
Definition: SLGLProgram.h:149
vector< SLGLTexture * > SLVGLTexture
STL vector of SLGLTexture pointers.
Definition: SLGLTexture.h:342
vector< SLMaterial * > SLVMaterial
STL vector of material pointers.
Definition: SLMaterial.h:274
vector< SLMesh * > SLVMesh
Definition: SLMesh.h:263
SLAnimManager is the central class for all animation handling.
Definition: SLAnimManager.h:27
Toplevel holder of the assets meshes, materials, textures and shaders.
SLVGLTexture _textures
Vector of all texture pointers.
SLVMesh & meshes()
bool removeMesh(SLMesh *mesh)
Removes the specified mesh from the meshes resource vector.
void clear()
for all assets, clear gpu data
static SLTexFont * font24
24 pixel high fixed size font
static void deleteFonts()
Deletes all static fonts.
static SLTexFont * font10
10 pixel high fixed size font
static SLTexFont * getFont(SLfloat heightMM, SLint dpi)
returns nearest font for a given height in mm
static SLTexFont * font20
20 pixel high fixed size font
static SLTexFont * font09
9 pixel high fixed size font
static SLTexFont * font22
22 pixel high fixed size font
static SLTexFont * font14
14 pixel high fixed size font
static SLTexFont * font07
7 pixel high fixed size font
static SLTexFont * font08
8 pixel high fixed size font
SLVGLProgram & programs()
static SLTexFont * font18
18 pixel high fixed size font
SLGLProgram * getProgramByName(const string &programName)
Returns the pointer to shader program if found by name.
void merge(SLAssetManager &other)
merge other asset manager into this
SLVMaterial _materials
Vector of all materials pointers.
static SLTexFont * font12
12 pixel high fixed size font
SLVGLProgram _programs
Vector of all shader program pointers.
void deleteDataGpu()
for all assets, clear gpu data
static void generateFonts(SLstring fontPath, SLGLProgram &fontTexProgram)
Generates all static fonts.
SLVMesh _meshes
Vector of all meshes.
void generateStaticFonts(SLstring fontPath)
bool removeProgram(SLGLProgram *program)
Removes the specified mesh from the meshes resource vector.
SLVMaterial & materials()
static SLTexFont * font16
16 pixel high fixed size font
SLVGLTexture & textures()
Active or visible camera node class.
Definition: SLCamera.h:54
Encapsulation of an OpenGL shader program object.
Definition: SLGLProgram.h:56
SLInputManager. manages system input and custom input devices.
An SLMesh object is a triangulated mesh, drawn with one draw call.
Definition: SLMesh.h:134
Texture Font class inherits SLGLTexture for alpha blended font rendering.
Definition: SLTexFont.h:40