-3

I've noticed that using the Java libraries that are default built in, rendering the simplest graphics absolutely kills the FPS, and furthermore, looks ugly.

Now I was wondering if I could use JOGL or LWJGL libraries to use in my pre-existing program. (I'm making a game which renders cubes as planets, and you have to build planets.) Do I need to completely rewrite my code? Or can I just install these and render freely? And which one of the above is easier to understand, because I have limited knowledge in these libraries.

Btw, right now, I am using JFrames, does that need to go as well? Also, what is OpenGL, is that good to use as well without rewriting code?

genpfault
  • 51,148
  • 11
  • 85
  • 139
EDToaster
  • 3,160
  • 3
  • 16
  • 25
  • You didn't even tell us which API you're currently using I'm assuming `java.awt.Graphics2D` but you never even mentioned what you're using now, so how are people supposed to give you a migration path – PeterT May 05 '14 at 00:04
  • @peterT Hold on, I'll check. OK, right now I am just using a pixel array and writing those values onto the screen. As for what API? I'll have to check later, because my dad's currently using the computer. – EDToaster May 05 '14 at 01:35

2 Answers2

3

OpenGL is a standardized graphics interface for use between programs and your graphics card. A proprietary version of this by Microsoft is known as DirectX. LWJGL and JOGL are two different Java bindings to OpenGL libraries, both of which have native code they load in.

LWJGL is much more aimed towards gaming with OpenGL, where as JOGL is more worried about complete and perfect bindings to OpenGL/OpenCL. I would recommend LWJGL if you're just getting started.

You're going to have to rewrite your rendering code, yes. But assuming you designed your project well, you shouldn't need to rewrite the game logic. JFrames will probably also have to go, but I'm not completely sure about that.

Zoey Mertes
  • 3,139
  • 19
  • 23
  • So can you point me in the right direction as to where i can find information on how to port to LWJGL? Is the _original code_ able to render 3D cubes efficiently? Because rewriting the rendering code is going to be horrible. – EDToaster May 04 '14 at 22:23
  • @JClassic What do you even mean with that? LWJGL is a simple OpenGL wrapper, so it can do the "same" as OpenGL. – vallentin May 04 '14 at 22:58
  • @Vallentin I did not mean that it does it differently. I meant how to be able to use LWJGL in my project. – EDToaster May 04 '14 at 23:08
  • @JClassic Well, download the libraries and implement them into your project. – vallentin May 04 '14 at 23:55
  • @Vallentin that was not my question. – EDToaster May 05 '14 at 01:36
  • @JClassic "how to be able to use LWJGL in my project" = "download the libraries and implement them into your project" – vallentin May 05 '14 at 09:02
  • @JClassic your question is too broad - you use LWJGL by using it. Learn how to use it, and put what you learned into your project, the same way you learned what you did originally and put that into your project. – Devon Parsons May 05 '14 at 14:40
1

Please don't turn this question into another "JOGL vs LWJGL" thread. Moreover, JOGL is used in several games including Poxnora and Salem (MMO). You'll have to learn OpenGL if you want to use any Java binding of this API anyway.

Finally, you can use GLG2D in order to get a better hardware acceleration with plain Swing, it would allow you to benefit of better performance only with a very few changes in your program. GLG2D relies on JOGL 2, you can find more information about it here: http://brandonborkholder.github.io/glg2d/

gouessej
  • 3,640
  • 3
  • 33
  • 67