Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (120)
games submitted by our members
Games in WIP (577)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Autogenerated native stub code  (Read 1496 times)
0 Members and 1 Guest are viewing this topic.
Offline elias

Senior Duke





« Posted 2004-01-14 17:12:58 »

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:

1. 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).

2. 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.

3. 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)

4. 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

Offline abies

Senior Duke





« Reply #1 - Posted 2004-01-14 17:49:25 »

Have you considered using gluegen from Jogl ? I think it does exactly what you want. On the other hand, if LWJGL would start to use gluegen, it might be easier to just port rest of it on top of jogl Smiley

Artur Biesiadowski
Offline elias

Senior Duke





« Reply #2 - Posted 2004-01-14 18:10:53 »

I'm guessing here, but isn't gluegen "only" generating source code (and even that is from a gl.h file if I'm not mistaken)? I want to go all the way, creating the dll for System.loadLibrary to load.

- elias

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline abies

Senior Duke





« Reply #3 - Posted 2004-01-14 18:20:06 »

Yes, it is created also from gl.h, but it is smart enough to handle many non-cryptic headers out there.

What do you mean by 'only source' ? It generates both java and C part, it is enough to run gcc with few parameters to turn all c files into dll.

Artur Biesiadowski
Offline swpalmer

JGO Coder


Exp: 12 years


Where's the Kaboom?


« Reply #4 - Posted 2004-01-15 11:44:34 »

elias is saying he want's to generate the required machine code for the stubs and write out the DLL, .so, etc.  from Java.  Since the calls are so simple this won't need a C compiler.. just something that pushes args and calls a method for whatever OS is supported.
It sounds cool, but I don't know how practical it is.

Offline abies

Senior Duke





« Reply #5 - Posted 2004-01-15 11:55:49 »

Maybe something like http://www.excelsior-usa.com/xfunction.html would work ? (it is commercial software, but it should be possible to write it yourself).

Artur Biesiadowski
Offline princec

JGO Kernel


Medals: 407
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #6 - Posted 2004-01-15 12:35:03 »

The code which xFunction is based on has been publicly available as a JNI example (for x86 at least) for some time now, but it's not quite what we want, although it'll do what we need it to. Trouble is it created millions of objects as the primitive arguments have to be wrapped and that'll never cut it in a performance situation.

What we're looking at here is actually writing a .dll or .so or .dylib out on first run in the correct binary format for the platform.

A tall order, I suspect Sad

Cas Smiley

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (52 views)
2014-10-17 03:59:02

Norakomi (44 views)
2014-10-16 15:22:06

Norakomi (34 views)
2014-10-16 15:20:20

lcass (38 views)
2014-10-15 16:18:58

TehJavaDev (68 views)
2014-10-14 00:39:48

TehJavaDev (68 views)
2014-10-14 00:35:47

TehJavaDev (60 views)
2014-10-14 00:32:37

BurntPizza (73 views)
2014-10-11 23:24:42

BurntPizza (45 views)
2014-10-11 23:10:45

BurntPizza (87 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!