@Override protected GLAutoDrawable createGLComponent(GLCapabilitiesImmutable capabilities, GLContext shareWith) { GLJPanel canvas = new GLJPanel(capabilities); canvas.setEnabled(false); return canvas; }
GLJPanel panel = new GLJPanel(capabilities); panel.setFocusable(true); canvas.setScalableSurface(panel); panel.addGLEventListener(canvas); panel.addMouseListener(canvas); panel.addMouseMotionListener(canvas); panel.addMouseWheelListener(canvas);
public void run() { System.out.println("main:run"); GLCanvas canvas = new GLCanvas(); GLJPanel jpanel = new GLJPanel(); canvas.addGLEventListener(new Guts("GLCanvas")); jpanel.addGLEventListener(new Guts("GLJPanel")); makeFrame(canvas,"JoglDemo: GLCanvas"); makeFrame(jpanel,"JoglDemo: GLJPanel"); } });
public static Component createGLCanvas(OTFVisConfigGroup otfVisConfig) { //turn off HiDPI uiScaling in Windows (issue MATSIM-875) if (System.getProperty("os.name").startsWith("Windows")) { System.setProperty("sun.java2d.uiScale", "1.0"); } GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL2)); if (otfVisConfig.isMapOverlayMode()) { caps.setBackgroundOpaque(false); // A GLJPanel is an OpenGL component which is "more Swing compatible" than a GLCanvas. // The JOGL doc says the tradeoff is that it is slower than a GLCanvas. // We use it if we want to put map tiles behind the agent drawer, because it can be made translucent! GLJPanel glJPanel = new GLJPanel(caps); glJPanel.setOpaque(false); // So that the map shines through return glJPanel; } else { // This is the default JOGL component. JOGL doc recommends using it if you do not need a GLJPanel. return new GLCanvas(caps); } }
/** * clear the panel * * @param gl2 */ private void paintBackground(GL2 gl2) { // Clear The Screen And The Depth Buffer gl2.glClearColor(212.0f / 255.0f, 233.0f / 255.0f, 255.0f / 255.0f, 0.0f); // Special handling for the case where the GLJPanel is translucent // and wants to be composited with other Java 2D content if (GLProfile.isAWTAvailable() && (this instanceof com.jogamp.opengl.awt.GLJPanel) && !((com.jogamp.opengl.awt.GLJPanel) this).isOpaque() && ((com.jogamp.opengl.awt.GLJPanel) this).shouldPreserveColorBufferIfTranslucent()) { gl2.glClear(GL2.GL_DEPTH_BUFFER_BIT); } else { gl2.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT); } }
@Override public void initSpecific() { GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); caps.setStencilBits(1); canvas = new GLJPanel(caps); ((GLJPanel)canvas).addGLEventListener(this); new GOSwingEventConverter(canvas, parent); }