0
\$\begingroup\$

I've spent months coding a game that uses Java's native graphics methods to create a polygon-based 3D engine, and at this point it's about 12,000 lines long. However, the graphics performance is starting to get bogged down and is wildly inconsistent (e.g. running it on my very nice windows laptop gets me only around 10 FPS, and running it on my Macbook Air gets me around 30-40). From what I've read, Java's graphics are not optimized for speed as much as they would be had I used a library created to aid in drawing efficiency. Given how much work I've put into the project without knowing I probably should be using a graphics library to speed my game up, how easy would it be to implement LWJGL to my game? And if that were difficult, are there any libraries I could use instead that would make transitioning easier and would boost performance and/or at least make the frame rate more consistent across different systems?

Thanks.

\$\endgroup\$
1
  • 3
    \$\begingroup\$ We don't have enough knowledge of your whole project to give you an answer. My tip would be to learn about such an engine, understand how it works, and re-write your game. Don't put good money over bad. You probably can't retro-fit an engine in what you already have. \$\endgroup\$
    – Vaillancourt
    Oct 21, 2016 at 22:20

1 Answer 1

2
\$\begingroup\$

There is only little useful information in your question. The reason, you are getting low fps is that you aren't actually using your graphics card. LWJGL uses OpenGL which is a graphics pipeline/interface that runs on GPUs. In such limited space, I cannot explain, how to make a rendering engine in OpenGL since there are a lot of different ways you can do it and it is far too compex. But basicly it looks like this: almost everything is static, which means OpenGL itself provides hardly any Objects to use. Little is stored on your CPUs RAM, things are rather stored on the GPUs memory and accessed via handles, which you can think of as pointers (in c/c++ you'd use GLuint, in java just int) pointing to memory in the graphics card. GPUs are faster in terms of rendering, because they have a lot of cores, that by themselves aren't that fast, however since there are so many of them (my card has 640). They execute code in parallel, that's why you can't just port your Java or even C programs directly to the GPU, you would have to basicly start your rendering engine all over. LWJGL isn't that hard, especially if you already wrote a 3D-Engine in pure Java (not bad!). It is well documented and there are hundrets of tutorials with examples on it. Any OpenGL code looks more or less the same in any programming language, so even examples written in C++ will be helpful in Java.

\$\endgroup\$
9
  • 1
    \$\begingroup\$ I strongly suggest you de-build this wall of text and replace it with paragraphs :) \$\endgroup\$
    – Vaillancourt
    Oct 22, 2016 at 18:42
  • \$\begingroup\$ @AlexandreVaillancourt I just realized that i wrote an entire novel there... Thanks ;) \$\endgroup\$
    – l'arbre
    Oct 22, 2016 at 21:05
  • \$\begingroup\$ @AlexandreVaillancourt Sorry about the lack of information -- I don't even know what features would be important to mention. Basically, the bulk of my project is drawn using the fillPolygon method, using trig to project 2D polygons as three dimensional (orthographically). The greatest strain on the FPS are color transparency and the number of scenery I draw. Here is an example of what the game looks like: imgur.com/a/beD7w. I've had a great FPS increase just by replacing transparency with color interpolation. The FPS is still lower than I would like, however. \$\endgroup\$
    – pete2fiddy
    Oct 22, 2016 at 22:26
  • \$\begingroup\$ @pete2fiddy creating a scene like this in lwjgl is a matter of a couple of hours, if you know what you are doing. So just get started with some tutorials. Its really simple, believe me. \$\endgroup\$
    – l'arbre
    Oct 22, 2016 at 22:47
  • \$\begingroup\$ I'll give it a go after I'm finished with college applications because I am hoping to attach my code since it is something I've been so passionate about and spent so long on. That being said, it's fairly sloppy, and you can definitely see how I've learned as I've coded it since the later portions are significantly better-coded than the beginning. My point is, I'd love to expand the game as much as possible so I have something that looks as cool as possible to submit, then I'll try to port it to LWJGL for my own sake and for sake of the game's playability. \$\endgroup\$
    – pete2fiddy
    Oct 22, 2016 at 22:58

Not the answer you're looking for? Browse other questions tagged .