Lugdunum  0.1.0
Camera.cpp
Go to the documentation of this file.
2 
5 
6 namespace lug {
7 namespace Graphics {
8 namespace Vulkan {
9 namespace Render {
10 namespace BufferPool {
11 
12 Camera::Camera(Renderer& renderer) : BufferPool(renderer, {
13  renderer.getDevice().getQueue("queue_graphics")->getQueueFamily()->getIdx(),
14  renderer.getDevice().getQueue("queue_transfer")->getQueueFamily()->getIdx()
15 }) {}
16 
18  const auto& result = BufferPool::allocate(camera.getHandle().value, camera.isDirty());
19  camera.clearDirty();
20 
21  if (std::get<0>(result) && std::get<1>(result)) {
22  // Update the buffer if the BufferPool told us that we need to
23  const Math::Mat4x4f cameraData[] = {
24  camera.getViewMatrix(),
25  camera.getProjectionMatrix()
26  };
27 
28  cmdBuffer.updateBuffer(*std::get<1>(result)->getBuffer(), cameraData, sizeof(cameraData), std::get<1>(result)->getOffset());
29  }
30 
31  return std::get<1>(result);
32 }
33 
34 } // BufferPool
35 } // Render
36 } // Vulkan
37 } // Graphics
38 } // lug
uint32_t value
Access of the raw value of the above bytefield.
Definition: Resource.hpp:48
std::tuple< bool, const SubBuffer * > allocate(size_t hash, bool dirty)
Definition: BufferPool.inl:7
const API::Queue * getQueue(const std::string &queueName) const
Definition: Device.cpp:70
Handle getHandle() const
Returns the handle of the Resource.
Definition: Resource.inl:133
const QueueFamily * getQueueFamily() const
Definition: Queue.cpp:86
const Math::Mat4x4f & getViewMatrix()
Gets the view matrix. Computes it if needed, but internally the view matrix is cached.
Definition: Camera.inl:41
const SubBuffer * allocate(const API::CommandBuffer &cmdBuffer, ::lug::Graphics::Render::Camera::Camera &camera)
Definition: Camera.cpp:17
const Math::Mat4x4f & getProjectionMatrix()
Gets the projection matrix. Computes it if needed, but internally the projection matrix is cached...
Definition: Camera.inl:33
bool isDirty(uint32_t currentFrame) const
Definition: DirtyObject.inl:21