OpenGLRenderer: Use a single context with WebGL
This commit is contained in:
committed by
Jérôme Leclercq
parent
ea5c5240fc
commit
5b3703347f
@@ -29,8 +29,8 @@ namespace Nz
|
||||
OpenGLDevice(OpenGLDevice&&) = delete; ///TODO?
|
||||
~OpenGLDevice();
|
||||
|
||||
std::unique_ptr<GL::Context> CreateContext(GL::ContextParams params) const;
|
||||
std::unique_ptr<GL::Context> CreateContext(GL::ContextParams params, WindowHandle handle) const;
|
||||
std::shared_ptr<GL::Context> CreateContext(GL::ContextParams params) const;
|
||||
std::shared_ptr<GL::Context> CreateContext(GL::ContextParams params, WindowHandle handle) const;
|
||||
|
||||
const RenderDeviceInfo& GetDeviceInfo() const override;
|
||||
const RenderDeviceFeatures& GetEnabledFeatures() const override;
|
||||
@@ -62,7 +62,7 @@ namespace Nz
|
||||
private:
|
||||
inline void NotifyContextDestruction(const GL::Context& context) const;
|
||||
|
||||
std::unique_ptr<GL::Context> m_referenceContext;
|
||||
std::shared_ptr<GL::Context> m_referenceContext;
|
||||
mutable std::unordered_set<const GL::Context*> m_contexts;
|
||||
RenderDeviceInfo m_deviceInfo;
|
||||
GL::Loader& m_loader;
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Nz
|
||||
std::optional<OpenGLRenderPass> m_renderPass;
|
||||
std::size_t m_currentFrame;
|
||||
std::vector<std::unique_ptr<OpenGLRenderImage>> m_renderImage;
|
||||
std::unique_ptr<GL::Context> m_context;
|
||||
std::shared_ptr<GL::Context> m_context;
|
||||
OpenGLWindowFramebuffer m_framebuffer;
|
||||
Vector2ui m_size;
|
||||
bool m_sizeInvalidated;
|
||||
|
||||
@@ -25,8 +25,8 @@ namespace Nz::GL
|
||||
EGLLoader(const Renderer::Config& config);
|
||||
~EGLLoader();
|
||||
|
||||
std::unique_ptr<Context> CreateContext(const OpenGLDevice* device, const ContextParams& params, Context* shareContext) const override;
|
||||
std::unique_ptr<Context> CreateContext(const OpenGLDevice* device, const ContextParams& params, WindowHandle handle, Context* shareContext) const override;
|
||||
std::shared_ptr<Context> CreateContext(const OpenGLDevice* device, const ContextParams& params, Context* shareContext) const override;
|
||||
std::shared_ptr<Context> CreateContext(const OpenGLDevice* device, const ContextParams& params, WindowHandle handle, Context* shareContext) const override;
|
||||
|
||||
inline EGLDisplay GetDefaultDisplay() const;
|
||||
ContextType GetPreferredContextType() const override;
|
||||
|
||||
@@ -31,8 +31,8 @@ namespace Nz::GL
|
||||
Loader() = default;
|
||||
virtual ~Loader();
|
||||
|
||||
virtual std::unique_ptr<Context> CreateContext(const OpenGLDevice* device, const ContextParams& params, Context* shareContext = nullptr) const = 0;
|
||||
virtual std::unique_ptr<Context> CreateContext(const OpenGLDevice* device, const ContextParams& params, WindowHandle handle, Context* shareContext = nullptr) const = 0;
|
||||
virtual std::shared_ptr<Context> CreateContext(const OpenGLDevice* device, const ContextParams& params, Context* shareContext = nullptr) const = 0;
|
||||
virtual std::shared_ptr<Context> CreateContext(const OpenGLDevice* device, const ContextParams& params, WindowHandle handle, Context* shareContext = nullptr) const = 0;
|
||||
|
||||
virtual ContextType GetPreferredContextType() const = 0;
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace Nz::GL
|
||||
|
||||
inline void Shader::DestroyHelper(OpenGLDevice& /*device*/, const Context& context, GLuint objectId)
|
||||
{
|
||||
// context.glDeleteShader(objectId);
|
||||
context.glDeleteShader(objectId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@ namespace Nz::GL
|
||||
WGLLoader(const Renderer::Config& config);
|
||||
~WGLLoader() = default;
|
||||
|
||||
std::unique_ptr<Context> CreateContext(const OpenGLDevice* device, const ContextParams& params, Context* shareContext) const override;
|
||||
std::unique_ptr<Context> CreateContext(const OpenGLDevice* device, const ContextParams& params, WindowHandle handle, Context* shareContext) const override;
|
||||
std::shared_ptr<Context> CreateContext(const OpenGLDevice* device, const ContextParams& params, Context* shareContext) const override;
|
||||
std::shared_ptr<Context> CreateContext(const OpenGLDevice* device, const ContextParams& params, WindowHandle handle, Context* shareContext) const override;
|
||||
|
||||
ContextType GetPreferredContextType() const override;
|
||||
|
||||
|
||||
@@ -65,9 +65,7 @@ namespace Nz::GL
|
||||
Fallback fallbacks; //< m_ omitted
|
||||
|
||||
std::unordered_set<std::string> m_supportedPlatformExtensions;
|
||||
static EMSCRIPTEN_WEBGL_CONTEXT_HANDLE s_handle;
|
||||
static size_t s_handleCounter;
|
||||
bool m_ownsDisplay;
|
||||
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE m_handle;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -10,8 +10,7 @@ namespace Nz::GL
|
||||
inline WebContext::WebContext(const OpenGLDevice* device, const WebLoader& loader) :
|
||||
Context(device),
|
||||
m_loader(loader),
|
||||
//m_handle(0),
|
||||
m_ownsDisplay(false)
|
||||
m_handle(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ namespace Nz::GL
|
||||
friend SymbolLoader;
|
||||
|
||||
public:
|
||||
std::unique_ptr<Context> CreateContext(const OpenGLDevice* device, const ContextParams& params, Context* shareContext) const override;
|
||||
std::unique_ptr<Context> CreateContext(const OpenGLDevice* device, const ContextParams& params, WindowHandle handle, Context* shareContext) const override;
|
||||
std::shared_ptr<Context> CreateContext(const OpenGLDevice* device, const ContextParams& params, Context* shareContext) const override;
|
||||
std::shared_ptr<Context> CreateContext(const OpenGLDevice* device, const ContextParams& params, WindowHandle handle, Context* shareContext) const override;
|
||||
|
||||
ContextType GetPreferredContextType() const override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user