Page 1 of 1

Reinitialize console after closing OpenGL

Posted: Fri Jul 05, 2024 1:01 pm
by Tenry
Hi! I am writing a game using OpenGL + EGL. I follow the structure of "examples/switch/graphics/opengl/simple_triangle" for initializing and quitting OpenGL and EGL.

What do I need to do to bring back the console on the screen (and quitting OpenGL)?

My use case: If some error (exception) occurs, I want to shut down OpenGL and EGL and initialize the console again (consoleInit) and show the error message on the screen. I'm testing using the Suyu emulator on Linux.

I tried various variations of deinitializing EGL and initializing the console, and this is my code so far:

Code: Select all

// "error" occurred
// doing consoleInit(NULL) has no effect here
eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
// doing consoleInit(NULL) has no effect here
eglDestroyContext(eglDisplay, eglContext);
// doing consoleInit(NULL) has no effect here

// the following line causes the Suyu emulator to crash in Vulkan mode with "VK_ERROR_INITIALIZATION_FAILED" error
// using OpenGL, it shows "QOpenGLContext::swapBuffers() called with non-exposed window, behavior is undefined" warning, but keeps running
eglDestroySurface(eglDisplay, eglSurface);
// doing consoleInit(NULL) has some kind of effect, but it appears so switch between normal white and small green text every frame

// this does not seem to work as expected
// eglTerminate(eglDisplay);

consoleInit(NULL);
printf("the error message\n");
while (appletMainLoop()) {
  consoleUpdate(NULL);
}
Please note that I do consoleInit(NULL) initially for any startup messages and consoleExit(NULL) right before initializing EGL. But also without initializing and quitting console before EGL, this does not seem to make any difference.