I have built a SDL2 game on Haiku. If I run it under the Debugger, it stops at BView::_AddChild().
If I hit Run in the Debugger, it continues on and runs fine. Running it from the terminal, it crashes at startup with the same call stack.
Any clues appreciated.
Thanks,
Joe
You are probably hitting a call to the debugger() function. In this case Debugger shuold show the exact message, to the right of the thread name in the thread list.
Hopefully the message is clear enough for you to understand the problem, if not, tell us what it says and we can have a look
Can you save debug report (available in Debugger menu), upload it somewhere and put link here?
thread 7800: sdl-min (main)
state: Call (AddChild failed - the view already has a parent.)
Frame IP Function Name
-----------------------------------------------
00000000 0x15c5f1f35ef _kern_debugger + 0x7
Disassembly:
_kern_debugger:
0x0000015c5f1f35e8: 48c7c0e4000000 mov $0xe4, %rax
0x0000015c5f1f35ef: 0f05 syscall <--
0x7fa8c3f6e560 0x781b1ac017 BView::_AddChild(BView*, BView*) + 0xa7
0x7fa8c3f6e580 0x781b1ac2bd BView::AddChild(BView*, BView*) + 0xd
0x7fa8c3f6e5d0 0x781b1b08bd BWindow::AddChild(BView*, BView*) + 0x4d
0x7fa8c3f6e610 0x978f7dfe9d SDL_BWin::CreateGLView(unsigned int) + 0xc3
0x7fa8c3f6e640 0x978f7de239 HAIKU_GL_CreateContext + 0xca
0x7fa8c3f6e680 0x978f7ad5bf SDL_GL_CreateContext_REAL(SDL_Window*) + 0x3f (../src/video/SDL_video.c:-1)
Variables:
ctx: 0 {
*ctx: Unavailable
}
0x7fa8c3f6e6c0 0x1b70a9fe839 setupSDL2() + 0xc9
0x7fa8c3f6e6e0 0x1b70a9fe3fe main + 0xe
I have also created a minimal example, if you would like to run it in the Debugger:
https://github.com/BeagleJoe/SDL2-minimal
I’m a bit rusty with SDL but I’m pretty sure you can’t use the SDL_Renderer and an OpenGL Context together.
I’ll change can’t with shouldn’t, since I’ve done some Googling and looks like people have mixed results doing it per platform.
The SDL Renderer will use eg. OpenGL behind the scenes to do its work, and since OpenGL is state based, trying to use both the Renderer and a Context at the same time could get messed up. The Renderer might also want a different version of OpenGL to what the Context is using.
If you just want to use the Renderer, you don’t need the Context, if you want to use OpenGL you should just use the Context.