Login  Register

Re: Simple example with NEWT but without animator

Posted by elect on Nov 11, 2013; 3:12pm
URL: https://forum.jogamp.org/Simple-example-with-NEWT-but-without-animator-tp4030571p4030579.html

gouessej wrote
Hi

If you don't use an animator, you'll have to call display() by yourself which is exactly what an animator does. Therefore, I advise you to use an animator.

You can add some listeners into the GLWindow to get user's input.
I guess there are 2 ways of doing this, a gl-centric, where the class extending the glEventListener will execute everything, in that case we need an animator.

Or, we use a modulized approach, where the main program doent know what lie in the renderer, it just call the render method, offer by the renderer...

Something like this

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package core;

/**
 *
 * @author gbarbieri
 */
public class FrozenBubble implements Runnable{
   
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
       
        FrozenBubble frozenBubble = new FrozenBubble();
       
        new Thread(frozenBubble).start();
    }
   
    private Rendering rendering;
    private boolean running;
   
    public FrozenBubble(){
       
        rendering = new Rendering();
       
        running = true;
    }

    @Override
    public void run() {
       
        while(running){            
           
            rendering.render();
        }
    }
}



Where render() is nothing else than

    public void render(){
       
        glWindow.display();
    }


What do you think?

If this is one way of doing this right, is it also right that when I instantiate the rendering, it fires automatically, init(), reshape() and display()?

Theoretically, shouldn't it call just the init()?