Exemplo n.º 1
0
  public GLSandBox(Composite parent, GLElement root, GLPadding padding) {
    // use use my own library loader
    System.setProperty("jnlp.launcher.class", SandBoxLibraryLoader.class.getCanonicalName());

    IGLCanvasFactory canvasFactory = new SWTGLCanvasFactory();

    GLCapabilities caps = createCapabilities();

    this.canvas = canvasFactory.create(caps, parent);
    canvas.asComposite().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    this.swtLayer = new SWTLayer(canvas);

    this.padding = padding;
    canvas.addGLEventListener(this);

    this.animator = new MyAnimator(MyPreferences.getFPS());

    this.animator.add(canvas.asGLAutoDrawAble());
    canvas.asGLAutoDrawAble().setAutoSwapBufferMode(true);

    // ENABLE to print the fps to System.err
    animator.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err);

    this.canvas.addMouseListener(pickingManager.getListener());
    this.canvas.addKeyListener(
        new IGLKeyListener() {
          @Override
          public void keyReleased(IKeyEvent e) {
            if (e.isKey('p')) {
              renderPick = !renderPick;
            }
          }

          @Override
          public void keyPressed(IKeyEvent e) {}
        });
    this.root = new WindowGLElement(root, canvas);

    animator.start();
  }
Exemplo n.º 2
0
 public void shutdown() {
   animator.shutdown();
 }