コード例 #1
0
  private void initPanels(GLCapabilities caps) {
    // create panels to draw on
    myPanels = new GLJPanel[3];
    myPanels[0] = new GLJPanel(caps);
    myPanels[1] = new GLJPanel(caps);
    myPanels[2] = new GLJPanel(caps);

    setLayout(new GridLayout(1, 3));
    add(myPanels[0]);
    add(myPanels[1]);
    add(myPanels[2]);

    // The cross section view
    CrossSectionView view0 = new CrossSectionView(this);
    myPanels[0].addGLEventListener(view0);

    // the spine view
    SpineView view1 = new SpineView(this);
    myPanels[1].addGLEventListener(view1);
    myPanels[1].addMouseMotionListener(view1);

    // the extrusion view
    ExtrusionView view2 = new ExtrusionView(this);
    myPanels[2].addGLEventListener(view2);
    myPanels[2].addMouseMotionListener(view2);

    FPSAnimator animator = new FPSAnimator(60);
    animator.add(myPanels[0]);
    animator.add(myPanels[1]);
    animator.add(myPanels[2]);
    animator.start();
  }
コード例 #2
0
ファイル: GLUtils.java プロジェクト: stacktracer/glimpse
 public static FPSAnimator startFpsAnimator(int fps, GlimpseCanvas... canvases) {
   FPSAnimator animator = new FPSAnimator(fps);
   for (GlimpseCanvas canvas : canvases) {
     animator.add(canvas.getGLDrawable());
   }
   animator.start();
   return animator;
 }
コード例 #3
0
 public FirstStepNewtLast() {
   GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL2));
   GLWindow glWindow = GLWindow.create(caps);
   glWindow.setTitle("First demo (Newt)");
   glWindow.setSize(300, 300);
   glWindow.addWindowListener(
       new WindowAdapter() {
         @Override
         public void windowDestroyed(WindowEvent arg0) {
           System.exit(0);
         }
       });
   glWindow.addGLEventListener(this);
   FPSAnimator animator = new FPSAnimator(10); // (2)
   animator.add(glWindow);
   animator.start();
   glWindow.setVisible(true);
 }
コード例 #4
0
 public CubeSample6InvalidNormal() {
   GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL2));
   glu = new GLU();
   GLWindow glWindow = GLWindow.create(caps);
   glWindow.setTitle("Cube demo (Newt)");
   glWindow.setSize(300, 300);
   glWindow.addWindowListener(
       new WindowAdapter() {
         @Override
         public void windowDestroyed(WindowEvent arg0) {
           System.exit(0);
         }
       });
   glWindow.addGLEventListener(this);
   glWindow.addMouseListener(this);
   animator = new FPSAnimator(30);
   animator.add(glWindow);
   animator.start();
   animator.pause();
   glWindow.setVisible(true);
 }
コード例 #5
0
  private void initPanels(GLCapabilities caps) {
    // create a panel to draw on
    myPanels = new GLJPanel[1];
    myPanels[0] = new GLJPanel(caps);

    // create a panel of sliders
    JPanel panel = initSliders();

    setLayout(new GridLayout(1, 2));
    add(myPanels[0]);
    add(panel);

    TextureView view1 = new TextureView(this);
    myPanels[0].addGLEventListener(view1);
    myPanels[0].addMouseMotionListener(view1);
    myPanels[0].addKeyListener(this);
    myPanels[0].setFocusable(true);

    FPSAnimator animator = new FPSAnimator(60);
    animator.add(myPanels[0]);
    animator.start();
  }
コード例 #6
0
ファイル: Engine.java プロジェクト: JacobNorlin/TRIPPN-BALLS
  public Engine(GLCanvas canvas) {
    frame = new Frame("TRIPPIN' BALLS");
    frame.add(canvas);
    frame.setSize(600, 600);
    if (fullscreen) frame.setUndecorated(true);
    frame.setVisible(true);

    if (fullscreen) {
      GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
      ge.getDefaultScreenDevice().setFullScreenWindow(frame);
    }

    input = new Input();
    frame.addWindowListener(input);
    canvas.addKeyListener(input);
    canvas.addMouseListener(input);
    canvas.addMouseWheelListener(input);
    canvas.addFocusListener(input);

    animator = new FPSAnimator(canvas, 60);
    animator.add(canvas);
    animator.start();
    animator.getTotalFrames();
  }
コード例 #7
0
  protected GLJPanel newGLJPanel(
      final JFrame frame,
      final GLCapabilities caps,
      final FPSAnimator animator,
      final SnapshotGLEventListener snap)
      throws AWTException, InterruptedException, InvocationTargetException {
    final GLJPanel glJPanel = new GLJPanel(caps);
    Assert.assertNotNull(glJPanel);
    glJPanel.setSkipGLOrientationVerticalFlip(skipGLOrientationVerticalFlip);
    glJPanel.setMinimumSize(wsize);
    glJPanel.setPreferredSize(wsize);
    glJPanel.setSize(wsize);
    glJPanel.setSurfaceScale(reqSurfacePixelScale);
    {
      final GLEventListener demo = createDemo(caps);
      if (null != demo) {
        glJPanel.addGLEventListener(demo);
      }
    }
    if (null != snap) {
      glJPanel.addGLEventListener(snap);
    }
    glJPanel.addGLEventListener(
        new GLEventListener() {
          @Override
          public void init(final GLAutoDrawable drawable) {}

          @Override
          public void dispose(final GLAutoDrawable drawable) {}

          @Override
          public void display(final GLAutoDrawable drawable) {}

          @Override
          public void reshape(
              final GLAutoDrawable drawable,
              final int x,
              final int y,
              final int width,
              final int height) {
            setTitle(frame, glJPanel, caps);
          }
        });
    setTitle(frame, glJPanel, caps);

    frame.addComponentListener(
        new ComponentListener() {
          @Override
          public void componentResized(final ComponentEvent e) {
            setTitle(frame, glJPanel, caps);
          }

          @Override
          public void componentMoved(final ComponentEvent e) {
            setTitle(frame, glJPanel, caps);
          }

          @Override
          public void componentShown(final ComponentEvent e) {}

          @Override
          public void componentHidden(final ComponentEvent e) {}
        });

    if (SwingUtilities.isEventDispatchThread()) {
      frame.getContentPane().add(glJPanel, BorderLayout.CENTER);
      frame.getContentPane().validate();
      frame.pack();
      frame.setVisible(true);
    } else {
      SwingUtilities.invokeAndWait(
          new Runnable() {
            public void run() {
              frame.getContentPane().add(glJPanel, BorderLayout.CENTER);
              frame.getContentPane().validate();
              frame.pack();
              frame.setVisible(true);
            }
          });
      Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true));
      Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glJPanel, true));

      final float[] minSurfacePixelScale = glJPanel.getMinimumSurfaceScale(new float[2]);
      final float[] maxSurfacePixelScale = glJPanel.getMaximumSurfaceScale(new float[2]);
      final float[] valReqSurfacePixelScale = glJPanel.getRequestedSurfaceScale(new float[2]);
      final float[] hasSurfacePixelScale = glJPanel.getCurrentSurfaceScale(new float[2]);
      System.err.println(
          "HiDPI PixelScale: min "
              + minSurfacePixelScale[0]
              + "x"
              + minSurfacePixelScale[1]
              + ", max "
              + maxSurfacePixelScale[0]
              + "x"
              + maxSurfacePixelScale[1]
              + ", req "
              + reqSurfacePixelScale[0]
              + "x"
              + reqSurfacePixelScale[1]
              + " -> val "
              + valReqSurfacePixelScale[0]
              + "x"
              + valReqSurfacePixelScale[1]
              + " -> has "
              + hasSurfacePixelScale[0]
              + "x"
              + hasSurfacePixelScale[1]);
      setTitle(frame, glJPanel, caps);
    }

    if (null != animator) {
      animator.add(glJPanel);
      animator.setUpdateFPSFrames(60, System.err);
    }
    return glJPanel;
  }