Question

Is there an easy way to use DirectX in Java? In particular, DirectX's video APIs.

I know that C# might be a more natural choice, but I have my devious reasons for wanting to do something so perverse.

Was it helpful?

Solution

I don't know about easy, but you could always use JNI to load the DirectX libs and invoke the methods.

Using something like Swig you could auto-generate a lot of the code.

Not sure how workable something like that would be though.

OTHER TIPS

There seems to be a standard API about dealing with 3D inside Java.

It probably uses some kind of accelerating technology, may be even DirectX.

But I'm not sure about direct video support in this framework.

I create a library using BridJ (https://bridj.googlecode.com) that wrap DirectX classes, so you can use almost the same code than C++ examples.

You can find the library in https://bitbucket.org/fourthskyinteractive/directx-for-java.

Please, let me know about projects you develop.

There is a set of Direct3D bindings for Java available at http://java-direct3d.sourceforge.net/ but it seems that developement stopped in 2006 with DirectX 9.

Otherwise, there are OpenGL binding for java called JOGL.

The package that you want to investigate is the Java Media Framework (JMF). The core of it is pure Java, and per-platform "performance packs" provide acceleration via native libraries. It currently supports A/V capture and playback in a wide variety of data types as well as streaming via RTP and RTSP.

Sun's JMF home page

JMF SW/HW requirements

Minecraft is coded in Java with LWJGL, but Messiah Andrew's Renderer Wrapper converts the OpenGL to DirectX by using a modified version of the LWJGL libraries. Using these libraries, you should be able to code in LWJGL and have the game be running DirectX.

It seems that most are forgetting that JavaFX and Java3D support both DirectX and OpenGL using the best context for the machine you are on... well actually if you are on windows it attempts to load DirectX if it is newer than your OpenGL version.

I am not telling anyone to use either Java3D or JavaFX, but if you look at the source you can see how it is done.

GrepCode "good for looking for how things are implemented"

Open JavaFX "Open JavaFX project home" source

I should note that you want to look at the com.sun.prism package.

Java3D "Java3D project home" sources

I have been LEARNING development, LOL, for 20 years. Professionally for about 8 possible has never been the question, but how long, and/or is it worth it... Those are the questions.

Good luck my friend!

If you need any help I would be interested in creating a DirectX wrapper for java so

GIVE ME A SHOUT!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top