Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (768)
Games in Android Showcase (230)
games submitted by our members
Games in WIP (854)
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  
  Why require context?  (Read 1780 times)
0 Members and 1 Guest are viewing this topic.
Offline dolachin

Senior Newbie




Java games rock!


« Posted 2003-09-04 16:11:38 »

Hi,

My life has taken me from OpenGL to Java3D and now to Jogl. And I have this question.

The way I've been organizing my code is by letting each object build itself and then sticking it into varous contexts. But with Jogl this seems not possible since any routine that does the building needs to have an instance of the GL class. This causes a couple "problems".

1. I need to build each object several times depending on the context.
2. I can't hide implementation (that fact that I'm using Jogl) since all of my routines have GLDrawable as an argument, and I have always been taught to separate logic from implementation.

Any thoughts?

Dola
Offline Orangy Tang

JGO Kernel


Medals: 57
Projects: 11


Monkey for a head


« Reply #1 - Posted 2003-09-04 19:10:07 »

This is always a tricky one, and i've been tinkering with various methods for a while now. You're trying to decouple your rendering and game logic, yes?

First off, the standard method nicked from normal J2D rendering is some kind of .paint(Graphics) method, which works nice since you can wrap up animation etc. in its own class and just have it display its current frame in the paint method. While this is slightly possible in a OpenGL driven game, its not even close to efficiant, and as soon as you start on anything more complicated you end up tearing your hair out with GL state problems..

You end up having to take your abstraction to a higher level - instead of your player/enemy/whatever game objects having a draw method, let these hold on to some kind of Sprite or Mesh class (with whatever material/texture/shader set of state that you need). Then these Mesh objects are held by some kind of renderer object which is in charge of drawing them all. Add some sort of camera object and you've got everything you need to draw a frame.

If you look at that again, you'll realise that you've effectivly created your own simple scene graph - a scene consisting of Meshes and Materials, in some sort of collection along with the camera. Your renderer deals with the low level details of turning this abstract representation into an actual image on screen.

This leaves your renderer is free to do all the funky stuff it needs like state sorting on Materials, view culling, building geometry lists from Mesh objects etc. and the rest of your app just has to poke objects into a scene graph and not have to worry about it Grin

Hope that gives you some ideas at least Smiley

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline dolachin

Senior Newbie




Java games rock!


« Reply #2 - Posted 2003-09-05 18:22:43 »

Thank you very much for the reply. WHat you are saying makes sense.

But is my conclusion correct that if I want to have, say,  two views of the same object, I will need two display lists?

Thanks again,

Dola
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline albanc

Senior Newbie





« Reply #3 - Posted 2003-09-06 06:45:48 »

JoGL now implements shared display lists between GLContexts so you don't need to create 2 lists for the same object if you run 2 GLContexts.
This is a recent feature and you need to get the latest official binary release (september 5) for it.
However, I think you'll still have to set perspective and lighting independantly for each GLContext.
Pages: [1]
  ignore  |  Print  
 
 

 
EgonOlsen (1339 views)
2018-06-10 19:43:48

EgonOlsen (1229 views)
2018-06-10 19:43:44

EgonOlsen (939 views)
2018-06-10 19:43:20

DesertCoockie (1380 views)
2018-05-13 18:23:11

nelsongames (1112 views)
2018-04-24 18:15:36

nelsongames (1374 views)
2018-04-24 18:14:32

ivj94 (2119 views)
2018-03-24 14:47:39

ivj94 (1268 views)
2018-03-24 14:46:31

ivj94 (2285 views)
2018-03-24 14:43:53

Solater (807 views)
2018-03-17 05:04:08
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46
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!