opengl: introduce makeCurrent and doneCurrent in OpenGlContext

... instead of them being specific to EglContext and GlxContext
This commit is contained in:
Xaver Hugl 2024-02-29 15:24:57 +01:00
parent 8c8c5b9b0e
commit 5101579eb8
4 changed files with 13 additions and 4 deletions

View file

@ -25,8 +25,8 @@ public:
GlxContext(::Display *display, GLXWindow window, GLXContext handle);
~GlxContext() override;
bool makeCurrent();
void doneCurrent() const;
bool makeCurrent() override;
void doneCurrent() const override;
void glXSwapIntervalMESA(unsigned int interval);

View file

@ -82,6 +82,11 @@ EglContext::~EglContext()
eglDestroyContext(m_display->handle(), m_handle);
}
bool EglContext::makeCurrent()
{
return makeCurrent(EGL_NO_SURFACE);
}
bool EglContext::makeCurrent(EGLSurface surface)
{
if (QOpenGLContext *context = QOpenGLContext::currentContext()) {

View file

@ -28,8 +28,9 @@ public:
EglContext(EglDisplay *display, EGLConfig config, ::EGLContext context);
~EglContext() override;
bool makeCurrent(EGLSurface surface = EGL_NO_SURFACE);
void doneCurrent() const;
bool makeCurrent() override;
bool makeCurrent(EGLSurface surface);
void doneCurrent() const override;
std::shared_ptr<GLTexture> importDmaBufAsTexture(const DmaBufAttributes &attributes) const;
EglDisplay *displayObject() const;

View file

@ -39,6 +39,9 @@ public:
explicit OpenGlContext(bool EGL);
virtual ~OpenGlContext();
virtual bool makeCurrent() = 0;
virtual void doneCurrent() const = 0;
bool hasVersion(const Version &version) const;
QByteArrayView openglVersionString() const;