Fillwave  10.0.0
TextureSystem.h
1 #pragma once
2 
3 /*
4  * The MIT License (MIT)
5  *
6  * Copyright (c) 2018 Filip Wasil and Fillwave community members
7  *
8  * Permission is hereby granted, free of charge, to any person
9  * obtaining a copy of this software and associated documentation files (the "Software"),
10  * to deal in the Software without restriction, including without limitation the rights
11  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
12  * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included
15  * in all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
18  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22  */
23 
24 #include <flw/flc/extended/texturing/Texture1D.h>
25 #include <flw/flc/rendering/Texture2DRenderableDynamic.h>
26 #include <flw/flc/extended/rendering/Texture3DRenderable.h>
27 #include <flw/flf/loaders/modelloader/ModelLoaderTraits.h>
28 #include <flw/flf/loaders/TextureLoader.h>
29 #include <flw/flf/management/base/TCache.h>
30 
31 namespace flw {
32 namespace flf {
33 
38 class TextureSystem final {
39 public:
40  TextureSystem(const std::string& rootPath);
41 
42  void checkExtensions();
43 
44  flc::Texture2D* get(const std::string& texturePath);
45 
46  flc::Texture2DRenderable* getShadow2D(GLuint width, GLuint height);
47  flc::Texture2DRenderable* getColor2D(GLuint width, GLuint height);
48  flc::Texture2D* getDeferredColor(GLuint width, GLuint height, GLuint size = 1);
49  flc::Texture2D* getDeferredColorScreen(GLuint width, GLuint height, GLuint size = 1);
50  flc::Texture2D* getDeferredDepth(GLuint width, GLuint height);
51 #if defined(FILLWAVE_BACKEND_OPENGL_ES_20)
52 #else
53  flc::Texture3D* get(
54  const std::string& posX
55  , const std::string& negX
56  , const std::string& posY
57  , const std::string& negY
58  , const std::string& posZ
59  , const std::string& negZ);
60 
61  flc::Texture3DRenderable* getShadow3D(GLuint width, GLuint height);
62  flc::Texture2D* getDeferredStencilDepth(GLuint width, GLuint height);
63 #endif
65  getDynamic(const std::string& fragmentShaderPath, flc::Program* program, glm::ivec2 screenSize);
66 
67  void reload();
68 
69  void populateDynamicTextures(GLfloat timeExpiredInSeconds);
70 
71  void drawDynamicTextures();
72 
73  void resizeTextures(GLuint width, GLuint height);
74 
75  void resize(GLuint width, GLuint height);
76 
77 private:
78 
79  TCache<
80  MAX_CACHE_SIZE
82  , std::string
84  , flc::ParameterList&
85  , GLuint> mTextures2D;
86 
87  TCache<
88  MAX_CACHE_SIZE
89  , flc::Texture2D
90  , size_t
91  , flc::TextureConfig*
92  , flc::ParameterList&
93  , GLuint> mTextures2DDeferred;
94 
95  TCache<MAX_CACHE_SIZE
97  , std::string
98  , flc::TextureConfig*
99  , flc::ParameterList &
100  , flc::Program*> mTextures2DDynamic;
101 
102  TCache<
103  MAX_CACHE_SIZE
105  , size_t
106  , GLenum
107  , flc::TextureConfig*
108  , flc::ParameterList&> mTextures2DRenderable;
109 
110 #if defined(FILLWAVE_BACKEND_OPENGL_ES_20)
111 #else
112  TCache<
113  MAX_CACHE_SIZE
115  , std::string, flc::TextureConfig*
116  , flc::TextureConfig*
117  , flc::TextureConfig*
118  , flc::TextureConfig*
119  , flc::TextureConfig*
120  , flc::TextureConfig*
121  , flc::ParameterList&> mTextures3D;
122 
123  TCache<
124  MAX_CACHE_SIZE
126  , size_t
127  , flc::TextureConfig*
128  , flc::TextureConfig*
129  , flc::TextureConfig*
130  , flc::TextureConfig*
131  , flc::TextureConfig*
132  , flc::TextureConfig*
133  , flc::Texture2DRenderable*
134  , flc::ParameterList&> mTextures3DRenderable;
135 
136 #ifdef FILLWAVE_BACKEND_OPENGL_ES_30
137 #else /* FILLWAVE_BACKEND_OPENGL_ES_30 */
139 #endif /* FILLWAVE_BACKEND_OPENGL_ES_30 */
140 
141 #endif /* FILLWAVE_BACKEND_OPENGL_ES_20 */
142 
143  std::vector<GLenum> mSupportedCompresssionTypes;
144  const std::string mRootPath;
145  TextureLoader mLoader;
146 };
147 
148 } /* flf */
149 } /* flw */
Definition: Aliases.h:30
Manager to handle TextureObject1D, TextureObject2D and TextureObject3D objects.
Definition: TextureSystem.h:38
Single GLSL 2D Texture object.
Definition: Texture2D.h:36
Dynamic texture will update its content during runtime according to specified fragment shader...
Definition: Texture2DRenderableDynamic.h:34
Basic manager of composites.
Definition: TCache.h:44
One can render to this texture and use the rendered 6 images as a 2D texture.
Definition: Texture3DRenderable.h:34
Single GLSL 3D Texture object. It consists of six 2D images.
Definition: Texture3D.h:34
Single GLSL program object.
Definition: Program.h:37
Stores the single texture data.
Definition: TextureConfigs.h:35
One can render to this texture and use the rendered image as a 2D texture.
Definition: Texture2DRenderable.h:34