From b35ba22d8439df35056957b9f1519e9150cc900b Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Wed, 16 Jun 2021 22:13:36 +0100 Subject: GHOST/EGL: getters for display, config and context --- intern/ghost/intern/GHOST_ContextEGL.cpp | 25 +++++++++++++++++++------ intern/ghost/intern/GHOST_ContextEGL.h | 7 +++++++ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/intern/ghost/intern/GHOST_ContextEGL.cpp b/intern/ghost/intern/GHOST_ContextEGL.cpp index 6ec79aad045..770ead5962e 100644 --- a/intern/ghost/intern/GHOST_ContextEGL.cpp +++ b/intern/ghost/intern/GHOST_ContextEGL.cpp @@ -288,6 +288,21 @@ GHOST_TSuccess GHOST_ContextEGL::getSwapInterval(int &intervalOut) return GHOST_kSuccess; } +EGLDisplay GHOST_ContextEGL::getDisplay() const +{ + return m_display; +} + +EGLConfig GHOST_ContextEGL::getConfig() const +{ + return m_config; +} + +EGLContext GHOST_ContextEGL::getContext() const +{ + return m_context; +} + GHOST_TSuccess GHOST_ContextEGL::activateDrawingContext() { if (m_display) { @@ -459,9 +474,7 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext() attrib_list.push_back(EGL_NONE); - EGLConfig config; - - if (!EGL_CHK(::eglChooseConfig(m_display, &(attrib_list[0]), &config, 1, &num_config))) + if (!EGL_CHK(::eglChooseConfig(m_display, &(attrib_list[0]), &m_config, 1, &num_config))) goto error; // A common error is to assume that ChooseConfig worked because it returned EGL_TRUE @@ -469,7 +482,7 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext() goto error; if (m_nativeWindow != 0) { - m_surface = ::eglCreateWindowSurface(m_display, config, m_nativeWindow, NULL); + m_surface = ::eglCreateWindowSurface(m_display, m_config, m_nativeWindow, NULL); } else { static const EGLint pb_attrib_list[] = { @@ -479,7 +492,7 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext() 1, EGL_NONE, }; - m_surface = ::eglCreatePbufferSurface(m_display, config, pb_attrib_list); + m_surface = ::eglCreatePbufferSurface(m_display, m_config, pb_attrib_list); } if (!EGL_CHK(m_surface != EGL_NO_SURFACE)) @@ -580,7 +593,7 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext() attrib_list.push_back(EGL_NONE); - m_context = ::eglCreateContext(m_display, config, m_sharedContext, &(attrib_list[0])); + m_context = ::eglCreateContext(m_display, m_config, m_sharedContext, &(attrib_list[0])); if (!EGL_CHK(m_context != EGL_NO_CONTEXT)) goto error; diff --git a/intern/ghost/intern/GHOST_ContextEGL.h b/intern/ghost/intern/GHOST_ContextEGL.h index f828271d88d..88d78b159b9 100644 --- a/intern/ghost/intern/GHOST_ContextEGL.h +++ b/intern/ghost/intern/GHOST_ContextEGL.h @@ -100,6 +100,12 @@ class GHOST_ContextEGL : public GHOST_Context { */ GHOST_TSuccess getSwapInterval(int &intervalOut); + EGLDisplay getDisplay() const; + + EGLConfig getConfig() const; + + EGLContext getContext() const; + private: bool initContextEGLEW(); @@ -117,6 +123,7 @@ class GHOST_ContextEGL : public GHOST_Context { EGLContext m_context; EGLSurface m_surface; EGLDisplay m_display; + EGLConfig m_config; EGLint m_swap_interval; -- cgit v1.2.3