Changeset View
Changeset View
Standalone View
Standalone View
intern/ghost/intern/GHOST_ContextGLX.cpp
| Show First 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | |||||
| GHOST_TSuccess GHOST_ContextGLX::releaseDrawingContext() | GHOST_TSuccess GHOST_ContextGLX::releaseDrawingContext() | ||||
| { | { | ||||
| if (m_display == nullptr) { | if (m_display == nullptr) { | ||||
| return GHOST_kFailure; | return GHOST_kFailure; | ||||
| } | } | ||||
| return ::glXMakeCurrent(m_display, None, nullptr) ? GHOST_kSuccess : GHOST_kFailure; | return ::glXMakeCurrent(m_display, None, nullptr) ? GHOST_kSuccess : GHOST_kFailure; | ||||
| } | } | ||||
| void GHOST_ContextGLX::initContextGLXEW() | |||||
| { | |||||
| initContextGLEW(); | |||||
| } | |||||
| GHOST_TSuccess GHOST_ContextGLX::initializeDrawingContext() | GHOST_TSuccess GHOST_ContextGLX::initializeDrawingContext() | ||||
| { | { | ||||
| GHOST_X11_ERROR_HANDLERS_OVERRIDE(handler_store); | GHOST_X11_ERROR_HANDLERS_OVERRIDE(handler_store); | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /* Begin Inline GLEW. */ | /* Begin Inline GLEW. */ | ||||
| #ifdef USE_GLXEW_INIT_WORKAROUND | #ifdef USE_GLXEW_INIT_WORKAROUND | ||||
| ▲ Show 20 Lines • Show All 162 Lines • ▼ Show 20 Lines | if (m_context != nullptr) { | ||||
| if (!s_sharedContext) { | if (!s_sharedContext) { | ||||
| s_sharedContext = m_context; | s_sharedContext = m_context; | ||||
| } | } | ||||
| s_sharedCount++; | s_sharedCount++; | ||||
| glXMakeCurrent(m_display, m_window, m_context); | glXMakeCurrent(m_display, m_window, m_context); | ||||
| /* Seems that this has to be called after #glXMakeCurrent, | |||||
| * which means we cannot use `glX` extensions until after we create a context. */ | |||||
| initContextGLXEW(); | |||||
| if (m_window) { | if (m_window) { | ||||
| initClearGL(); | initClearGL(); | ||||
| ::glXSwapBuffers(m_display, m_window); | ::glXSwapBuffers(m_display, m_window); | ||||
| } | } | ||||
| /* re initialize to get the extensions properly */ | |||||
| initContextGLXEW(); | |||||
| version = glGetString(GL_VERSION); | version = glGetString(GL_VERSION); | ||||
| if (!version || version[0] < '3' || ((version[0] == '3') && (version[2] < '3'))) { | if (!version || version[0] < '3' || ((version[0] == '3') && (version[2] < '3'))) { | ||||
| success = GHOST_kFailure; | success = GHOST_kFailure; | ||||
| } | } | ||||
| else { | else { | ||||
| success = GHOST_kSuccess; | success = GHOST_kSuccess; | ||||
| } | } | ||||
| Show All 12 Lines | |||||
| { | { | ||||
| m_window = 0; | m_window = 0; | ||||
| return GHOST_kSuccess; | return GHOST_kSuccess; | ||||
| } | } | ||||
| GHOST_TSuccess GHOST_ContextGLX::setSwapInterval(int interval) | GHOST_TSuccess GHOST_ContextGLX::setSwapInterval(int interval) | ||||
| { | { | ||||
| if (!GLXEW_EXT_swap_control) { | if (!epoxy_has_glx_extension(m_display, DefaultScreen(m_display), "GLX_EXT_swap_control")) { | ||||
| ::glXSwapIntervalEXT(m_display, m_window, interval); | ::glXSwapIntervalEXT(m_display, m_window, interval); | ||||
| return GHOST_kSuccess; | return GHOST_kSuccess; | ||||
| } | } | ||||
| return GHOST_kFailure; | return GHOST_kFailure; | ||||
| } | } | ||||
| GHOST_TSuccess GHOST_ContextGLX::getSwapInterval(int &intervalOut) | GHOST_TSuccess GHOST_ContextGLX::getSwapInterval(int &intervalOut) | ||||
| { | { | ||||
| if (GLXEW_EXT_swap_control) { | if (epoxy_has_glx_extension(m_display, DefaultScreen(m_display), "GLX_EXT_swap_control")) { | ||||
| unsigned int interval = 0; | unsigned int interval = 0; | ||||
| ::glXQueryDrawable(m_display, m_window, GLX_SWAP_INTERVAL_EXT, &interval); | ::glXQueryDrawable(m_display, m_window, GLX_SWAP_INTERVAL_EXT, &interval); | ||||
| intervalOut = static_cast<int>(interval); | intervalOut = static_cast<int>(interval); | ||||
| return GHOST_kSuccess; | return GHOST_kSuccess; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 112 Lines • Show Last 20 Lines | |||||