OpenGL: Implement device

This commit is contained in:
Lynix
2020-04-19 01:36:44 +02:00
parent 0fa095e8f7
commit 5c3eb31d4a
7 changed files with 97 additions and 143 deletions

View File

@@ -2,63 +2,68 @@
// This file is part of the "Nazara Engine - OpenGL Renderer"
// For conditions of distribution and use, see copyright notice in Config.hpp
#if 0
#include <Nazara/OpenGLRenderer/OpenGLDevice.hpp>
#include <Nazara/OpenGLRenderer/OpenGLCommandPool.hpp>
#include <Nazara/OpenGLRenderer/OpenGLRenderPipeline.hpp>
#include <Nazara/OpenGLRenderer/OpenGLRenderPipelineLayout.hpp>
#include <Nazara/Renderer/CommandPool.hpp>
#include <Nazara/OpenGLRenderer/OpenGLShaderStage.hpp>
#include <Nazara/OpenGLRenderer/OpenGLTexture.hpp>
#include <Nazara/OpenGLRenderer/OpenGLTextureSampler.hpp>
#include <Nazara/OpenGLRenderer/Wrapper/Loader.hpp>
#include <stdexcept>
#include <Nazara/OpenGLRenderer/Debug.hpp>
namespace Nz
{
OpenGLDevice::OpenGLDevice(GL::Loader& loader) :
m_loader(loader)
{
m_referenceContext = loader.CreateContext({});
if (!m_referenceContext)
throw std::runtime_error("failed to create reference context");
}
OpenGLDevice::~OpenGLDevice() = default;
std::unique_ptr<GL::Context> OpenGLDevice::CreateContext(const GL::ContextParams& params) const
{
return m_loader.CreateContext(params, m_referenceContext.get());
}
std::unique_ptr<GL::Context> OpenGLDevice::CreateContext(const GL::ContextParams& params, WindowHandle handle) const
{
return m_loader.CreateContext(params, handle, m_referenceContext.get());
}
std::unique_ptr<AbstractBuffer> OpenGLDevice::InstantiateBuffer(BufferType type)
{
return std::make_unique<OpenGLBuffer>(*this, type);
return {};
}
std::unique_ptr<CommandPool> OpenGLDevice::InstantiateCommandPool(QueueType queueType)
{
return std::make_unique<OpenGLCommandPool>(*this, queueType);
return {};
}
std::unique_ptr<RenderPipeline> OpenGLDevice::InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo)
{
return std::make_unique<OpenGLRenderPipeline>(*this, std::move(pipelineInfo));
return {};
}
std::shared_ptr<RenderPipelineLayout> OpenGLDevice::InstantiateRenderPipelineLayout(RenderPipelineLayoutInfo pipelineLayoutInfo)
{
auto pipelineLayout = std::make_shared<OpenGLRenderPipelineLayout>();
if (!pipelineLayout->Create(*this, std::move(pipelineLayoutInfo)))
return {};
return pipelineLayout;
return {};
}
std::shared_ptr<ShaderStageImpl> OpenGLDevice::InstantiateShaderStage(ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize)
{
auto stage = std::make_shared<OpenGLShaderStage>();
if (!stage->Create(*this, type, lang, source, sourceSize))
return {};
return stage;
}
std::unique_ptr<Texture> OpenGLDevice::InstantiateTexture(const TextureInfo& params)
{
return std::make_unique<OpenGLTexture>(*this, params);
return {};
}
std::unique_ptr<TextureSampler> OpenGLDevice::InstantiateTextureSampler(const TextureSamplerInfo& params)
{
return std::make_unique<OpenGLTextureSampler>(*this, params);
return {};
}
}
#endif