Hey everyone, I have recently decided to get into LWJGL as opposed to using Java2D, however have some questions about the basic game structure for games using LWJGL for rendering.

Right now with Java2D I have a Main class that is used to create the window (JApplet or JFrame) and then a Game class that extended JPanel and was added to the JFrame or JApplet. Now in the Game class I had a paint method that would draw to the JPanel and when drawing other objects, I would call their paint method and pass it the Graphics object in order to paint them to the JPanel.

What is a similar structure in LWJGL? For example, I dont understand what to pass to the Objects being rendered in order to have them all render to the same display and all of that.

Any advice, tips or suggestions are appreciated!

(Also I was looking at the lesson posted by bobjob and I like the set up for it, as I prefer to use Applets, however I dont see how you could extend that to use entities etc as the GLHandle is in another class and all of the Objects would be handled in a different class).

(Also I was looking at the lesson posted by bobjob and I like the set up for it, as I prefer to use Applets, however I dont see how you could extend that to use entities etc as the GLHandle is in another class and all of the Objects would be handled in a different class).

OH! my tut's are not really finished/clean up yet. The main thing in the applet is that all LWJGL methods are handled in its own Thread.

As for handling game resource, Its best to have a class that is a resource loader that will track/store/clean up resources. And something like a "GameData" class that will store the current state of the game.

I didnt know anyone was interested in the tutorials so I havnt really had a sense of ergency with them, Ill spend a bit more time on them from now on.

OH! my tut's are not really finished/clean up yet. The main thing in the applet is that all LWJGL methods are handled in its own Thread.

As for handling game resource, Its best to have a class that is a resource loader that will track/store/clean up resources. And something like a "GameData" class that will store the current state of the game.

I didnt know anyone was interested in the tutorials so I havnt really had a sense of ergency with them, Ill spend a bit more time on them from now on.

Ahh thanks man, and no need to rush with the tutorials but I really do appreciate them and you helping out!

What is a similar structure in LWJGL? For example, I dont understand what to pass to the Objects being rendered in order to have them all render to the same display and all of that.

LWJGL is notable for its lack of structure. Almost everything is static, so there's no need to pass anything around. There's one one display, so just make glWhatever calls however and wherever you like (within the same thread, naturally). Same goes for OpenAL, and the keyboard and mouse classes.Whatever structure you build is up to you, LWJGL doesn't prescribe one.

Hey everyone, I have recently decided to get into LWJGL as opposed to using Java2D.

If your looking for a simple switch, then using LWJGL directly is not the best idea, it will mean you have to write lots of boiler plate code like game loop, etc.

a better choice would be to use Slick2D. Its basically a thin library that sits on top of LWJGL and provides all the basics like, game loop, image loading, etc and it api is designed specifically to emulate that of Java2D so you should be able to move over your java2d project in no time. Plus if your going to do a 2d game you'll be reinventing the wheel and will probably end up writing code pretty similar to what Slick2D already provides.

If your looking for a simple switch, then using LWJGL directly is not the best idea, it will mean you have to write lots of boiler plate code like game loop, etc.

a better choice would be to use Slick2D. Its basically a thin library that sits on top of LWJGL and provides all the basics like, game loop, image loading, etc and it api is designed specifically to emulate that of Java2D so you should be able to move over your java2d project in no time. Plus if your going to do a 2d game you'll be reinventing the wheel and will probably end up writing code pretty similar to what Slick2D already provides.

Yea a lot of people have been telling me to do this, and I too think it is a good idea when I have a solid game idea that I want to crank out, but at the moment I just want to learn about it all and also I am just one who likes to do these on my own in a sense, something to me just feels odd about using other libraries that are suppose to make it easier to write games, its not so much the idea of "This is for noobs" because I know it is not, but I feel like I do not truly understand what is happening and why I am using certain things, i think.

LWJGL is notable for its lack of structure. Almost everything is static, so there's no need to pass anything around. There's one one display, so just make glWhatever calls however and wherever you like (within the same thread, naturally). Same goes for OpenAL, and the keyboard and mouse classes.Whatever structure you build is up to you, LWJGL doesn't prescribe one.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org