Dear all,
I've written a 2D/3D engine in D before which runs on windows, linux and android using SDL2 as the window manager and uses Modern OpenGL /OpenGLES for rendering. It compiles fine for android using ldc and works like a charm, although the garbage collection under android has multi-threading issues.
Since OpenGL is abandoned, I am currently adding Vulkan support to future proof it.
I have done this in D with the help of the bindbc-sdl and erupted packages and managed to get the whole vulkan-tutorial.com example working under windows without much hassle. (I bet it would run on linux without much issues as well)
So I have now been stuck for a week on getting the tutorial example to successfully run on android. To do this I get a DLL compiled with ldc, I have setup the SDL2 toolchain for android, with symlinks to SDL2/IMAGE/TTF/etc, I hook the call to SDL_main from the JNI:
/* Main entry point to the program */
version (Android) {
import core.memory;
import core.runtime : rt_init;
extern(C) int SDL_main(int argc, char* argv) { // Hijack the SDL main
rt_init();
GC.disable(); // The GC crashes on android
run(["android"]);
return(0);
}
// Other OS can just call run() directly (No known issues with garbage collection)
} else { void main (string[] args) { run(args); } }
I create my APK using Android Studio, and load it onto my phone. The hook succeeds, I can do:
loadSDL();
SDL_Log("SDL loaded");
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO);
SDL_Log("SDL init");
SDL_Vulkan_LoadLibrary();
SDL_Log("SDL_Vulkan_LoadLibrary");
I see SDL being loaded and initialized (successfully) on my phone. However, the SDL_Vulkan_LoadLibrary call just crashes the whole thing dead, with a:
I/SDL/APP: SDL loaded
I/SDL/APP: SDL init
A/libc: Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 25878 (SDLThread), pid 25794 (SDLActivity)
I was wondering if I am missing something obvious. Since it works for SDL2 and opengles
Any thoughts on why loading the Vulkan library using SDL2 would not work ?
thoughts in general about the process ?
Danny