/** * Creates a {@code Component} that is also a {@code GLAutoDrawable}. This is * where all the drawing takes place. The advantage of a {@code GLCanvas} is * that it is faster, but a {@code GLJPanel} is more portable. The component * should also be disabled so that it does not receive events that should be * sent to the {@code drawableComponent}. A {@code GLCanvas} is a heavyweight * component and on some platforms will not pass through mouse events even * though it is disabled. A {@code GLJPanel} supports this better. */ protected GLAutoDrawable createGLComponent(GLCapabilitiesImmutable capabilities, GLContext shareWith) { GLCanvas canvas = new GLCanvas(capabilities); if (shareWith != null) { canvas.setSharedContext(shareWith); } canvas.setEnabled(false); chosenCapabilities = (GLCapabilitiesImmutable) capabilities.cloneMutable(); return canvas; }
/** * Creates a {@code Component} that is also a {@code GLAutoDrawable}. This is * where all the drawing takes place. The advantage of a {@code GLCanvas} is * that it is faster, but a {@code GLJPanel} is more portable. The component * should also be disabled so that it does not receive events that should be * sent to the {@code drawableComponent}. A {@code GLCanvas} is a heavyweight * component and on some platforms will not pass through mouse events even * though it is disabled. A {@code GLJPanel} supports this better. */ protected GLAutoDrawable createGLComponent(GLCapabilitiesImmutable capabilities, GLContext shareWith) { GLCanvas canvas = new GLCanvas(capabilities); if (shareWith != null) { canvas.setSharedContext(shareWith); } canvas.setEnabled(false); chosenCapabilities = (GLCapabilitiesImmutable) capabilities.cloneMutable(); return canvas; }
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 { canvas.setSize(1, 1); // or we do not get a GLContext needInitialResize = true; } getContentPane().add(canvas); canvas.setVisible(true); if (wasErase != null) { System.setProperty("sun.awt.noerasebackground", wasErase); } else { System.clearProperty("sun.awt.noerasebackground"); } }};