Hi everyone,
I’ve grown kinda annoyed having to write and recompile the native code for LWJGL for every platform we support (especially for Cas the lazy bum who doesn’t like to get his hands all dirty touching a linux box :-D). And we don’t even have readily access to a real Mac at the moment. So a crazy idea of mine was why not simply autocreate the native code? To do that, I think, we need:
-
To create an class mapping C structs to an internal ByteBuffer using reflection something like the way Cas wanted the Structs API extension to java. That way, almost every traditional C function argument can be described by a primitive type, a Buffer object or a Struct (at least that’s what I hoped).
-
To redesign all native parts of LWJGL to use SWT style. That is, have all (OS) native calls be simple and easily generated stubs at the native side and let platform specific java classes handle the work done in native code today. This is already done for OpenGL for obvious reasons, but the real platform dependent code needs a lot of work here.
-
For each platform, find out how its dynamic libraries are built and then autocreate each and every native stub from the java declarations. Something like:
push the args
call the function pointer (fetched at some library init point)
- Now only the jar and openal will have to be distributed along with the game.
Obviously that’s a lot of work, and quite a few details are missing (like how to handle structs within structs? or C arrays that lack explicit length information). The work isn’t pressing, as it won’t introduce any public API changes, but I wonder if anybody had ever tried something like this before? I know almost nothing about dynamic library layouts and only a little (win32/SPARC) assembler, but that doesn’t scare me yet.
- elias