4

My questions are:

  • How to use Opengl or DirectX in Java.
  • Does DirectX have any major advantages over Opengl when using it in Java?
  • Is there a way to do so without using an API?
  • Should I use a API such as: JOGL LWJGL
  • Would Java FX be useful for making 3D things?

Also, I am using Windows. Is there a different way to draw 3D objects??

2
  • 2
    You definitively need a library which can talk to the native interfaces, so you do not have to do so in your own code. If you go for OpenGL your program is very easy to port to other platforms. Commented May 18, 2014 at 11:29
  • I don't know what you're trying to achieve, but if you're just trying to render something simple in 3D, you might give JavaFX a shot: youtube.com/watch?feature=player_detailpage&v=EBKHdV-_rIc Commented May 18, 2014 at 12:04

2 Answers 2

7

How to use Opengl or DirectX in Java.

There are a number of OpenGL bindings available for Java. Java does not seem to support DirectX by itself, and neither do there seem to be libraries available that provide bindings.

Does DirectX have any major advantages over Opengl when using it in Java?

I'd say DirectX is at a disadvantage compared to OpenGL due to its lack of support on Linux or OSX. If you want to write cross-platform games using Java, I'd recommend taking a look at OpenGL.

Is there a way to do so without using an API?

I assume you mean a library here. Java offers an API for drawing: Java2D. This might be a nice starting point if you want to write games and are starting out with computer graphics in general. Java does not provide bindings for either OpenGL or DirectX as part of the standard library.

Should I use a API such as: JOGL LWJGL

I have VERY good experiences with LWJGL. I can therefore recommend using their bindings if you want to try using OpenGL.

Would Java FX be useful for making 3D things?

JavaFX is still somewhat buggy as far as my experience goes (came across several bugs when trying it). I don't know how well it works for doing 3D graphics.

Sign up to request clarification or add additional context in comments.

Comments

6

JOGL is a Java binding for the OpenGL and OpenGL ES API. I have used JOGL since 2006 and I'm very happy with it, it's very easy to install as you can see here. It works both in desktop and embedded environments, it supports Android too, it is used by almost all major middle and high level APIs including JogAmp's Ardor3D Continuation, JMonkeyEngine, Java3D, Xith3D, LibGDX, ... GLG2D allows to benefit OpenGL when coding in plain Java2D without having to know OpenGL.

I agree with Bartvbl about JavaFX 3D API which is noticeably poorer than the APIs I quoted above.

JOGL is the only unified Java binding for the OpenGL and OpenGL ES API. It is suitable both for games and for other applications (CAD, ...) as it supports several displays, several screens, several monitors. You can use it with JInput if you want to support joysticks.

6 Comments

I would appreciate that the only person who down-voted my answer tells me why.
I think because this answer is slightly biased. " I'm very happy with it" Also, it doesn't answer the whole question. I still think this answer is useful, an answer is usually better than no answer.
I answered your question, I gave you a link to a detailed tutorial explaining how to install JOGL, nobody can explain shortly how to use OpenGL as this isn't the kind of thing you can learn in a few minutes and there are numerous links to some tutorials in our wiki. You asked whether there are different ways to draw 3D objects and I mentioned numerous 3D engines based on JOGL. My answer isn't more biased than Bartvbl's one and I talked about JavaFX 3D API because Veluria mentioned it.
Well, I guess you are right. I might vote it up when I got 15 reputation. Also, I did learn JOGL! Reason: The name is shorter than LWJGL! (Kidding)
Yes, expecting a constructive feedback from unconstructive posters is silly.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.