Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (524)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (592)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Basic LWJGL game structure  (Read 3267 times)
0 Members and 1 Guest are viewing this topic.
Offline Swattkidd7

Junior Devvie





« Posted 2010-07-30 23:19:25 »

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).
Offline bobjob

JGO Knight


Medals: 10
Projects: 4


David Aaron Muhar


« Reply #1 - Posted 2010-07-31 04:06:13 »

(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.

My Projects
Games, Webcam chat, Video screencast, PDF tools.

Javagaming.org with chat room
Offline Swattkidd7

Junior Devvie





« Reply #2 - Posted 2010-07-31 05:26:15 »

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!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ryanm

Senior Devvie


Projects: 1
Exp: 15 years


Used to be bleb


« Reply #3 - Posted 2010-07-31 06:26:42 »

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.
Offline kappa
« League of Dukes »

JGO Kernel


Medals: 78
Projects: 15


★★★★★


« Reply #4 - Posted 2010-07-31 11:02:30 »

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.
Offline Swattkidd7

Junior Devvie





« Reply #5 - Posted 2010-08-01 07:06:44 »

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.
Hmm, this actually clears up a lot, thanks!
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

toopeicgaming1999 (57 views)
2014-11-26 15:22:04

toopeicgaming1999 (50 views)
2014-11-26 15:20:36

toopeicgaming1999 (10 views)
2014-11-26 15:20:08

SHC (24 views)
2014-11-25 12:00:59

SHC (24 views)
2014-11-25 11:53:45

Norakomi (27 views)
2014-11-25 11:26:43

Gibbo3771 (24 views)
2014-11-24 19:59:16

trollwarrior1 (37 views)
2014-11-22 12:13:56

xFryIx (75 views)
2014-11-13 12:34:49

digdugdiggy (52 views)
2014-11-12 21:11:50
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!