@Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { GL2 gl = drawable.getGL().getGL2(); viewFrustum.setRight(canvas.getDIPWidth()); viewFrustum.setBottom(canvas.getDIPHeight()); gl.glViewport(x, y, width, height); gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION); gl.glLoadIdentity(); viewFrustum.setProjectionMatrix(gl); relayout(); }
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(); }