Login  Register

Re: JOGL Questions - Guidance on creating Scene class

Posted by glangho on Oct 30, 2015; 12:51am
URL: https://forum.jogamp.org/JOGL-Questions-Guidance-on-creating-Scene-class-tp4035659p4035672.html

elect wrote
For the shaders, I suggest you to use the jogl utility class, it makes things much easier and less verbose. For textures, save the int id into an integer array and use an enum to handle it. Something like here
This is quite clever. I like it.

My initial thought was to create a bunch of Scenes for each state and each having their own systems for input handling, rendering, ai, phyics, etc (I'm using an Entity Component System design so I have many systems). If I'm understanding things correctly, the more professional approach is to have one set of systems with logic to handle different states. So for example, my input system would have one set of controls for BattleState while another set of controls for MenuState all in the same object. It looks like the concept of a SceneNode (part of a SceneGraph) could be used to organize which entities need processing based on the state as well.

Am I close to understanding or completely off?

One last questionon GLAutoDrawable. You mentioned to only the GL object locally, not pass it or the GLAutoDrawable down on the stack, and instead use GLContext.getCurrent().getGL(). If you want to offload rendering to a different class from your GLEventListener implementation like this:

    ...
    public void display(GLAutoDrawable drawable){
        renderSystem.draw();
    }
    ....
The RenderSystem draw() method would then look like this, correct?

    ...
    public void draw(){
        GLContext.getCurrent().getGL();
        // draw stuff
    }
The more I think about this post, the less I feel a need to have a separate class for rendering. Maybe it just makes more sense to do everything in the GLEventListener display method using GLAutoDrawable. It certainly sounds safer. Is this "professionally / commercially" acceptable?

I wanted to thank you both for your time. This has really been enlightening for me.