Graphical operations in C++ through the JNI - java

I'm writing an online multiplayer game, and I'm thinking about implementing the network code in Java, using JBoss Netty. But I'm considering C++ for the 3D rendering (they're simple graphics, nothing extensive). Would it be worth implementing such behavior in C++?

Would it be worth implementing such behavior in C++?
No, I would recommend doing everything in java or in c++. That way you won't have any problems with c++ to java interoperability. In case you already have the network code in java I would go for that.
If you choose java you can use a 3D rendering library like for example jogl or lwjgl. These libraries are really light weight and you will probably not have any problems with the actual rendering performance since it is done by the graphics chip.

Related

Java 3D Graphics using Applet and in built libraries only

I want to do Java 3D Graphics without using external libraries to develop a game applet. Sorry I am not that experienced with Graphics and so I am not sure how hard it would be to do it by myself
The real answer to your question is that you're thinking about it a bit sideways: you shouldn't be using an applet (they're dead), and you shouldn't try to do it all by yourself without any libraries.
I'd personally recommend Processing for beginners or libGDX for more experienced users. They both allow you to do 3D, and they both allow you to deploy as JavaScript- which is better than applets.
If you really, really, really want to try to do this without any libraries, then you'll have to do all the 3D math and whatnot yourself, then do the drawing in Java2D. A very basic example of getting started is here, but like I said, you're on your own to do all the conversions from 3D world space to 2D drawing space.
Any sane person would use something like OpenGL instead, which you can find Java wrappers for- JOGL is a pretty basic wrapper (so if your goal is to get "close to the metal" then this might be your best bet), LWJGL provides a few extra features for game development, and the already-mentioned libGDX is built on top of LWJGL.
If you're afraid of using libraries because you think they're too complicated, let me tell you that doing 3D stuff without a library is even more complicated.

JOGL or LWJGL pre-existing project

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?
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.
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/

C++ vs Java in Android

I'm interesting in start a game development. I currently did some openGL in C++, but now I'm looking for the options that offers Android, and I have found people who developes his games using Native code (C++) and others that use Java...
So I don't really know which is the main difference. I read that many people has experience using C++ and prefers this one to don't have to learn new things using java... but I don't think this is the main reason.
What are the main differences developing a game using C++ or Java? Perfomance? Scalability? Posibilities?
Also, do you recommend to start the game development using OpenGL?
I would suggest using whichever language you are more comfortable with. A game is never a small project, and since you are new to the process (judging by this question) you will probably not be concerned with any performance differences or anything like that.
To answer your questions:
Performance
see C++ vs Java Performance, Android: Java, C or C++?, etc.
Possibilities
There is nothing inherit that C++ can do and Java can't, or vice versa when it comes to your goal.
Scalability
Not sure what you are asking with this one.
C++ can perform better than Java (don't believe the naysayers, do your own benchmarks), but there is more support for Java on Android. In the end it depends on how intensive your app is going to be and how much battery it is going to drain. If it is extremely intensive, go with C++ because you can do more with less. If it doesn't matter, then go with Java.
at the end it doesn't matter sense if you use c++ you will need to learn all those frameworks used for android development, if you use java you will learn java and openGL is the same in all languages so just go with c++ if you are a c++ developer
Also, do you recommend to start the game development using OpenGL?
you should not start with OpenGL not that you can't but I would sagest something like SFML witch will teach you a lot about graphics programming then you can move to OpenGL

Moving from Java to C++ API's

There are some particular API's in Java that make it very good. However I would prefer C++ because of performance and "bleeding" edge support with OpenGL and OpenAL among the many libraries.
Which API's are there that are similar to Java2D (I know I can use OpenGL however I lack the matrix math understanding to fully use OpenGL in this way)? Also which GUI framework (non-native; platform independent) is the most used in C++?
FLTK, Fast Light Tool Kit has some 2d functionality. It's somewhat like swing and 2d mixed together. It does focus more on the UI aspect but it may help you out.
http://www.fltk.org/
If you want platform independent GUI framework for C++ check Qt.
I can't speak much for Java2D equivalents but as far as GUI frameworks go, I've heard of two:
wxWidgets: http://www.wxwidgets.org/
Qt: http://qt.nokia.com/products/
Both of these are cross-platform and I believe widely used.
Try GTK--. It has some features that make it a bit nicer an API than either wx or Qt.

Learning OpenGL through Java

I'm interested in learning OpenGL and my favorite language at the time is Java. Can I reap its full (or most) benefits using things like JOGL or should I instead focus on getting stronger C++ skills?
Btw, which is your Java OpenGL wrapper library of choice and why?
JOGL is a wrapper library that allows OpenGL to be used in the Java programming language. It is currently the reference implementation for
JSR-231 (Java Bindings for OpenGL) so it should be your first choice
I have done some basic OpenGL development in Delphi and Java as well. I used JOGL, as mentioned in others' replies, and I must conclude that although there is very little difference in programming OpenGL in Java using JOGL and programming OpenGL in other languages (Delphi, C++, etc...) it just doesn't feel right. It was driving me crazy to set it all up correctly and then writing stuff like
gl.glBegin (GL.GL_QUADS)
there seems to be a lot of superfuous gl, GL, GLU to be written and it just gets in your way. Also the performance would be, I believe, much better if you used C++ or similar, NOT Java.
I am not saying hands off JOGL (Java+OpenGL), it can be done, and it really isn't too different, but... as I said. Give c++ a try, if you can.
If you are also interested in just doing 3D stuff in Java without worrying about all that low-level stuff, check out Java3D.
Worst case, you can look at how they leverage OpenGL for some good learning material.
if you really want to get serious at 3d programming you have to learn C/C++, C++ is the standard for programming 3d games
Do it in C++, the bits you'll be using will basically be the same, because there won't be much messing about with pointers, so it's not a major leap of intuition. Also, the C++ bindings are more reliable and (in my experience) the fastest out of all the langauges available (Python in particular REALLY can't do OpenGL).
Also, C++ is always a good thing to learn, it makes you think about programming concepts in much more detail, as opposed to just popping in an ArrayList<> or whatever pre-built class kind-of-serves your purposes =]

Categories