Hello everyone! I'm trying to port one of my game engines that I've working on to the Switch platform and I'm using devkitPRO as my toolchain.
I've had issues with getting their CMake toolchain to work properly with my engine (I couldn't locate any documentation related to how to use it with CMake as most of the example projects use Makefiles; this is a different issue and not the main topic)
I've been looking around the devkitPRO forum for similar issues, but I couldn't find anything, and also my thread got rejected for some reason, and that's why I decided to try my shots on other forums as well.
The main issue is that I'm trying to use EGL in order to fetch a proper context for the Switch window, but for some reason, whenever I call eglCreateWindowSurface inside my code, the app crashes, requiring a restart.
If I run it inside an emulator (yuzu), it crashes the emulator entirely; if I run it on proper, jailbroken hardware (it is the only way for me to develop and test homebrew games) I get a crash screen, which doesn't really provide useful information. I think the backtrace got corrupted or something.
This is how my crashes look like:
The snippet of code I'm using is the following:
I'm not really familiar with Console Development (it's my first time doing homebrew), so if possible, can I get some advice on how I can approach this issue and debug it properly?
I did some limited debugging using gdb in the emulator (yuzu), and I'm starting to suspect it may be something inside the mesa implementation for Switch or something with libnx.
The strange thing is that if I'm making a separate project in which I do the calls inside the application, the instance seems to get created properly, so I'm not sure if it's an issue because I'm linking the main game application with my engine library.
If you need any more information on how I'm trying to achieve things in my engine in order to understand together what I'm doing wrong, let me know.
Also, I don't know if this is the right zone to post this, so please let me know if I used the wrong forum for my issue.
Cheers!
I've had issues with getting their CMake toolchain to work properly with my engine (I couldn't locate any documentation related to how to use it with CMake as most of the example projects use Makefiles; this is a different issue and not the main topic)
I've been looking around the devkitPRO forum for similar issues, but I couldn't find anything, and also my thread got rejected for some reason, and that's why I decided to try my shots on other forums as well.
The main issue is that I'm trying to use EGL in order to fetch a proper context for the Switch window, but for some reason, whenever I call eglCreateWindowSurface inside my code, the app crashes, requiring a restart.
If I run it inside an emulator (yuzu), it crashes the emulator entirely; if I run it on proper, jailbroken hardware (it is the only way for me to develop and test homebrew games) I get a crash screen, which doesn't really provide useful information. I think the backtrace got corrupted or something.
This is how my crashes look like:
The snippet of code I'm using is the following:
Code:
bool EGLGraphicsContext::init(windows::BaseAppWindowSPtr window) {
const EGLint attribsCtx[] = {
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE
};
const EGLint attribs[] = {
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
EGL_BLUE_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_RED_SIZE, 8,
EGL_ALPHA_SIZE, 8,
EGL_DEPTH_SIZE, 24,
EGL_STENCIL_SIZE, 8,
EGL_NONE
};
EGLConfig config;
EGLint numConfigs;
EGLint format;
if ((display = eglGetDisplay(EGL_DEFAULT_DISPLAY)) == EGL_NO_DISPLAY) {
DEBUG_MSG("eglGetDisplay failed! %s\n", egl_get_error_string(eglGetError()).data())
return false;
}
if (!eglInitialize(display, nullptr, nullptr)) {
DEBUG_MSG("eglInitialize failed! %s\n", egl_get_error_string(eglGetError()).data())
return false;
}
DEBUG_MSG("Loaded EGL %s.\n", eglQueryString(display, EGL_VERSION))
if (!eglChooseConfig(display, attribs, &config, 1, &numConfigs)) {
DEBUG_MSG("eglChooseConfig failed! %s\n", egl_get_error_string(eglGetError()).data())
return false;
}
// it crashes exactly here at this call for some reason
surface = eglCreateWindowSurface(display, config, nwindowGetDefault(), nullptr);
if (!surface) {
DEBUG_MSG("eglCreateWindowSurface failed! %s\n",
egl_get_error_string(eglGetError()).data())
return false;
}
DEBUG_MSG("eglCreateContext %lx\n", &eglCreateContext)
if (!(context = eglCreateContext(display, config, EGL_NO_CONTEXT, attribsCtx))) {
DEBUG_MSG("eglCreateContext failed! %s\n", egl_get_error_string(eglGetError()).data())
return false;
}
return true;
}
I'm not really familiar with Console Development (it's my first time doing homebrew), so if possible, can I get some advice on how I can approach this issue and debug it properly?
I did some limited debugging using gdb in the emulator (yuzu), and I'm starting to suspect it may be something inside the mesa implementation for Switch or something with libnx.
The strange thing is that if I'm making a separate project in which I do the calls inside the application, the instance seems to get created properly, so I'm not sure if it's an issue because I'm linking the main game application with my engine library.
If you need any more information on how I'm trying to achieve things in my engine in order to understand together what I'm doing wrong, let me know.
Also, I don't know if this is the right zone to post this, so please let me know if I used the wrong forum for my issue.
Cheers!