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

@@ -1,35 +0,0 @@
// Copyright (C) 2020 Jérôme Leclercq
// This file is part of the "Nazara Engine - OpenGL Renderer"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_OPENGL_HPP
#define NAZARA_OPENGL_HPP
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Core/Initializer.hpp>
#include <Nazara/OpenGLRenderer/Config.hpp>
#include <list>
#include <memory>
#include <vector>
namespace Nz
{
class OpenGLDevice;
class NAZARA_OPENGLRENDERER_API OpenGL
{
public:
OpenGL() = delete;
~OpenGL() = delete;
static bool Initialize();
static bool IsInitialized();
static void Uninitialize();
};
}
#endif // NAZARA_OPENGL_HPP

View File

@@ -8,21 +8,27 @@
#define NAZARA_OPENGLRENDERER_OPENGLDEVICE_HPP
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Platform/WindowHandle.hpp>
#include <Nazara/OpenGLRenderer/Config.hpp>
#include <Nazara/OpenGLRenderer/Wrapper/Context.hpp>
#include <Nazara/Renderer/RenderDevice.hpp>
#include <Nazara/OpenGLRenderer/OpenGLBuffer.hpp>
#include <Nazara/OpenGLRenderer/Wrapper/Device.hpp>
#include <vector>
namespace Nz
{
class NAZARA_OPENGLRENDERER_API OpenGLDevice : public RenderDevice, public Vk::Device
class NAZARA_OPENGLRENDERER_API OpenGLDevice : public RenderDevice
{
public:
using Device::Device;
OpenGLDevice(GL::Loader& loader);
OpenGLDevice(const OpenGLDevice&) = delete;
OpenGLDevice(OpenGLDevice&&) = delete; ///TODO?
~OpenGLDevice();
std::unique_ptr<GL::Context> CreateContext(const GL::ContextParams& params) const;
std::unique_ptr<GL::Context> CreateContext(const GL::ContextParams& params, WindowHandle handle) const;
inline const GL::Context& GetReferenceContext() const;
std::unique_ptr<AbstractBuffer> InstantiateBuffer(BufferType type) override;
std::unique_ptr<CommandPool> InstantiateCommandPool(QueueType queueType) override;
std::unique_ptr<RenderPipeline> InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo) override;
@@ -33,6 +39,10 @@ namespace Nz
OpenGLDevice& operator=(const OpenGLDevice&) = delete;
OpenGLDevice& operator=(OpenGLDevice&&) = delete; ///TODO?
private:
std::unique_ptr<GL::Context> m_referenceContext;
GL::Loader& m_loader;
};
}

View File

@@ -7,6 +7,10 @@
namespace Nz
{
inline const GL::Context& OpenGLDevice::GetReferenceContext() const
{
return *m_referenceContext;
}
}
#include <Nazara/OpenGLRenderer/DebugOff.hpp>

View File

@@ -8,10 +8,12 @@
#define NAZARA_OPENGLRENDERER_HPP
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Core/DynLib.hpp>
#include <Nazara/Renderer/RendererImpl.hpp>
#include <Nazara/OpenGLRenderer/Config.hpp>
#include <list>
#include <vector>
#include <Nazara/OpenGLRenderer/OpenGLDevice.hpp>
#include <Nazara/OpenGLRenderer/Wrapper/Loader.hpp>
#include <memory>
namespace Nz
{
@@ -34,6 +36,11 @@ namespace Nz
std::vector<RenderDeviceInfo> QueryRenderDevices() const override;
bool Prepare(const ParameterList& parameters) override;
private:
DynLib m_opengl32Lib;
std::shared_ptr<OpenGLDevice> m_device;
std::unique_ptr<GL::Loader> m_loader;
};
}