1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-07 03:13:49 +00:00

Fix EGL initialization in applications that don't implment VidExt

This commit is contained in:
fzurita 2019-09-30 08:39:13 -04:00
parent 7861d14060
commit d6ad676436
2 changed files with 26 additions and 4 deletions

View File

@ -50,7 +50,7 @@ DisplayWindow & DisplayWindow::get()
void DisplayWindowMupen64plus::_setAttributes() void DisplayWindowMupen64plus::_setAttributes()
{ {
LOG(LOG_VERBOSE, "[gles2GlideN64]: _setAttributes"); LOG(LOG_VERBOSE, "_setAttributes");
FunctionWrapper::CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_PROFILE_MASK, M64P_GL_CONTEXT_PROFILE_CORE); FunctionWrapper::CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_PROFILE_MASK, M64P_GL_CONTEXT_PROFILE_CORE);
FunctionWrapper::CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_MAJOR_VERSION, 3); FunctionWrapper::CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_MAJOR_VERSION, 3);
@ -77,6 +77,21 @@ bool DisplayWindowMupen64plus::_start()
{ {
FunctionWrapper::setThreadedMode(config.video.threadedVideo); FunctionWrapper::setThreadedMode(config.video.threadedVideo);
#ifdef EGL
// Normally this is initialized externally through VidExt, but if VidExt is not implemented,
// do this here anyways. Calling eglInitialize has no negative effect according to the spec
EGLDisplay display;
if ((display = eglGetDisplay(EGL_DEFAULT_DISPLAY)) == EGL_NO_DISPLAY) {
LOG(LOG_ERROR, "eglGetDisplay() returned error %d", eglGetError());
return false;
}
if (!eglInitialize(display, nullptr, nullptr)) {
LOG(LOG_ERROR, "eglInitialize() returned error %d", eglGetError());
return false;
}
#endif
FunctionWrapper::CoreVideo_Init(); FunctionWrapper::CoreVideo_Init();
_setAttributes(); _setAttributes();
@ -90,11 +105,11 @@ bool DisplayWindowMupen64plus::_start()
const m64p_video_flags flags = M64VIDEOFLAG_SUPPORT_RESIZING; const m64p_video_flags flags = M64VIDEOFLAG_SUPPORT_RESIZING;
if (FunctionWrapper::CoreVideo_SetVideoMode(m_screenWidth, m_screenHeight, 0, m_bFullscreen ? M64VIDEO_FULLSCREEN : M64VIDEO_WINDOWED, flags) != M64ERR_SUCCESS) { if (FunctionWrapper::CoreVideo_SetVideoMode(m_screenWidth, m_screenHeight, 0, m_bFullscreen ? M64VIDEO_FULLSCREEN : M64VIDEO_WINDOWED, flags) != M64ERR_SUCCESS) {
//printf("(EE) Error setting videomode %dx%d\n", m_screenWidth, m_screenHeight); //printf("(EE) Error setting videomode %dx%d\n", m_screenWidth, m_screenHeight);
LOG(LOG_ERROR, "[gles2GlideN64]: Error setting videomode %dx%d", m_screenWidth, m_screenHeight); LOG(LOG_ERROR, "Error setting videomode %dx%d", m_screenWidth, m_screenHeight);
FunctionWrapper::CoreVideo_Quit(); FunctionWrapper::CoreVideo_Quit();
return false; return false;
} }
LOG(LOG_VERBOSE, "[gles2GlideN64]: Create setting videomode %dx%d", m_screenWidth, m_screenHeight); LOG(LOG_VERBOSE, "Create setting videomode %dx%d", m_screenWidth, m_screenHeight);
char caption[128]; char caption[128];
# ifdef _DEBUG # ifdef _DEBUG

View File

@ -27,6 +27,10 @@ bool Utils::isExtensionSupported(const opengl::GLInfo & _glinfo, const char *ext
return false; return false;
const GLubyte *extensions = glGetString(GL_EXTENSIONS); const GLubyte *extensions = glGetString(GL_EXTENSIONS);
if (extensions == nullptr) {
LOG(LOG_WARNING, "Could not query GL extensions on this device");
return false;
}
const GLubyte *start = extensions; const GLubyte *start = extensions;
for (;;) { for (;;) {
@ -52,6 +56,10 @@ bool Utils::isEGLExtensionSupported(const char * extension)
return false; return false;
const char* extensions = eglQueryString(eglGetDisplay(EGL_DEFAULT_DISPLAY), EGL_EXTENSIONS); const char* extensions = eglQueryString(eglGetDisplay(EGL_DEFAULT_DISPLAY), EGL_EXTENSIONS);
if (extensions == nullptr) {
LOG(LOG_WARNING, "Could not query EGL extensions on this device");
return false;
}
const char* start = extensions; const char* start = extensions;
for (;;) { for (;;) {
@ -72,7 +80,6 @@ bool Utils::isEGLExtensionSupported(const char * extension)
#endif #endif
} }
static static
const char* GLErrorString(GLenum errorCode) const char* GLErrorString(GLenum errorCode)
{ {