OpenGLRenderer: Use generic DeviceObject

This commit is contained in:
Lynix
2020-04-26 16:26:08 +02:00
parent b4b15f826d
commit 1c23949608
6 changed files with 137 additions and 215 deletions

View File

@@ -9,41 +9,43 @@
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Core/MovablePtr.hpp>
#include <Nazara/OpenGLRenderer/Wrapper/Context.hpp>
#include <string>
namespace Nz::GL
{
template<typename C>
template<typename C, GLenum ObjectType, typename... CreateArgs>
class DeviceObject
{
public:
DeviceObject();
DeviceObject() = default;
DeviceObject(const DeviceObject&) = delete;
DeviceObject(DeviceObject&& object) noexcept;
DeviceObject(DeviceObject&& object) noexcept = default;
~DeviceObject();
bool Create(OpenGLDevice& device);
bool Create(OpenGLDevice& device, CreateArgs... args);
void Destroy();
bool IsValid() const;
Device* GetDevice() const;
VkResult GetLastErrorCode() const;
OpenGLDevice* GetDevice() const;
GLuint GetObjectId() const;
void SetDebugName(const char* name);
void SetDebugName(const std::string& name);
void SetDebugName(const std::string_view& name);
DeviceObject& operator=(const DeviceObject&) = delete;
DeviceObject& operator=(DeviceObject&& object) noexcept;
DeviceObject& operator=(DeviceObject&& object) noexcept = default;
operator VkType() const;
static constexpr GLuint InvalidObject = 0;
protected:
const Context& EnsureDeviceContext();
MovablePtr<OpenGLDevice> m_device;
GLuint m_handle;
MovableValue<GLuint> m_objectId;
};
}
#include <Nazara/OpenGLRenderer/Wrapper/DeviceObject.inl>
#endif // NAZARA_OPENGLRENDERER_VKDEVICEOBJECT_HPP
#endif