public VisualizerWindow(WindowSettings ws) { this.setPreferredSize(new Dimension(ws.width, ws.height)); this.setLocation(ws.xLocation, ws.yLocation); // Create the OpenGL rendering canvas this.canvas = new VisualizerCanvas(); canvas.setPreferredSize(new Dimension(ws.width, ws.height)); canvas.setLocation(ws.xLocation, ws.yLocation); // Create a animator that drives canvas' display() at the specified FPS. this.animator = new FPSAnimator(canvas, FPS, true); // Create the top-level container final JFrame frame = this; // Swing's JFrame or AWT's Frame frame.getContentPane().add(canvas); // Manage pausing and resuming the animator when it doesn't need to run. frame.addWindowListener(this); frame.setTitle(TITLE); frame.pack(); frame.setVisible(true); animator.start(); // start the animation loop }
public VisualizerPanel(BackendAPI backend) { super(new BorderLayout()); if (backend != null) { backend.addControllerListener(this); backend.addUGSEventListener(this); } // Create the OpenGL rendering canvas this.canvas = new VisualizerCanvas(); // Create a animator that drives canvas' display() at the specified FPS. FPSAnimator animator = new FPSAnimator(canvas, FPS, true); animator.start(); // start the animation loop initComponents(); }
fpsAnimator.start();
fpsAnimator.start();
public void startThread() { if (animator != null) { animator.start(); } }
public void start() { animator.start(); }
public Listener() { GLProfile glp = GLProfile.getDefault(); GLCapabilities caps = new GLCapabilities(glp); GLCanvas canvas = new GLCanvas(caps); setSize(300, 300); add(canvas); setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); canvas.addGLEventListener(this); canvas.addKeyListener(this); FPSAnimator animator = new FPSAnimator(canvas, 60); animator.start(); }
@Override public void init(JOGLCanvas3D canvas) { canvas.addGLEventListener(this); animator = new FPSAnimator(canvas, FPS, true); animator.start(); // start the animation loop }
private void scaleAnim(float initV, float v) { if (isAnimationEnabled()) { System.out.println("animating: " + isAnimationEnabled()); if (!animator.isAnimating()) { animator.start(); } fromScale = initV; scale = initV; toScale = v; deltaScale = (toScale - fromScale) / 15f; } else { System.out.println("not animating"); scale = v; } }
private void perspectiveAnim(float v) { if (isAnimationEnabled()) { if (!animator.isAnimating()) { animator.start(); } fromPerspective = perspective; toPerspective = v; deltaPerspective = (toPerspective - fromPerspective) / 15f; } else { perspective = v; } }
private void zoomAnim(float initV, float v) { if (isAnimationEnabled()) { if (!animator.isAnimating()) { animator.start(); } fromZoom = initV; zoom = initV; toZoom = v; deltaZoom = (toZoom - fromZoom) / 20f; } else { zoom = v; } }
public void start() { mAnimator = new FPSAnimator(this.getGLAutoDrawable(), mFramesPerSecond); mAnimator.setUpdateFPSFrames(60, null); mAnimator.start(); while (!mAnimator.isAnimating()) Thread.yield(); }
public static void main( String[] args ) throws Exception { final NewtSwingGlimpseCanvas canvas = new NewtSwingGlimpseCanvas( ); GlimpseLayout plot = buildPlot( canvas ); canvas.addLayout( plot ); canvas.setLookAndFeel( new SwingLookAndFeel( ) ); // attach a repaint manager which repaints the canvas in a loop new FPSAnimator( canvas.getGLDrawable( ), 120 ).start( ); final JFrame frame = new JFrame( "Glimpse Example (Swing)" ); frame.addWindowListener( new WindowAdapter( ) { @Override public void windowClosing( WindowEvent e ) { canvas.disposeAttached( ); } } ); frame.add( canvas ); frame.pack( ); frame.setSize( 800, 800 ); frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); frame.setVisible( true ); return; }
public void createAndShowGUI() { // Create and set up the window. mainFrame = new JFrame(Translator.get("TitlePrefix")); mainFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); mainFrame.addWindowListener(this); mainFrame.setJMenuBar(createMenuBar()); mainFrame.setContentPane(createContentPane()); adjustWindowSize(); mainFrame.setVisible(true); drawPanel.zoomToFitPaper(); // add the drag & drop support mainFrame.setTransferHandler(myTransferHandler); // start animation system animator = new FPSAnimator(30); animator.add(drawPanel); animator.start(); }
Frame frame = new Frame("test"); GLCanvas canvas; FPSAnimator animator; GLCapabilities caps = new GLCapabilities(); caps.setDoubleBuffered(true); caps.setHardwareAccelerated(true); canvas = new GLCanvas(caps); animator = new FPSAnimator(canvas, 60); canvas.addGLEventListener(new Renderer()); frame.add(canvas); frame.setSize(600, 600); animator.start();
private void centerAnim(Vector3f fromCenter, Vector3f toCenter) { if (isAnimationEnabled()) { if (!animator.isAnimating()) { animator.start(); } this.fromCenter = fromCenter; this.center = fromCenter; this.toCenter = toCenter; deltaCenter = new Vector3f(toCenter).sub(fromCenter).div(15f); } else { this.center = toCenter; } }
public void setFrameRate(float fps) { if (fps < 1) { PGraphics.showWarning( "The OpenGL renderer cannot have a frame rate lower than 1.\n" + "Your sketch will run at 1 frame per second."); fps = 1; } else if (fps > 1000) { PGraphics.showWarning( "The OpenGL renderer cannot have a frame rate higher than 1000.\n" + "Your sketch will run at 1000 frames per second."); fps = 1000; } if (animator != null) { animator.stop(); animator.setFPS((int)fps); pgl.setFps(fps); animator.start(); } }
private void debug(final GL gl) { dbgFrame = new Frame("TextRenderer Debug Output"); final GLCanvas dbgCanvas = new GLCanvas(new GLCapabilities(gl.getGLProfile())); dbgCanvas.setSharedContext(GLContext.getCurrent()); dbgCanvas.addGLEventListener(new DebugListener(gl, dbgFrame)); dbgFrame.add(dbgCanvas); final FPSAnimator anim = new FPSAnimator(dbgCanvas, 10); dbgFrame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(final 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() { @Override public void run() { anim.stop(); } }).start(); } }); dbgFrame.setSize(kSize, kSize); dbgFrame.setVisible(true); anim.start(); debugged = true; }
animator.add( canvas2.getGLDrawable( ) ); animator.add( canvas.getGLDrawable( ) ); animator.start( );
public static void main(String[] args) { Frame frame = new Frame("Delaunay Triangulation Example"); frame.setResizable(false); GLCapabilities caps = new GLCapabilities(GLProfile.get("GL2")); caps.setSampleBuffers(true); caps.setNumSamples(8); GLCanvas canvas = new GLCanvas(caps); DelaunayTriangulationExample ex = new DelaunayTriangulationExample(); MouseListener lister = ex; canvas.addGLEventListener(ex); canvas.setPreferredSize(DIMENSION); canvas.addMouseListener(lister); frame.add(canvas); final FPSAnimator animator = new FPSAnimator(canvas, 25); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { new Thread(new Runnable() { public void run() { animator.stop(); System.exit(0); } }).start(); } }); frame.setVisible(true); frame.pack(); animator.start(); }