Search in sources :

Example 6 with FPSAnimator

use of com.jogamp.opengl.util.FPSAnimator in project tdme by andreasdr.

the class PhysicsTest2 method main.

/**
	 * Main
	 * @param args
	 */
public static void main(String[] args) {
    Logger.getLogger("").setLevel(Level.WARNING);
    // create GL canvas
    GLProfile glp = Engine.getProfile();
    GLCapabilities caps = new GLCapabilities(glp);
    // create GL window
    GLWindow glWindow = GLWindow.create(caps);
    glWindow.setTitle("PhysicsTest2");
    // animator
    FPSAnimator animator = new FPSAnimator(glWindow, 60);
    // tdme level editor
    PhysicsTest2 physicsTest2 = new PhysicsTest2();
    // GL Window
    glWindow.addGLEventListener(physicsTest2);
    glWindow.setSize(800, 600);
    glWindow.setVisible(true);
    glWindow.addKeyListener(physicsTest2);
    glWindow.addMouseListener(physicsTest2);
    glWindow.addWindowListener(physicsTest2);
    // start animator
    animator.setUpdateFPSFrames(3, null);
    animator.start();
}
Also used : FPSAnimator(com.jogamp.opengl.util.FPSAnimator) GLCapabilities(com.jogamp.opengl.GLCapabilities) GLWindow(com.jogamp.newt.opengl.GLWindow) GLProfile(com.jogamp.opengl.GLProfile)

Example 7 with FPSAnimator

use of com.jogamp.opengl.util.FPSAnimator in project tdme by andreasdr.

the class TDMELevelEditor method main.

/**
	 * @param args
	 */
public static void main(String[] args) {
    String modelFileName = null;
    //
    System.out.println("TDMELevelEditor " + VERSION);
    System.out.println("Programmed 2014,...,2017 by Andreas Drewke, drewke.net.");
    System.out.println();
    // no nifty logging
    Logger.getLogger("").setLevel(Level.SEVERE);
    // create GL caps
    GLProfile glp = Engine.getProfile();
    GLCapabilities caps = new GLCapabilities(glp);
    System.out.println(glp);
    System.out.println(caps);
    // create GL window
    GLWindow glWindow = GLWindow.create(caps);
    glWindow.setTitle("TDMELevelEditor " + VERSION);
    // animator
    FPSAnimator animator = new FPSAnimator(glWindow, 60);
    // tdme level editor
    TDMELevelEditor tdmeLevelEditor = new TDMELevelEditor(glWindow, animator, modelFileName);
    // GL Window
    glWindow.addWindowListener(tdmeLevelEditor);
    glWindow.addGLEventListener(tdmeLevelEditor);
    glWindow.setSize(1024, 600);
    glWindow.setVisible(true);
    // start animator
    animator.start();
}
Also used : FPSAnimator(com.jogamp.opengl.util.FPSAnimator) GLCapabilities(com.jogamp.opengl.GLCapabilities) GLWindow(com.jogamp.newt.opengl.GLWindow) GLProfile(com.jogamp.opengl.GLProfile)

Example 8 with FPSAnimator

use of com.jogamp.opengl.util.FPSAnimator in project processing by processing.

the class PSurfaceJOGL method initAnimator.

protected void initAnimator() {
    if (PApplet.platform == PConstants.WINDOWS) {
        // Force Windows to keep timer resolution high by
        // sleeping for time which is not a multiple of 10 ms.
        // See section "Clocks and Timers on Windows":
        //   https://blogs.oracle.com/dholmes/entry/inside_the_hotspot_vm_clocks
        Thread highResTimerThread = new Thread(() -> {
            try {
                Thread.sleep(Long.MAX_VALUE);
            } catch (InterruptedException ignore) {
            }
        }, "HighResTimerThread");
        highResTimerThread.setDaemon(true);
        highResTimerThread.start();
    }
    animator = new FPSAnimator(window, 60);
    drawException = null;
    animator.setUncaughtExceptionHandler(new GLAnimatorControl.UncaughtExceptionHandler() {

        @Override
        public void uncaughtException(final GLAnimatorControl animator, final GLAutoDrawable drawable, final Throwable cause) {
            synchronized (drawExceptionMutex) {
                drawException = cause;
                drawExceptionMutex.notify();
            }
        }
    });
    drawExceptionHandler = new Thread(new Runnable() {

        public void run() {
            synchronized (drawExceptionMutex) {
                try {
                    while (drawException == null) {
                        drawExceptionMutex.wait();
                    }
                    // System.err.println("Caught exception: " + drawException.getMessage());
                    if (drawException != null) {
                        Throwable cause = drawException.getCause();
                        if (cause instanceof ThreadDeath) {
                        // System.out.println("caught ThreadDeath");
                        // throw (ThreadDeath)cause;
                        } else if (cause instanceof RuntimeException) {
                            throw (RuntimeException) cause;
                        } else if (cause instanceof UnsatisfiedLinkError) {
                            throw new UnsatisfiedLinkError(cause.getMessage());
                        } else if (cause == null) {
                            throw new RuntimeException(drawException.getMessage());
                        } else {
                            throw new RuntimeException(cause);
                        }
                    }
                } catch (InterruptedException e) {
                    return;
                }
            }
        }
    });
    drawExceptionHandler.start();
}
Also used : FPSAnimator(com.jogamp.opengl.util.FPSAnimator) GLAutoDrawable(com.jogamp.opengl.GLAutoDrawable) GLAnimatorControl(com.jogamp.opengl.GLAnimatorControl)

Example 9 with FPSAnimator

use of com.jogamp.opengl.util.FPSAnimator in project tdme by andreasdr.

the class TDMEParticleSystem method main.

/**
	 * @param args
	 */
public static void main(String[] args) {
    //
    System.out.println("TDMEParticleSystem " + VERSION);
    System.out.println("Programmed 2017 by Andreas Drewke, drewke.net.");
    System.out.println();
    // no nifty logging
    Logger.getLogger("").setLevel(Level.SEVERE);
    // create GL caps
    GLProfile glp = Engine.getProfile();
    GLCapabilities caps = new GLCapabilities(glp);
    System.out.println(glp);
    System.out.println(caps);
    // create GL window
    GLWindow glWindow = GLWindow.create(caps);
    glWindow.setTitle("TDMEParticleSystem " + VERSION);
    // animator
    FPSAnimator animator = new FPSAnimator(glWindow, 60);
    // tdme particle system
    TDMEParticleSystem tdmeLevelEditor = new TDMEParticleSystem(glWindow, animator);
    // GL Window
    glWindow.addWindowListener(tdmeLevelEditor);
    glWindow.addGLEventListener(tdmeLevelEditor);
    glWindow.setSize(800, 600);
    glWindow.setVisible(true);
    // start animator
    animator.start();
}
Also used : FPSAnimator(com.jogamp.opengl.util.FPSAnimator) GLCapabilities(com.jogamp.opengl.GLCapabilities) GLWindow(com.jogamp.newt.opengl.GLWindow) GLProfile(com.jogamp.opengl.GLProfile)

Example 10 with FPSAnimator

use of com.jogamp.opengl.util.FPSAnimator in project tdme by andreasdr.

the class TDMEViewer method main.

/**
	 * @param args
	 */
public static void main(String[] args) {
    String modelFileName = null;
    //
    System.out.println("TDMEViewer " + VERSION);
    System.out.println("Programmed 2014,...,2017 by Andreas Drewke, drewke.net.");
    System.out.println();
    // no nifty logging
    Logger.getLogger("").setLevel(Level.SEVERE);
    // create GL caps
    GLProfile glp = Engine.getProfile();
    GLCapabilities caps = new GLCapabilities(glp);
    System.out.println(glp);
    System.out.println(caps);
    // create GL window
    GLWindow glWindow = GLWindow.create(caps);
    glWindow.setTitle("TDMEViewer " + VERSION);
    // animator
    FPSAnimator animator = new FPSAnimator(glWindow, 60);
    // tdme level editor
    TDMEViewer tdmeLevelEditor = new TDMEViewer(glWindow, animator, modelFileName);
    // GL Window
    glWindow.addWindowListener(tdmeLevelEditor);
    glWindow.addGLEventListener(tdmeLevelEditor);
    glWindow.setSize(800, 600);
    glWindow.setVisible(true);
    // start animator
    animator.start();
}
Also used : FPSAnimator(com.jogamp.opengl.util.FPSAnimator) GLCapabilities(com.jogamp.opengl.GLCapabilities) GLWindow(com.jogamp.newt.opengl.GLWindow) GLProfile(com.jogamp.opengl.GLProfile)

Aggregations

FPSAnimator (com.jogamp.opengl.util.FPSAnimator)11 GLWindow (com.jogamp.newt.opengl.GLWindow)8 GLCapabilities (com.jogamp.opengl.GLCapabilities)8 GLProfile (com.jogamp.opengl.GLProfile)8 Animator (com.jogamp.opengl.util.Animator)2 GLAnimatorControl (com.jogamp.opengl.GLAnimatorControl)1 GLAutoDrawable (com.jogamp.opengl.GLAutoDrawable)1