Rendering Engine 0.2.0
Modular Graphics Rendering Engine | v0.2.0
Loading...
Searching...
No Matches
drawable_component.cpp
Go to the documentation of this file.
2
3#include "i_renderer.hpp"
5#include "model_cache.hpp"
6#include "texture_cache.hpp"
7#include "material_cache.hpp"
8#include "material.hpp"
9
10namespace rendering_engine
11{
12
14 :
15 mRenderContext(renderContext),
16 mMaterial(nullptr),
17 mMeshData(nullptr)
18{
19 mRenderResources = std::unique_ptr<IRenderResources>(mRenderContext.renderer->ProvideRenderResources());
20}
21
23{
24 mMaterial = mRenderContext.materialCache->GetMaterial(mMaterialName);
25 mMaterialParameters = mMaterial->PackMaterialParameters();
26 mMeshData = mRenderContext.meshCache->GetMeshResources(mMeshName).get();
27
28 mRenderResources->Initialize(mMaterial, mMeshData, mRenderContext.textureCache);
29}
30
32{
34 {
35 mRenderResources->Shutdown();
36 }
37}
38
39void DrawableComponent::SetMaterialName(const std::string& materialName)
40{
41 mMaterialName = materialName;
42}
43void DrawableComponent::SetMeshName(const std::string& meshName)
44{
45 mMeshName = meshName;
46}
47
48}
void SetMaterialName(const std::string &materialName)
Sets the material to use (by name).
std::unique_ptr< IRenderResources > mRenderResources
virtual void Initialize()
Initializes render resource pointers (material, mesh, etc.). Must be called after setting material an...
void SetMeshName(const std::string &meshName)
Sets the mesh to use (by name).
DrawableComponent(RenderResourceContext renderContext)
Constructs the DrawableComponent with a resource context.
Aggregates pointers to global rendering resource managers.