Lugdunum  0.1.0
Camera.cpp
Go to the documentation of this file.
2 
6 
7 namespace lug {
8 namespace Graphics {
9 namespace Builder {
10 
11 Camera::Camera(Renderer& renderer) : _renderer(renderer) {}
12 
14  std::unique_ptr<Resource> resource{nullptr};
15 
16  switch(_type) {
18  resource = std::unique_ptr<Resource>(new Render::Camera::Perspective(_name));
19  Render::Camera::Perspective* camera = static_cast<Render::Camera::Perspective*>(resource.get());
20 
22  camera->setFovY(_fovy);
23 
24  camera->setZNear(_znear);
25  camera->setZFar(_zfar);
26 
27  break;
28  }
29 
31  resource = std::unique_ptr<Resource>(new Render::Camera::Orthographic(_name));
32  Render::Camera::Orthographic* camera = static_cast<Render::Camera::Orthographic*>(resource.get());
33 
34  camera->setXMag(_xmag);
35  camera->setYMag(_ymag);
36 
37  camera->setZNear(_znear);
38  camera->setZFar(_zfar);
39 
40  break;
41  }
42  }
43 
44  return resource ? _renderer.getResourceManager()->add<::lug::Graphics::Render::Camera::Camera>(std::move(resource)) : nullptr;
45 }
46 
47 } // Builder
48 } // Graphics
49 } // lug
Resource::SharedPtr< T > add(std::unique_ptr< Resource > resource)
Add a resource to the ResourceManager.
Dummy class for a shared pointer.
Definition: Resource.hpp:66
Resource::SharedPtr< Render::Camera::Camera > build()
Definition: Camera.cpp:13
ResourceManager * getResourceManager() const
Definition: Renderer.inl:9
Camera(Renderer &renderer)
Definition: Camera.cpp:11