Simple example with NEWT but without animator
Posted by elect on Nov 11, 2013; 10:56am
URL: https://forum.jogamp.org/Simple-example-with-NEWT-but-without-animator-tp4030571.html
Hi,
playing around with the nifty-gui, I wanted to put all the theory in a practical example and see how it performs/looks like..
I choose something simple, the frozen bubble game
I am trying to set up a basic scenario, I dont want to have an animator, I want to update the screen on explicit command
So far this is the main class
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package core;
/**
*
* @author gbarbieri
*/
public class FrozenBubble {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Rendering rendering = new Rendering();
}
}
And the rendering class
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package core;
import com.jogamp.newt.opengl.GLWindow;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLProfile;
/**
*
* @author gbarbieri
*/
public class Rendering implements GLEventListener{
private GLWindow glWindow;
public Rendering() {
initGL();
}
private void initGL() {
GLProfile profile = GLProfile.get(GLProfile.GL3);
GLCapabilities capabilities = new GLCapabilities(profile);
glWindow = GLWindow.create(capabilities);
glWindow.setAutoSwapBufferMode(true);
glWindow.setSize(800, 600);
glWindow.addGLEventListener(this);
glWindow.setTitle("Frozen Bubble");
glWindow.setVisible(true);
}
@Override
public void init(GLAutoDrawable drawable) {
System.out.println("init");
}
@Override
public void dispose(GLAutoDrawable drawable) {
System.out.println("dispose");
}
@Override
public void display(GLAutoDrawable drawable) {
System.out.println("display");
}
@Override
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
System.out.println("reshape");
}
}
The program shows the windows and shutdowns, obviously
The called methods are init, display and dispose
How can I set up in order the system to wait (on some user actions through the nifty-gui?)