Sleeping Wombat GUI  0.100
swGUI
ResourceManager.h
Go to the documentation of this file.
1 #pragma once
2 
13 
14 
15 class ILoader;
16 
17 
18 
25 {
26 private:
27 protected:
31 
37 
43  // UWAGA! m_fileModel musi być na końcu. Jego destruktor kasuje odwołania do obiektów powyżej. Podobnie RenderTargetObject odwołuje się do tekstur.
44  // Muszą one w tym czasie istnieć, a destruktory są wywoływane w kolejności odwrotnej do zadeklarowanej w klasie.
46 
47  /*loadery dla różnych formatów plików z modelami*/
48  //std::vector<ILoader*> m_loader; ///<Loadery do plików z modelami 3D
49 
50 public:
51  explicit ResourceManager();
53 
54  // Funkcje do zarządzania assetami
55  RenderTargetObject* CreateRenderTarget ( const std::wstring& name, const RenderTargetDescriptor& renderTargetDescriptor );
56 
60 
61  inline BlendingState* GetBlendingState ( const std::wstring& name ) { return m_blendingState.get( name ); }
62  inline RasterizerState* GetRasterizerState ( const std::wstring& name ) { return m_rasterizerState.get( name ); }
63  inline DepthStencilState* GetDepthStencilState ( const std::wstring& name ) { return m_depthStencilState.get( name ); }
64 
65  inline BlendingState* GetBlendingState ( const BlendingInfo& info ) { return m_blendingState.Find( info ); }
66  inline RasterizerState* GetRasterizerState ( const RasterizerStateInfo& info ) { return m_rasterizerState.Find( info ); }
67  inline DepthStencilState* GetDepthStencilState ( const DepthStencilInfo& info ) { return m_depthStencilState.Find( info ); }
68 
69  inline RenderTargetObject* GetRenderTarget ( const std::wstring& name ) { return m_renderTarget.get( name ); }
70  inline VertexShader* GetVertexShader ( const std::wstring& name ) { return m_vertexShader.get( name ); }
71  inline PixelShader* GetPixelShader ( const std::wstring& name ) { return m_pixelShader.get( name ); }
72  inline TextureObject* GetTexture ( const std::wstring& name ) { return m_texture.get( name ); }
73  inline BufferObject* GetVertexBuffer ( const std::wstring& name ) { return m_vertexBuffer.get( name ); }
74  inline BufferObject* GetConstantBuffer ( const std::wstring& name ) { return m_constantBuffer.get( name ); }
75  inline BufferObject* GetIndexBuffer ( const std::wstring& name ) { return m_indexBuffer.get( name ); }
76  inline ShaderInputLayout* GetLayout ( const std::wstring& name ) { return m_vertexLayout.get( name ); }
77 
79 
83  TextureObject* LoadTexture ( const std::wstring& fileName );
84  VertexShader* LoadVertexShader ( const std::wstring& fileName, const std::string& shaderEntry );
85  VertexShader* LoadVertexShader ( const std::wstring& fileName, const std::string& shaderEntry, ShaderInputLayout** layout, InputLayoutDescriptor* layout_desc );
86  PixelShader* LoadPixelShader ( const std::wstring& fileName, const std::string& shaderEntry );
87  GeometryShader* LoadGeometryShader ( const std::wstring& fileName, const std::string& shaderEntry );
88  ControlShader* LoadControlShader ( const std::wstring& fileName, const std::string& shaderEntry );
89  EvaluationShader* LoadEvaluationShader ( const std::wstring& fileName, const std::string& shaderEntry );
91 
96  ResourcePtr< BufferObject > CreateVertexBuffer ( const std::wstring& name, const void* buffer, unsigned int element_size, unsigned int vert_count );
97  ResourcePtr< BufferObject > CreateVertexBuffer ( const std::wstring& name, const VertexBufferInitData& data );
98  ResourcePtr< BufferObject > CreateIndexBuffer ( const std::wstring& name, const void* buffer, unsigned int element_size, unsigned int vert_count );
99  ResourcePtr< BufferObject > CreateIndexBuffer ( const std::wstring& name, const IndexBufferInitData& data );
100  ResourcePtr< BufferObject > CreateConstantsBuffer ( const std::wstring& name, const void* buffer, unsigned int size );
101  ResourcePtr< BufferObject > CreateConstantsBuffer ( const std::wstring& name, const ConstantBufferInitData& data );
102 
103  ResourcePtr< BlendingState > CreateBlendingState ( const std::wstring& name, const BlendingInfo& info );
104  ResourcePtr< RasterizerState > CreateRasterizerState ( const std::wstring& name, const RasterizerStateInfo& info );
105  ResourcePtr< DepthStencilState >CreateDepthStencilState ( const std::wstring& name, const DepthStencilInfo& info );
106 
108 
109  RenderTargetObject* AddRenderTarget ( RenderTargetObject* renderTarget, const std::wstring& name );
110 
111 
114  std::vector< ResourcePtr< BufferObject > > ListVertexBuffers ();
115  std::vector< ResourcePtr< BufferObject > > ListIndexBuffers ();
116  std::vector< ResourcePtr< BufferObject > > ListConstantBuffers ();
117  std::vector< ResourcePtr< ShaderInputLayout > > ListShaderLayouts ();
118 
119  std::vector< ResourcePtr< TextureObject > > ListTextures ();
120  std::vector< ResourcePtr< VertexShader > > ListVertexShaders ();
121  std::vector< ResourcePtr< PixelShader > > ListPixelShaders ();
122 
123  std::vector< ResourcePtr< RenderTargetObject > > ListRenderTargets ();
125 
126 private:
127  //ILoader* FindLoader ( const std::wstring& path );
128 
129  virtual MemoryChunk LoadTextureImpl ( const filesystem::Path& filePath, TextureInfo& texInfo );
130 };
131 
GeometryShader * LoadGeometryShader(const std::wstring &fileName, const std::string &shaderEntry)
Definition: ResourceManager.cpp:245
Definition: DepthStencilState.h:45
Klasa przechowująca pixel shader.
Definition: MeshResources.h:429
ResourceContainer< BlendingState > m_blendingState
BlendingState objects.
Definition: ResourceManager.h:28
ResourceManager()
Definition: ResourceManager.cpp:27
Deskryptor tekstury.
Definition: MeshResources.h:145
std::vector< ResourcePtr< BufferObject > > ListVertexBuffers()
Listowanie buforów wierzchołków.
Definition: ResourceManager.cpp:473
ResourceContainer< BufferObject > m_constantBuffer
Shader constant buffers.
Definition: ResourceManager.h:41
Definition: Path.h:22
TextureObject * LoadTexture(const std::wstring &fileName)
Dodaje teksturę do ModelManagera, jeżeli jeszcze nie istniała.
Definition: ResourceManager.cpp:283
Obiekt opakowujący bufor.Bufor może być zarówno buforem wierzchołków, indeksów jak i stałych...
Definition: MeshResources.h:516
Zawiera deklarację szblonu klasy kontenera dla assetów.
std::vector< ResourcePtr< RenderTargetObject > > ListRenderTargets()
Listowanie render targetów.
Definition: ResourceManager.cpp:515
Klasa przechowuje opis layoutu wierzchołka, na podstawie którego tworzony jest obiekt layoutu...
Definition: MeshResources.h:352
std::vector< ResourcePtr< PixelShader > > ListPixelShaders()
Listowanie pixel shaderów.
Definition: ResourceManager.cpp:509
BufferObject * GetVertexBuffer(const std::wstring &name)
Zwraca bufor wierzchołków o podanej nazwie, jeżeli jest wczytany.
Definition: ResourceManager.h:73
ResourceContainer< RasterizerState > m_rasterizerState
RasterizerState objects.
Definition: ResourceManager.h:29
ResourceContainer< TextureObject > m_texture
Textures.
Definition: ResourceManager.h:38
Definition: RasterizerState.h:20
Index buffer initialization data.
Definition: BufferInitData.h:54
ResourceContainer< BufferObject > m_vertexBuffer
Vertex buffers.
Definition: ResourceManager.h:39
std::vector< ResourcePtr< BufferObject > > ListConstantBuffers()
Listowanie buforów stałych.
Definition: ResourceManager.cpp:485
BlendingState * GetBlendingState(const BlendingInfo &info)
Definition: ResourceManager.h:65
PixelShader * GetPixelShader(const std::wstring &name)
Zwraca pixel shader o podanej nazwie, jeżeli jest wczytany.
Definition: ResourceManager.h:71
Klasa przechowuje pamięć o dowolnym przeznaczeniu.
Definition: MemoryChunk.h:8
std::vector< ResourcePtr< TextureObject > > ListTextures()
Listowanie tekstur.
Definition: ResourceManager.cpp:497
Klasa przechowująca pixel shader.
Definition: MeshResources.h:450
VertexShader * LoadVertexShader(const std::wstring &fileName, const std::string &shaderEntry)
Dodaje vertex shader do ResourceManagera. Jeżeli obiekt już istniał, to nie jest tworzony nowy...
Definition: ResourceManager.cpp:130
ResourceContainer< ControlShader > m_controlShaders
Tesselation control shaders.
Definition: ResourceManager.h:36
RenderTargetObject * CreateRenderTarget(const std::wstring &name, const RenderTargetDescriptor &renderTargetDescriptor)
Znajduje Loader pasujący do pliku podanego w parametrze.
Definition: ResourceManager.cpp:69
ResourceContainer< PixelShader > m_pixelShader
Pixel shaders.
Definition: ResourceManager.h:33
Wrapper for low level resources and high level assets.
Definition: ResourcePtr.h:18
Klasa przechowująca pixel shader.
Definition: MeshResources.h:408
std::vector< ResourcePtr< BufferObject > > ListIndexBuffers()
Listowanie buforów indeksów.
Definition: ResourceManager.cpp:479
Struktura używana do tworzenia render targetu.
Definition: MeshResources.h:238
DepthStencilState * GetDepthStencilState(const DepthStencilInfo &info)
Definition: ResourceManager.h:67
ResourceContainer< GeometryShader > m_geometryShader
Geometry shaders.
Definition: ResourceManager.h:34
ResourcePtr< BufferObject > CreateIndexBuffer(const std::wstring &name, const void *buffer, unsigned int element_size, unsigned int vert_count)
Dodaje do ResourceManagera bufor indeksów. Jeżeli pod taką nazwą istnieje jakiś bufor, to zostanie zwrócony wskaźnik na niego.
Definition: ResourceManager.cpp:356
TextureObject * GetTexture(const std::wstring &name)
Zwraca teksturę o podanej nazwie, jeżeli jest wczytany.
Definition: ResourceManager.h:72
~ResourceManager()
Definition: ResourceManager.cpp:32
Initialization of BlendingState.
Definition: BlendingState.h:20
Plik zawiera deklaracje formatów wierzchołków oraz klas zawierających assety shadery itp...
TYPE * get(unsigned int id)
Zwraca element na podstawie identyfikatora.
Definition: ResourceContainer.h:109
Klasa przechowująca pixel shader.
Definition: MeshResources.h:471
BufferObject * GetIndexBuffer(const std::wstring &name)
Zwraca bufor indeksów o podanej nazwie, jeżeli jest wczytany.
Definition: ResourceManager.h:75
ResourceContainer< DepthStencilState > m_depthStencilState
DepthStencilState objects.
Definition: ResourceManager.h:30
RasterizerState * GetRasterizerState(const RasterizerStateInfo &info)
Definition: ResourceManager.h:66
std::vector< ResourcePtr< ShaderInputLayout > > ListShaderLayouts()
Listowanie layoutów wierzchołków.
Definition: ResourceManager.cpp:491
Klasa przechowująca tekstury.Klasa bazowa, która będzie używana przez obiekty silnika. Powinny po niej odziedziczyć obiekty konkretnego API graficznego, żeby zaimplementować najważniejsze funkcjonalności.
Definition: MeshResources.h:206
BufferObject * GetConstantBuffer(const std::wstring &name)
Zwraca bufor stałych o podanej nazwie, jeżeli jest wczytany.
Definition: ResourceManager.h:74
TYPE * Find(const DescType &desc)
Finds resource matching given descriptor.
Definition: ResourceContainer.h:123
EvaluationShader * LoadEvaluationShader(const std::wstring &fileName, const std::string &shaderEntry)
Definition: ResourceManager.cpp:269
RasterizerState * GetRasterizerState(const std::wstring &name)
Definition: ResourceManager.h:62
PixelShader * LoadPixelShader(const std::wstring &fileName, const std::string &shaderEntry)
Dodaje pixel shader do ResourceManagera. Jeżeli obiekt już istniał, to nie jest tworzony nowy...
Definition: ResourceManager.cpp:229
VertexShader * GetVertexShader(const std::wstring &name)
Zwraca vertex shader o podanej nazwie, jeżeli jest wczytany.
Definition: ResourceManager.h:70
ResourceContainer< BufferObject > m_indexBuffer
Index buffers.
Definition: ResourceManager.h:40
ResourceContainer< EvaluationShader > m_evaluationShader
Tesselation evaluation shaders.
Definition: ResourceManager.h:35
Klasa przechowuje layout wierzchołka trafiającego do vertex shadera.
Definition: MeshResources.h:334
ShaderInputLayout * GetLayout(const std::wstring &name)
Definition: ResourceManager.h:76
ResourceContainer< RenderTargetObject > m_renderTarget
Obiekty mogące służyć za render target.
Definition: ResourceManager.h:45
Klasa dla render targetów.Klasa umożliwia pobranie jednej z tekstur składowych i udostępnienie dla sh...
Definition: MeshResources.h:301
Definition: DepthStencilState.h:17
ResourcePtr< BufferObject > CreateVertexBuffer(const std::wstring &name, const void *buffer, unsigned int element_size, unsigned int vert_count)
Dodaje do ResourceManagera bufor wierzchołków. Jeżeli pod taką nazwą istnieje jakiś bufor...
Definition: ResourceManager.cpp:317
ResourceContainer< VertexShader > m_vertexShader
Vertex shaders.
Definition: ResourceManager.h:32
ControlShader * LoadControlShader(const std::wstring &fileName, const std::string &shaderEntry)
Definition: ResourceManager.cpp:263
Vertex buffer initialization data.
Definition: BufferInitData.h:40
std::vector< ResourcePtr< VertexShader > > ListVertexShaders()
Listowanie vertex shaderów.
Definition: ResourceManager.cpp:503
ResourcePtr< BufferObject > CreateConstantsBuffer(const std::wstring &name, const void *buffer, unsigned int size)
Dodaje do ResourceManagera bufor stałch dla shadera. Jeżeli pod taką nazwą istnieje jakiś bufor...
Definition: ResourceManager.cpp:394
DepthStencilState * GetDepthStencilState(const std::wstring &name)
Definition: ResourceManager.h:63
Klasa przechowująca vertex shader.
Definition: MeshResources.h:387
Rasterizer state and depth stencil state.
Definition: RasterizerState.h:67
Definition: BlendingState.h:72
ResourcePtr< RasterizerState > CreateRasterizerState(const std::wstring &name, const RasterizerStateInfo &info)
Created RasterizerState object.
Definition: ResourceManager.cpp:440
RenderTargetObject * AddRenderTarget(RenderTargetObject *renderTarget, const std::wstring &name)
Dodaje renderTarget do ResourceManagera, jeżeli jeszcze nie istniał.
Definition: ResourceManager.cpp:113
ResourceContainer< ShaderInputLayout > m_vertexLayout
Vertex layouts.
Definition: ResourceManager.h:42
ResourcePtr< DepthStencilState > CreateDepthStencilState(const std::wstring &name, const DepthStencilInfo &info)
Created DepthStencilState object.
Definition: ResourceManager.cpp:455
RenderTargetObject * GetRenderTarget(const std::wstring &name)
Zwraca RenderTarget o podanej nazwie, jeżeli jest wczytany.
Definition: ResourceManager.h:69
virtual MemoryChunk LoadTextureImpl(const filesystem::Path &filePath, TextureInfo &texInfo)
Implementation of texture loading.
Definition: ResourceManager.cpp:526
Manager for low level resources.
Definition: ResourceManager.h:24
BlendingState * GetBlendingState(const std::wstring &name)
Definition: ResourceManager.h:61
Constant buffer initialization data.
Definition: BufferInitData.h:32
ResourcePtr< BlendingState > CreateBlendingState(const std::wstring &name, const BlendingInfo &info)
Created BlendingState object.
Definition: ResourceManager.cpp:425