Skip to content

Commit

Permalink
print hint when missing call to 'RemoveCurrent' on context switch
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-rauch committed Sep 27, 2018
1 parent 01f0b6e commit 0e29437
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/display/device/display_x11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ static const std::unordered_map<EGLint, std::string> egl_error_msg = {
namespace pangolin {
inline void _CheckEGLDieOnError( const char *sFile, const int nLine )
{
EGLint eglError = eglGetError();
const EGLint eglError = eglGetError();
if( eglError != EGL_SUCCESS ) {
pango_print_error("EGL Error: %s (%x)\n", egl_error_msg.at(eglError), eglError);
pango_print_error("EGL Error: %s (%x)\n", egl_error_msg.at(eglError).c_str(), eglError);
pango_print_error("In: %s, line %d\n", sFile, nLine);
exit(EXIT_FAILURE);
}
Expand Down Expand Up @@ -327,7 +327,17 @@ X11Window::~X11Window()

void X11Window::MakeCurrent(EGLContext ctx)
{
eglMakeCurrent( glcontext->egl_display, glcontext->egl_surface, glcontext->egl_surface, ctx );
if(eglMakeCurrent( glcontext->egl_display, glcontext->egl_surface, glcontext->egl_surface, ctx )==EGL_FALSE) {
const EGLint eglError = eglGetError();
if(eglError==EGL_BAD_ACCESS) {
std::cerr << "Received 'EGL_BAD_ACCESS' trying to set current EGL context." << std::endl;
std::cerr << "When calling 'MakeCurrent()' from a different thread, you need to unset the previous context first by calling 'RemoveCurrent()'." << std::endl;
}
else {
pango_print_error("X11Window::MakeCurrent(): EGL Error %s (%x)\n", egl_error_msg.at(eglError).c_str(), eglError);
}
exit(EXIT_FAILURE);
}
context = this;
}

Expand Down

0 comments on commit 0e29437

Please sign in to comment.