Search in sources :

Example 1 with GLCanvas

use of com.jogamp.opengl.awt.GLCanvas in project Universal-G-Code-Sender by winder.

the class JOGLGearsDemo method main.

public static void main(String[] args) {
    Frame frame = new Frame("Gear Demo");
    GLCanvas canvas = new GLCanvas();
    canvas.addGLEventListener(new JOGLGearsDemo());
    frame.add(canvas);
    frame.setSize(300, 300);
    final Animator animator = new Animator(canvas);
    frame.addWindowListener(new WindowAdapter() {

        public void windowClosing(WindowEvent e) {
            // Run this on another thread than the AWT event queue to
            // make sure the call to Animator.stop() completes before
            // exiting
            new Thread(new Runnable() {

                public void run() {
                    animator.stop();
                    System.exit(0);
                }
            }).start();
        }
    });
    frame.show();
    animator.start();
}
Also used : GLCanvas(com.jogamp.opengl.awt.GLCanvas) Frame(java.awt.Frame) Animator(com.jogamp.opengl.util.Animator)

Example 2 with GLCanvas

use of com.jogamp.opengl.awt.GLCanvas in project javacv by bytedeco.

the class GLCanvasFrame method init.

private void init(final boolean fullScreen, final GLCapabilitiesImmutable caps, final GLContext shareWith) {
    Runnable r = new Runnable() {

        public void run() {
            String wasErase = System.setProperty("sun.awt.noerasebackground", "true");
            canvas = new GLCanvas(caps);
            if (shareWith != null) {
                ((GLCanvas) canvas).setSharedContext(shareWith);
            }
            ((GLCanvas) canvas).addGLEventListener(eventListener);
            if (fullScreen) {
                canvas.setSize(getSize());
                needInitialResize = false;
            } else {
                // or we do not get a GLContext
                canvas.setSize(1, 1);
                needInitialResize = true;
            }
            getContentPane().add(canvas);
            canvas.setVisible(true);
            if (wasErase != null) {
                System.setProperty("sun.awt.noerasebackground", wasErase);
            } else {
                System.clearProperty("sun.awt.noerasebackground");
            }
        }
    };
    if (EventQueue.isDispatchThread()) {
        r.run();
    } else {
        try {
            EventQueue.invokeAndWait(r);
        } catch (java.lang.Exception ex) {
        }
    }
}
Also used : GLCanvas(com.jogamp.opengl.awt.GLCanvas)

Example 3 with GLCanvas

use of com.jogamp.opengl.awt.GLCanvas in project jmonkeyengine by jMonkeyEngine.

the class JoglAbstractDisplay method initGLCanvas.

protected void initGLCanvas() {
    device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    GLCapabilities caps;
    if (settings.getRenderer().equals(AppSettings.JOGL_OPENGL_FORWARD_COMPATIBLE)) {
        caps = new GLCapabilities(GLProfile.getMaxProgrammable(true));
    } else {
        caps = new GLCapabilities(GLProfile.getMaxFixedFunc(true));
    }
    caps.setHardwareAccelerated(true);
    caps.setDoubleBuffered(true);
    caps.setStencilBits(settings.getStencilBits());
    caps.setDepthBits(settings.getDepthBits());
    if (settings.getSamples() > 1) {
        caps.setSampleBuffers(true);
        caps.setNumSamples(settings.getSamples());
    }
    canvas = new GLCanvas(caps) {

        @Override
        public void addNotify() {
            super.addNotify();
            onCanvasAdded();
        }

        @Override
        public void removeNotify() {
            onCanvasRemoved();
            super.removeNotify();
        }
    };
    canvas.invoke(false, new GLRunnable() {

        public boolean run(GLAutoDrawable glad) {
            canvas.getGL().setSwapInterval(settings.isVSync() ? 1 : 0);
            return true;
        }
    });
    canvas.setFocusable(true);
    canvas.requestFocus();
    canvas.setSize(settings.getWidth(), settings.getHeight());
    canvas.setIgnoreRepaint(true);
    canvas.addGLEventListener(this);
    //FIXME not sure it is the best place to do that
    renderable.set(true);
}
Also used : GLCanvas(com.jogamp.opengl.awt.GLCanvas) GLAutoDrawable(com.jogamp.opengl.GLAutoDrawable) GLCapabilities(com.jogamp.opengl.GLCapabilities) GLRunnable(com.jogamp.opengl.GLRunnable)

Example 4 with GLCanvas

use of com.jogamp.opengl.awt.GLCanvas in project artisynth_core by artisynth.

the class GLCanvasTest method main.

public static void main(String[] args) {
    GLProfile glp = GLProfile.getDefault();
    GLCapabilities caps = new GLCapabilities(glp);
    GLCanvas canvas = new GLCanvas(caps);
    final Frame frame = new Frame("AWT Window Test");
    frame.setSize(300, 300);
    frame.setLocation(30, 30);
    frame.add(canvas);
    frame.setVisible(true);
    frame.addWindowListener(new WindowAdapter() {

        public void windowClosing(WindowEvent e) {
            frame.dispose();
            System.exit(0);
        }
    });
    canvas.addGLEventListener(new GLCanvasTest());
    FPSAnimator animator = new FPSAnimator(canvas, 60);
    animator.start();
}
Also used : FPSAnimator(com.jogamp.opengl.util.FPSAnimator) GLCanvas(com.jogamp.opengl.awt.GLCanvas) GLCapabilities(com.jogamp.opengl.GLCapabilities) Frame(java.awt.Frame) WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter) GLProfile(com.jogamp.opengl.GLProfile)

Example 5 with GLCanvas

use of com.jogamp.opengl.awt.GLCanvas in project artisynth_core by artisynth.

the class GLSharedResources method createCanvas.

/**
 * Creates a canvas with the same capabilities and shared context
 * as other viewers using this set of resources.  This ensures
 * that the sharing of resources is properly initialized.
 * @return the created canvas
 */
public synchronized GLCanvas createCanvas() {
    maybeCreateMaster();
    GLCanvas canvas = new GLCanvas(glCapabilities);
    canvas.setSharedAutoDrawable(masterDrawable);
    return canvas;
}
Also used : GLCanvas(com.jogamp.opengl.awt.GLCanvas)

Aggregations

GLCanvas (com.jogamp.opengl.awt.GLCanvas)6 GLCapabilities (com.jogamp.opengl.GLCapabilities)3 Frame (java.awt.Frame)2 GLAutoDrawable (com.jogamp.opengl.GLAutoDrawable)1 GLProfile (com.jogamp.opengl.GLProfile)1 GLRunnable (com.jogamp.opengl.GLRunnable)1 Animator (com.jogamp.opengl.util.Animator)1 FPSAnimator (com.jogamp.opengl.util.FPSAnimator)1 WindowAdapter (java.awt.event.WindowAdapter)1 WindowEvent (java.awt.event.WindowEvent)1