[java] Anyone using JNI with DirectX/OpenGL?

Started by
30 comments, last by Kaijin 22 years, 2 months ago
Just out of interest how many people here use or are considering using DirectX/OpenGL with Java? (via JNI or otherwise) And if not is this restriction this poses on portablity? How does JNI with DirectX/OpenGL stack up against Java 1.4 in terms of speed? - Kaijin
Advertisement
i remember seeing GL4Java somewhere...
What''s the point in using Java if your game is going to be platform dependant? Isn''t the whole point of Java that it can run anywhere?
Java is proven to have benefits over C++ when it comes to productivity so you can spend less time debugging and more time actually making the game and improving game play.

- Kaijin
I use GL4Java, haven''t really done any speed comparisons though: http://www.jausoft.com/gl4java/

The main reason I use Java is its productivity benefits, but the portability is also nice. Java apps can often be quite portable even when using native calls because of they way the native code is contained by the Java Native Interface. The JNI provides a platform-independent way to call native code from Java so you do not have to change, or even recompile, the Java portions of your app when porting it to other platforms.

Henry
quote:Original post by Kaijin
Just out of interest how many people here use or are considering using DirectX/OpenGL with Java? (via JNI or otherwise)


I have a C++ project I''m working on that wraps OGL (D3D too as soon as I get some time). When I''m done with the native piece I plan on making both a JNI & a COM wrapper.

quote:
And if not is this restriction this poses on portablity?


Portability is a concern that needs to be addessed per-project. JNI does not kill portability as long as you port the native code too.

quote:
How does JNI with DirectX/OpenGL stack up against Java 1.4 in terms of speed?


Err...what part of Java 1.4? If you mean Java 3D, it''s not part of the standard J2SE release, it''s released seperatly under it''s own version number.
Also, Java 1.4 and its java.nio package is the best thing to happen to high-performance JNI programs since...well since JNI.

quote:Original post by Anonymous Poster
What''s the point in using Java if your game is going to be platform dependant? Isn''t the whole point of Java that it can run anywhere?


Portablilty is only one concern Java addresses. As Kaijin said, productivity is big too. I also like the idea of my game logic being fully portable, and only having to port the underlying engines to go to a new platform.

"So crucify the ego, before it''s far too late. To leave behind this place so negative and blind and cynical, and you will come to find that we are all one mind. Capable of all that''s imagined and all conceivable."
- Tool
------------------------------
"There is no reason good should not triumph at least as often as evil. The triumph of anything is a matter of organization. If there are such things as angels, I hope that they're organized along the lines of the mafia." -Kurt Vonnegut
quote:Original post by WayfarerX
Err...what part of Java 1.4? If you mean Java 3D, it''s not part of the standard J2SE release, it''s released seperatly under it''s own version number.
Also, Java 1.4 and its java.nio package is the best thing to happen to high-performance JNI programs since...well since JNI.


No I meant how does it compare using JNI vs the built in full screen support and violatile images.

Basically, I''m currently writing a game library in Java using JNI and DirectX and I just wanted to know if I was wasting my time seeing as Java 1.4 is being geared a lot more towards full screen multimedia apps.

- Kaijin
On the note of performance what sort of overhead does calling a JNI function impose? Is it conciderably worse than calling a standard Java method?

quote:Original post by WayfarerX
Also, Java 1.4 and its java.nio package is the best thing to happen to high-performance JNI programs since...well since JNI.


Yeah, I remember reading somewhere on this forum about the java.nio package. Is it true that it allows Java to share the same memory space with C++.

- Kaijin
quote:Original post by Kaijin
No I meant how does it compare using JNI vs the built in full screen support and violatile images.

Basically, I''m currently writing a game library in Java using JNI and DirectX and I just wanted to know if I was wasting my time seeing as Java 1.4 is being geared a lot more towards full screen multimedia apps.


Ahhh...ok, I see
Well, there is stuff DX gives you besides the graphics (sound, joystick input, etc). I haven''t gotten to play with the Volitile Images too much yet, but I bet you''re still going to get better performance out of your JNI/DX version (if it''s done well that is ) just because you''ll be able to tailor it to your specific needs.

If you wanted to be really crafty you could put a layer between the client code and the engine and have the layer load a pure Java 1.4 version of your engine if the Direct X version is not available.

1.4 is cool, but it''s still in beta, and if it''s anything like 1.3 then it''s going to be awhile before all the bugs get worked out.

"So crucify the ego, before it''s far too late. To leave behind this place so negative and blind and cynical, and you will come to find that we are all one mind. Capable of all that''s imagined and all conceivable."
- Tool
------------------------------
"There is no reason good should not triumph at least as often as evil. The triumph of anything is a matter of organization. If there are such things as angels, I hope that they're organized along the lines of the mafia." -Kurt Vonnegut
quote:Original post by Kaijin
On the note of performance what sort of overhead does calling a JNI function impose? Is it conciderably worse than calling a standard Java method?


Before java.nio the answer would be yes if you wanted to transfer a large amount of data across as it had to be copied. Otherwise very little or no extra overhead at all (from what I''ve seen).

quote:
Yeah, I remember reading somewhere on this forum about the java.nio package. Is it true that it allows Java to share the same memory space with C++.


Yes sir! Zero-copy data transfer between the JVM and your native code.

"So crucify the ego, before it''s far too late. To leave behind this place so negative and blind and cynical, and you will come to find that we are all one mind. Capable of all that''s imagined and all conceivable."
- Tool
------------------------------
"There is no reason good should not triumph at least as often as evil. The triumph of anything is a matter of organization. If there are such things as angels, I hope that they're organized along the lines of the mafia." -Kurt Vonnegut

This topic is closed to new replies.

Advertisement