GHOST/EGL: store pointer to GHOST_System for downcast tests

This commit is contained in:
Christian Rauch 2021-06-23 00:01:04 +01:00
parent b801db1181
commit 5f27a5fff7
6 changed files with 23 additions and 9 deletions

View File

@ -202,7 +202,8 @@ template<typename T> T &choose_api(EGLenum api, T &a, T &b, T &c)
}
}
GHOST_ContextEGL::GHOST_ContextEGL(bool stereoVisual,
GHOST_ContextEGL::GHOST_ContextEGL(const GHOST_System *const system,
bool stereoVisual,
EGLNativeWindowType nativeWindow,
EGLNativeDisplayType nativeDisplay,
EGLint contextProfileMask,
@ -212,6 +213,7 @@ GHOST_ContextEGL::GHOST_ContextEGL(bool stereoVisual,
EGLint contextResetNotificationStrategy,
EGLenum api)
: GHOST_Context(stereoVisual),
m_system(system),
m_nativeDisplay(nativeDisplay),
m_nativeWindow(nativeWindow),
m_contextProfileMask(contextProfileMask),

View File

@ -24,6 +24,7 @@
#pragma once
#include "GHOST_Context.h"
#include "GHOST_System.h"
#include <GL/eglew.h>
@ -43,7 +44,8 @@ class GHOST_ContextEGL : public GHOST_Context {
/**
* Constructor.
*/
GHOST_ContextEGL(bool stereoVisual,
GHOST_ContextEGL(const GHOST_System *const system,
bool stereoVisual,
EGLNativeWindowType nativeWindow,
EGLNativeDisplayType nativeDisplay,
EGLint contextProfileMask,
@ -112,6 +114,8 @@ class GHOST_ContextEGL : public GHOST_Context {
private:
bool initContextEGLEW();
const GHOST_System *const m_system;
EGLNativeDisplayType m_nativeDisplay;
EGLNativeWindowType m_nativeWindow;

View File

@ -1593,7 +1593,8 @@ GHOST_IContext *GHOST_SystemWayland::createOffscreenContext(GHOST_GLSettings /*g
GHOST_Context *context;
for (int minor = 6; minor >= 0; --minor) {
context = new GHOST_ContextEGL(false,
context = new GHOST_ContextEGL(this,
false,
EGLNativeWindowType(os_egl_window),
EGLNativeDisplayType(d->display),
EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
@ -1609,7 +1610,8 @@ GHOST_IContext *GHOST_SystemWayland::createOffscreenContext(GHOST_GLSettings /*g
delete context;
}
context = new GHOST_ContextEGL(false,
context = new GHOST_ContextEGL(this,
false,
EGLNativeWindowType(os_egl_window),
EGLNativeDisplayType(d->display),
EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,

View File

@ -441,7 +441,8 @@ GHOST_IContext *GHOST_SystemX11::createOffscreenContext(GHOST_GLSettings glSetti
for (int minor = 5; minor >= 0; --minor) {
#if defined(WITH_GL_EGL)
context = new GHOST_ContextEGL(false,
context = new GHOST_ContextEGL(this,
false,
EGLNativeWindowType(nullptr),
EGLNativeDisplayType(m_display),
profile_mask,
@ -471,7 +472,8 @@ GHOST_IContext *GHOST_SystemX11::createOffscreenContext(GHOST_GLSettings glSetti
}
#if defined(WITH_GL_EGL)
context = new GHOST_ContextEGL(false,
context = new GHOST_ContextEGL(this,
false,
EGLNativeWindowType(nullptr),
EGLNativeDisplayType(m_display),
profile_mask,

View File

@ -533,7 +533,8 @@ GHOST_Context *GHOST_WindowWayland::newDrawingContext(GHOST_TDrawingContextType
break;
case GHOST_kDrawingContextTypeOpenGL:
for (int minor = 6; minor >= 0; --minor) {
context = new GHOST_ContextEGL(m_wantStereoVisual,
context = new GHOST_ContextEGL(this->m_system,
m_wantStereoVisual,
EGLNativeWindowType(w->egl_window),
EGLNativeDisplayType(m_system->display()),
EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
@ -548,7 +549,8 @@ GHOST_Context *GHOST_WindowWayland::newDrawingContext(GHOST_TDrawingContextType
else
delete context;
}
context = new GHOST_ContextEGL(m_wantStereoVisual,
context = new GHOST_ContextEGL(this->m_system,
m_wantStereoVisual,
EGLNativeWindowType(w->egl_window),
EGLNativeDisplayType(m_system->display()),
EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,

View File

@ -1325,6 +1325,7 @@ GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type
for (int minor = 5; minor >= 0; --minor) {
#ifdef WITH_GL_EGL
context = new GHOST_ContextEGL(
this->m_system,
m_wantStereoVisual,
EGLNativeWindowType(m_window),
EGLNativeDisplayType(m_display),
@ -1355,7 +1356,8 @@ GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type
}
#ifdef WITH_GL_EGL
context = new GHOST_ContextEGL(m_wantStereoVisual,
context = new GHOST_ContextEGL(this->m_system,
m_wantStereoVisual,
EGLNativeWindowType(m_window),
EGLNativeDisplayType(m_display),
profile_mask,