Finally it renders something! This took me quite a while to get working. Apparently the 3DS expects some vectors in WZYX ordering… The wrong ordering caused the projection and view matrix to be incorrect and the result was a blank screen.
However, on a real 3DS it looks like this:
In the emulator I could get quite a bit more working. I added the ability to load 3D models. It doesn’t download from the object path yet so I copied a pre-filled cache folder to the emulator’s virtual SD card as a test:
There it is, VP with 3D models loading on the 3DS emulator 🙂 Of course it is still missing textures, lighting and probably more.
Unfortunately I’m not sure how to fix it so it runs on a real 3DS. It doesn’t just have distorted rendering, with the model loading it hangs a few seconds after starting. Unless I get it working, this will be the last part in the series.
In part 1 I was able to build most of VP’s code for the Nintendo 3DS target using the homebrew SDK, but only a small part of it was running: just enough to make it log in.
At the end of the previous article I mentioned that other parts of the code need a functioning renderer. Actually, it just needs to have a renderer that pretends to be functioning. For situations like this VP has a fake renderer. It doesn’t render anything, it just tell the rest of the code that it did and that everything is fine. Let’s use that and see what happens when running it in a 3DS emulator.
It enters the world! You can tell from the screenshot above that the user count for testworld went from 2 to 3. And on the PC the avatar can be seen as well:
Unfortunately, when I tried this on the real 3DS it just crashed. After some online searching I found out that it is possible to enable a remote debugger on the (softmodded) 3DS through the Rosalina menu, which can be accessed by pressing L + Down + Select. I enabled the debugger attached to it using GDB:
(gdb) target remote 192.168.1.51:4003
Remote debugging using 192.168.1.51:4003
0x00100000 in _start ()
(gdb) c
Continuing.
[New Thread 216]
[New Thread 219]
Thread 1 received signal SIGSEGV, Segmentation fault.
0x00320328 in strlen ()
(gdb) bt
#0 0x00320328 in strlen ()
#1 0x001bd75c in ObjectPath::getCachePath[abi:cxx11]() ()
... more stack frames
Something appears to be going wrong when trying to find where to put cache files. It’s running the code path that is also used on Linux systems. This code path uses getenv("HOME") to find the home directory and because the 3DS most likely doesn’t have this it returns a null pointer. Adding some 3DS-specific code to determine the cache location fixed this.
There were also some easier to fix issues before it would work. Here it is running on a real 3DS:
After this I started working on a renderer implementation for the 3DS. I managed to make it clear the screen with a color, but it’s not rendering anything yet.