Changeset View
Changeset View
Standalone View
Standalone View
intern/ghost/intern/GHOST_ContextEGL.cpp
| Show First 20 Lines • Show All 143 Lines • ▼ Show 20 Lines | fprintf(stderr, | ||||
| code ? code : "<Unknown>", | code ? code : "<Unknown>", | ||||
| msg ? msg : "<Unknown>"); | msg ? msg : "<Unknown>"); | ||||
| #else | #else | ||||
| fprintf(stderr, | fprintf(stderr, | ||||
| "EGL Error (0x%04X): %s: %s\n", | "EGL Error (0x%04X): %s: %s\n", | ||||
| static_cast<unsigned int>(error), | static_cast<unsigned int>(error), | ||||
| code ? code : "<Unknown>", | code ? code : "<Unknown>", | ||||
| msg ? msg : "<Unknown>"); | msg ? msg : "<Unknown>"); | ||||
| (void)(file); | |||||
| (void)(line); | |||||
| (void)(text); | |||||
| #endif | #endif | ||||
| } | } | ||||
| return result; | return result; | ||||
| } | } | ||||
| #ifndef NDEBUG | #ifndef NDEBUG | ||||
| # define EGL_CHK(x) egl_chk((x), __FILE__, __LINE__, # x) | # define EGL_CHK(x) egl_chk((x), __FILE__, __LINE__, # x) | ||||
| ▲ Show 20 Lines • Show All 120 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| // This is a bit of a kludge because there does not seem to | // This is a bit of a kludge because there does not seem to | ||||
| // be a way to query the swap interval with EGL. | // be a way to query the swap interval with EGL. | ||||
| intervalOut = m_swap_interval; | intervalOut = m_swap_interval; | ||||
| return GHOST_kSuccess; | 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() | GHOST_TSuccess GHOST_ContextEGL::activateDrawingContext() | ||||
| { | { | ||||
| if (m_display) { | if (m_display) { | ||||
| bindAPI(m_api); | bindAPI(m_api); | ||||
| return EGL_CHK(::eglMakeCurrent(m_display, m_surface, m_surface, m_context)) ? GHOST_kSuccess : | return EGL_CHK(::eglMakeCurrent(m_display, m_surface, m_surface, m_context)) ? GHOST_kSuccess : | ||||
| GHOST_kFailure; | GHOST_kFailure; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 155 Lines • ▼ Show 20 Lines | #endif | ||||
| if (m_nativeWindow == 0) { | if (m_nativeWindow == 0) { | ||||
| // off-screen surface | // off-screen surface | ||||
| attrib_list.push_back(EGL_SURFACE_TYPE); | attrib_list.push_back(EGL_SURFACE_TYPE); | ||||
| attrib_list.push_back(EGL_PBUFFER_BIT); | attrib_list.push_back(EGL_PBUFFER_BIT); | ||||
| } | } | ||||
| attrib_list.push_back(EGL_NONE); | attrib_list.push_back(EGL_NONE); | ||||
| EGLConfig config; | if (!EGL_CHK(::eglChooseConfig(m_display, &(attrib_list[0]), &m_config, 1, &num_config))) | ||||
| if (!EGL_CHK(::eglChooseConfig(m_display, &(attrib_list[0]), &config, 1, &num_config))) | |||||
| goto error; | goto error; | ||||
| // A common error is to assume that ChooseConfig worked because it returned EGL_TRUE | // A common error is to assume that ChooseConfig worked because it returned EGL_TRUE | ||||
| if (num_config != 1) // num_config should be exactly 1 | if (num_config != 1) // num_config should be exactly 1 | ||||
| goto error; | goto error; | ||||
| if (m_nativeWindow != 0) { | if (m_nativeWindow != 0) { | ||||
| m_surface = ::eglCreateWindowSurface(m_display, config, m_nativeWindow, NULL); | m_surface = ::eglCreateWindowSurface(m_display, m_config, m_nativeWindow, NULL); | ||||
| } | } | ||||
| else { | else { | ||||
| static const EGLint pb_attrib_list[] = { | static const EGLint pb_attrib_list[] = { | ||||
| EGL_WIDTH, | EGL_WIDTH, | ||||
| 1, | 1, | ||||
| EGL_HEIGHT, | EGL_HEIGHT, | ||||
| 1, | 1, | ||||
| EGL_NONE, | 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)) | if (!EGL_CHK(m_surface != EGL_NO_SURFACE)) | ||||
| goto error; | goto error; | ||||
| attrib_list.clear(); | attrib_list.clear(); | ||||
| if (EGLEW_VERSION_1_5 || EGLEW_KHR_create_context) { | if (EGLEW_VERSION_1_5 || EGLEW_KHR_create_context) { | ||||
| ▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | if (m_contextResetNotificationStrategy != 0) { | ||||
| "Warning! EGL %d.%d is unable to set the reset notification strategies.", | "Warning! EGL %d.%d is unable to set the reset notification strategies.", | ||||
| egl_major, | egl_major, | ||||
| egl_minor); | egl_minor); | ||||
| } | } | ||||
| } | } | ||||
| attrib_list.push_back(EGL_NONE); | 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)) | if (!EGL_CHK(m_context != EGL_NO_CONTEXT)) | ||||
| goto error; | goto error; | ||||
| if (m_sharedContext == EGL_NO_CONTEXT) | if (m_sharedContext == EGL_NO_CONTEXT) | ||||
| m_sharedContext = m_context; | m_sharedContext = m_context; | ||||
| m_sharedCount++; | m_sharedCount++; | ||||
| Show All 25 Lines | |||||