Skip to main content
GameDev.net gamedev.net
🔒 Locked

[java] Java / JNI / DirectX

Started by Ataru Jul 30, 2003 at 11:40 AM 3 replies 1.5k views
Original Post
Ataru
Ataru
I''ve seen some people discussing similar things before, but this is one of those cases where the "why would you use java if you want to write the whole enginge in C++" argument does not work. I''m thinking of writing a native code 3D application in C++, however this simulation is data driven from a large Java application that frankly I don''t want to touch. How easy would it be, for my application to have a button that says "run 3D simulation", and then calls through JNI my c++ 3D app, using DirectX or OpenGL. I want to create my own graphics window, etc... I don''t care about portability, I don''t want to bother wrapping DirectX or OpenGL to Java, I want a java application, at some point, to switch to a c++ graphics engine. It looks like something like this should be easy. Is it as easy as I''m making it out to be?
nickwinters
nickwinters
Theoretically, you should be able to do that. Just try doing simple things like creating a window and see what happens. Since OpenGL bindings exist, I know you should be able to do so with DirectX. Go to http://www.lwjgl.org and take a look at their source code. It''s a full OpenGL binding, but at least the window classes should get you started.
nickwinters
nickwinters
Actually, try getting your hands on the bastardization (IMHO) of Java. eg. J++ or maybe J#. Both should be able to do what you want.

Edit: IMHO

[edited by - nickwinters on August 1, 2003 12:49:24 PM]
NuffSaid
NuffSaid
Alternately, seeing as you aren''t really integrating the 3D app into the existing Java app, you could just code the entire 3D part in C++.

Then, in the Java app, have a button called "Run 3D Simulation", which gets a Runtime object, which then just executes the C++ app. The C++ app could take a few parameters on the command line so you can pass whatever additional information to it (e.g. file name to load, etc).

This is something similar to the C function system() or the Win32 function ShellExecuteEx().
==========================================In a team, you either lead, follow or GET OUT OF THE WAY.
CaptainJester
CaptainJester
Look at the various flavours of Runtime.exec(...);.



First make it work,
then make it fast.

--Brian Kernighan

"I’m happy to share what I can, because I’m in it for the love of programming. The Ferraris are just gravy, honest!" --John Carmack: Forward to Graphics Programming Black Book
"None of us learn in a vacuum; we all stand on the shoulders of giants such as Wirth and Knuth and thousands of others. Lend your shoulders to building the future!" - Michael Abrash[JavaGaming.org][The Java Tutorial][Slick][LWJGL][

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.