Graphics: Add GetViewerDataUBO
This commit is contained in:
parent
a6ff64106e
commit
a0d5750ec8
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
namespace Nz
|
||||
{
|
||||
class AbstractBuffer;
|
||||
class RenderDevice;
|
||||
|
||||
class NAZARA_GRAPHICS_API Graphics : public ModuleBase<Graphics>
|
||||
|
|
@ -29,6 +30,7 @@ namespace Nz
|
|||
~Graphics();
|
||||
|
||||
inline RenderDevice& GetRenderDevice();
|
||||
inline const std::shared_ptr<AbstractBuffer>& GetViewerDataUBO();
|
||||
|
||||
struct Config
|
||||
{
|
||||
|
|
@ -36,6 +38,7 @@ namespace Nz
|
|||
};
|
||||
|
||||
private:
|
||||
std::shared_ptr<AbstractBuffer> m_viewerDataUBO;
|
||||
std::shared_ptr<RenderDevice> m_renderDevice;
|
||||
|
||||
static Graphics* s_instance;
|
||||
|
|
|
|||
|
|
@ -11,6 +11,11 @@ namespace Nz
|
|||
{
|
||||
return *m_renderDevice;
|
||||
}
|
||||
|
||||
inline const std::shared_ptr<AbstractBuffer>& Graphics::GetViewerDataUBO()
|
||||
{
|
||||
return m_viewerDataUBO;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Graphics/DebugOff.hpp>
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include <Nazara/Graphics/Graphics.hpp>
|
||||
#include <Nazara/Graphics/MaterialPipeline.hpp>
|
||||
#include <Nazara/Graphics/PredefinedShaderStructs.hpp>
|
||||
#include <stdexcept>
|
||||
#include <Nazara/Graphics/Debug.hpp>
|
||||
|
||||
|
|
@ -39,6 +40,12 @@ namespace Nz
|
|||
throw std::runtime_error("failed to instantiate render device");
|
||||
|
||||
MaterialPipeline::Initialize();
|
||||
|
||||
Nz::PredefinedViewerData viewerUboOffsets = Nz::PredefinedViewerData::GetOffsets();
|
||||
|
||||
m_viewerDataUBO = m_renderDevice->InstantiateBuffer(Nz::BufferType_Uniform);
|
||||
if (!m_viewerDataUBO->Initialize(viewerUboOffsets.totalSize, Nz::BufferUsage_DeviceLocal | Nz::BufferUsage_Dynamic))
|
||||
throw std::runtime_error("failed to initialize viewer data UBO");
|
||||
}
|
||||
|
||||
Graphics::~Graphics()
|
||||
|
|
|
|||
Loading…
Reference in New Issue