Active Rendering and OpenGL
Hello, as some of may already know, recently I have been working on a 2D real-time game. This is my first attempt at this kind of project and sadly I have been disappointed by the trickiness this involves. In fact, I am writing a project similar (idea-wise) to Vermin ExTerminator (www.vermin-exterminator.de/). Whilst the game mentioned manages to run smoothly mine is unable to surpass 34 FPS. Here is a bit of background - I am using BufferStrategy to repaint the screen and I am using the Graphics2D to do the actual painting (this is done every 25 miliseconds using a "painter" thread). Correct me if I am wrong, but I think I heard something about G2D using OpenGL, and yet, even though I made quite a lot of tweaks to the code, I cannot break the 34 FPS barrier whilst similar games using libraries such as LWJGL and JOGL manage to do this easily. Are external libraries using OpenGL the only possibility when hoping for good steady results in a real-time game? This is not entirely cross-platform and, mainly, it is a whole new library (which looks quite complicated) to explore.
With Thanks,
laginimaineb.
# 1
Have you established for certain that the reason you get a frame-rate of 34 fps is that you can't draw faster than that? Could it be, for example, that your painter thread is lower priority than you think?
# 3
Hello, I have resolved my problem by learning how to use the LWJGL (http://www.lwjgl.org/) libraries. This has proved itself as the game now runs far faster without any significant changes to the code (except adjusting it to LWJGL). If anyone would like to learn how to use LWJGL for 2D games - I would suggest downloading the Vermin-Exterminator source which is free and provides a good example of OpenGL and OpenAL use in 2D real-time games. Furthermore, I would suggest learning how to use OpenGL from Nehe (http://nehe.gamedev.net/).
Hope this helps =).
laginimaineb.
# 5
Hey, sorry I didn't notice your post for a long while - I was quite busy. Anyway, since I am no expert at LWJGL I would advise you to do what helped me best - first of all, there's a game called Vermin Exterminator (http://www.vermin-exterminator.de/en/download.html) which is open source and uses LWJGL. I downloaded the source of the project and compiled it (mind you, it's code uses an old version of LWJGL, you will have to adjust it a little). From there on it's reading all of the comments and trying your best to understand. On top of that, since LWJGL's rendering is done via calls to OpenGL - I would suggest reading the Nehe tutorials (http://nehe.gamedev.net/) which also include a LWJGL source for each lesson. And last but not least, the forums at LWJGL (http://lwjgl.org/forum/) which have a very active and helpful community. By the way, if you use LWJGL - consider donating :)
Hope this helps.
laginimaineb.