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.
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.
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!
Related
I have been developing java games in lwjgl for quite a bit and now I want to switch to C++ for a new experience in game programming.
I read through quiet a lot of C++ Game engine/ libraries like SDL, SFML etc but I am really looking forward to something like LWJGL, where the code is similar to OpenGL native and supports OpenGL3 & above.
So is there a engine/ library like that? Or shall I just stick to Native OpenGL, I am really new to C++ Game development. ;)
SDL, SFML and Allegro all support using OpenGL directly so they're kind of like LWJGL in that regard. SFML and SDL 2 let you set the OpenGL version (Allegro only lets you use OpenGL 3.0 or no version specified at the moment). Of these, Allegro has the best documentation atm, SDL 2 the worst (SDL2 still isn't quite stable). SFMLs documentation is ok.
If you would tell us what exactly you're looking for you might get a more detailed answer.
Update: SDL2's documentation is quite usable by now, it's definitely not a reason not to use SDL2 anymore. Also, SDL2 seems to be stable.
Is there a LWJGL port for Android available? (does not matter if the phone needs to rooted)
Things have happened since this question was answered in 2011.
It is new that LWJGL has support for Android.
The linked repo has the setup instructions and the demo, the actual code is in the LWJGL3 repo under the Android branch.
I've been using it for a while now, and this library has a bunch of useful features that aren't just connected to OpenGLES, OpenAL, OpenVR and Vulkan, but it also has a lot of utilities for things like 3D model loading, layouts, dialogs, fonts and a lot more. Meaning the Android port of LWJGL is a considerable add-on to the current OpenGL ES support.
As for other libraries though, you can use no libraries because of the native support. Alternatively, you can use LibGDX or jMonkeyEngine, those are the only two others I know of and have used. Note that these are frameworks and not libraries like LWJGL, meaning they set up a given system you have to follow (one of the reasons I dislike them). It's harder implementing custom features without having to bring out a lot of other parts of the framework that aren't that well documented.
One of LWJGL's main features is its OpenGL support. Android natively supports OpenGL ES so there's basically no need for LWJGL. As for the rest of LWJGL, it doesn't apply on the Android platform anyway - for example there is obviously no mouse to an Android device - so I don't see a direct LWJGL port ever being developed.
Check out the Android reference, especially the android.opengl package, for a good starting point.
A good 3D and 2D engine that uses LWJGL and works well for Android development (and also Desktop and Web Apps) is libGDX.
I can't say for sure, but during last autumn I was searching for quite a long time for that and couldn't find anything. So I would say no, but don't bank on that.
I just ordered an Android smartphone and want to start playing around with creating my own applications. Now the question is which language to use, the native Java or Python using SL4A (former ASE).
I tend to Python, as I know it much better than Java, but I'm wondering what I would be missing using a "second class" language on Android. On the SL4A website it is also stated to be alpha quality software, which is not exactly encouraging.
I'm also not quite sure what the limitations of the scripting environment are and if they would be problematic.
At the moment you cannot create a releasable program with Python (or any other scripting language) using SL4A. I have heard rumours that this is something Google is working on, but even if they do enable it Python apps are likely to be slow and power-hungry compared to Java. Also the scripting API only gives you access to a limited subset of the native Java API. I would not consider using SL4A for serious development work at the moment, only for one-off scripts and prototyping.
Take a look at Scala. It is a statically typed language on the JVM, but uses type inference to remove most of the noise that you get in Java. It also fully supports functional programming, and has a lot of pythonish features. Because it is statically typed it is as efficient as straight Java with none of the disadvantages. IMHO it is the language that Java should have been in the first place.
A lot of people are blogging about using Scala on Android, so Google around for more information.
More likely will depend what type of applications you will develop.
I would start with Java to become familiar with Android SDK. Anyway first you need to look into some examples, tutorials. Most of them are done in Java, and only a few, probably on the dev site of SL4A for that.
Also there is native development Android NDK, that can be programmed with C++.
But anyway Java rules for general applications.
Adding an update to Dave Kirby's answer:
Issue 55, Distribute scripts as APKs, in the issue tracker at SL4A deals specifically with that.
There is a solution being worked out (may be complete by now) described at SharingScripts. The only issue seems to be that you need to have a interpreter APK already installed.
you may want to check out Ruboto it is a framework for developing Android apps based on JRuby which means your JRuby code can call Android APIs and can also be called back from the Android Java side.
Here is an introduction article .
Consider ising Kivy, if you want to write Android apps with Python. The process of packing script to .apk file is described here.
The problem is, resulting .apk will be big (~7Mb for 300Kb data). It is obvious, because you need to pack there Python runtime and all libraries.
Another solution I have heard of, is Pygame for Android, but it works on lower lewel, so you need to draw graphics manually.
Unfortunately, I have not tried any of this ways yet, but it looks, that I'm going to start using kivy soon.
I am in the concept phase of an application that is going to have a lot of Audio/Video input and output. I want to do it in Java; but somehow am not fully convinced yet. What do you think? How bad could it be? And any advices?
Why I am thinking Java:
It's the language I'm most comfortable with.
Easier cross platform migration would be a bonus.
Cannot afford commercial platforms (like .NET) or not good enough in other free alternatives (like Python)
I'm also slightly inclined towards C++/Qt; but that would take more time for me as I'm not great in that and I am a bit worried about maintainability.
If you're interested, check out Xuggler. It exposes all the power of FFmpeg, but as a Java API that runs on Windows, Mac and Linux. The advantage is you get all the power of FFmpeg but from Java. The disadvantage is it requires the FFmpeg native DLLs/shared-libraries to be installed.
Easier cross platform migration would be a bonus.
Audio and video means you will be dealing with dedicated native libraries and JNI-wrappers for each supported platform; in this case, the cross-platform argument for Java does not really apply.
I believe that when you want to write an audio/video application, the programming language you will use is the second most important thing. The most important thing is the audio/video framework your application will use since this is what defines your capabilities.
I am aware of two popular generic video frameworks that can be used to accesd most multimedia types: Directshow and ffmpeg. Directshow is tied with windows, so only ffmpeg is left.
Ffmpeg has versions in both windows and unix and, although it is written in C, it can be used from a lot of languages.
There is even a number of java wrappers for ffmpeg (for instance, take a look at xuggle)!
C++ would be the first choice because of performance concerns often present in Audio/Video processing as well as the range of available libraries for video/audio.
You do make a good point about being familiar with Java. If you are pressed for time, this is even more important. However if you can spare some time for learning, C++ would be well worth it.
Regarding .NET: The .NET SDK with everything you need is freely downloadable. Get hold of a free IDE such as SharpDevelop and you are up and running. It's Visual Studio that costs money, you don't need Visual Studio to do .NET development.
Rusty.in,
How about trying to do JavaFX Media API. Recently, the version of the JavaFX is 1.2.0 with GUI Application as well. It supports the Swing. The grammar is based on the script style; however, you can deploy the existing Swing components into the JavaFX.
I hope it helps.
Tiger
Rusty, what did you wind up doing? I too have a video app I'd like to do, but really would prefer Java/JavaFX over C++. The thing about the using Flash and/or the current JavaFX video support is that Flash video playback is not frame-accurate. I really need to be able to stop/start/step on individual frames like you can with QuickTime.
Has anyone tried doing playback with Xuggler and Java/JavaFX?
I'm working on some Flex spike in my company. We are basically evaluating different scenarios etc. What solution would you recommend for embedding Flex components into Java app? Flex <-> Java communication is not (yet...) an issue, just embedding swf into JFrame.
I've done it with EasyJCom. It's pretty straight forward as long as you're using one of the standard Java windowing libraries (Swing, awt). You can see an example (From the EZJCom site) here: http://www.ezjcom.com/FlashTest.java.txt
The people responsible for EasyJCom are also very responsive, and even though we ended up not using their product (Switching platforms), I'd recommend them.
I haven't used JFlashPlayer, but did take a look at the docs, it seems to be adequate as well. I think their license requires you to obfuscate your code. I thought it was a little odd, but maybe I mis-understood the license.
It gets quite a bit more complicated if you don't want to use Com, or if you need to embed in another type of window.
If you need to embed flash cross platform, you may be stuck rolling your own Jini library for the Mozilla plugin. At that point... Maybe it's worth just switching platforms if you aren't too far in. ;)
Haven't tested this, but it looks like JFlashPlayer will do the job. http://www.jpackages.com/jflashplayer/
None of these supports Linux or MacOS. So much for the cross-platform Java and Flash.
I think the best way to do something like this would be to embed something like xulrunner into your java app then have the java app interact with flash via the xulrunner interfaces.