OpenGL: Rework contexts
This commit is contained in:
@@ -4,28 +4,65 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_OPENGLRENDERER_CONTEXT_HPP
|
||||
#define NAZARA_OPENGLRENDERER_CONTEXT_HPP
|
||||
#ifndef NAZARA_OPENGLRENDERER_CONTEXTIMPL_HPP
|
||||
#define NAZARA_OPENGLRENDERER_CONTEXTIMPL_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/GLContext.hpp>
|
||||
#include <memory>
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/CoreFunctions.hpp>
|
||||
#include <string>
|
||||
#include <unordered_set>
|
||||
|
||||
namespace Nz::GL
|
||||
{
|
||||
enum class ContextType
|
||||
{
|
||||
OpenGL,
|
||||
OpenGL_ES
|
||||
};
|
||||
|
||||
struct ContextParams
|
||||
{
|
||||
ContextType type = ContextType::OpenGL_ES;
|
||||
bool doubleBuffering = true;
|
||||
unsigned int bitsPerPixel = 32;
|
||||
unsigned int depthBits = 24;
|
||||
unsigned int glMajorVersion = 0;
|
||||
unsigned int glMinorVersion = 0;
|
||||
unsigned int sampleCount = 1;
|
||||
unsigned int stencilBits = 8;
|
||||
};
|
||||
|
||||
class Loader;
|
||||
|
||||
class Context
|
||||
{
|
||||
public:
|
||||
Context() = default;
|
||||
Context(const Context&) = delete;
|
||||
Context(Context&& object) noexcept = default;
|
||||
~Context() = default;
|
||||
virtual ~Context();
|
||||
|
||||
Context& operator=(const Context&) = delete;
|
||||
Context& operator=(Context&& object) noexcept = default;
|
||||
virtual bool Activate() = 0;
|
||||
|
||||
private:
|
||||
std::unique_ptr<GLContext> m_impl;
|
||||
virtual void EnableVerticalSync(bool enabled) = 0;
|
||||
|
||||
inline const ContextParams& GetParams() const;
|
||||
|
||||
inline bool IsExtensionSupported(const std::string& extension) const;
|
||||
|
||||
bool Initialize(const ContextParams& params);
|
||||
|
||||
virtual void SwapBuffers() = 0;
|
||||
|
||||
#define NAZARA_OPENGLRENDERER_FUNC(name, sig) sig name = nullptr;
|
||||
NAZARA_OPENGLRENDERER_FOREACH_GLES_FUNC(NAZARA_OPENGLRENDERER_FUNC)
|
||||
#undef NAZARA_OPENGLRENDERER_FUNC
|
||||
|
||||
protected:
|
||||
virtual const Loader& GetLoader() = 0;
|
||||
|
||||
virtual bool ImplementFallback(const std::string_view& function) = 0;
|
||||
|
||||
std::unordered_set<std::string> m_supportedExtensions;
|
||||
ContextParams m_params;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user