canvas.invoke(false, new GLRunnable() { public boolean run(GLAutoDrawable glad) { canvas.getGL().setSwapInterval(settings.isVSync() ? 1 : 0); canvas.setFocusable(true); canvas.requestFocus(); canvas.setSize(settings.getWidth(), settings.getHeight()); canvas.setIgnoreRepaint(true); canvas.addGLEventListener(this);
@Override public void display(GLAutoDrawable glad) { if (!created.get() && renderer != null){ listener.destroy(); logger.fine("Canvas destroyed."); super.internalDestroy(); return; } int newWidth = Math.max(canvas.getWidth(), 1); int newHeight = Math.max(canvas.getHeight(), 1); if (width != newWidth || height != newHeight) { width = newWidth; height = newHeight; if (listener != null) { listener.reshape(width, height); } } boolean flush = autoFlush.get(); if (flush && !wasAnimating){ animator.start(); wasAnimating = true; }else if (!flush && wasAnimating){ animator.stop(); wasAnimating = false; } listener.update(); renderer.postFrame(); }
glcanvas = new GLCanvas(glcapabilities); glcanvas.addGLEventListener(new GLEventListener()
case GFXCMD_STARTFRAME: case GFXCMD_FLIPBUFFER: c.setCursor(null); break; case GFXCMD_DRAWRECT: case GFXCMD_PREPIMAGETARGETED: if (!cursorHidden) c.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); break; caps2.setDoubleBuffered(true); caps2.setStereo(false); c = new GLCanvas(caps2); c.setAutoSwapBufferMode(true); c.addGLEventListener(this); int windowTitleStyle = 0; try c.setFocusTraversalKeysEnabled(false); f.addWindowListener(new java.awt.event.WindowAdapter() c.addComponentListener(new java.awt.event.ComponentAdapter() c.addKeyListener(this); f.addMouseListener(this); f.addMouseWheelListener(this); c.addMouseListener(this); if (ENABLE_MOUSE_MOTION_EVENTS)
glcanvas = new GLCanvas(glcapabilities); glcanvas.addGLEventListener(new GLEventListener() { glcanvas.addMouseListener(new MouseListener() { glcanvas.addMouseMotionListener(new MouseMotionListener() {
canvas.addGLEventListener(this); frame.add(canvas); frame.setSize(640, 480); frame.setVisible(true); animator.start(); canvas.setFocusable(true); canvas.requestFocus();
public static void main(String[] args) { Frame frame = new Frame("Delaunay Triangulation Example"); frame.setResizable(false); GLCapabilities caps = new GLCapabilities(GLProfile.get("GL2")); caps.setSampleBuffers(true); caps.setNumSamples(8); GLCanvas canvas = new GLCanvas(caps); DelaunayTriangulationExample ex = new DelaunayTriangulationExample(); MouseListener lister = ex; canvas.addGLEventListener(ex); canvas.setPreferredSize(DIMENSION); canvas.addMouseListener(lister); frame.add(canvas); final FPSAnimator animator = new FPSAnimator(canvas, 25); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { new Thread(new Runnable() { public void run() { animator.stop(); System.exit(0); } }).start(); } }); frame.setVisible(true); frame.pack(); animator.start(); }
public GraphCanvas() { super(); glCanvas = new GLCanvas(getCaps()); super.initDrawable(glCanvas); // glCanvas.setMinimumSize(new Dimension(0, 0)); //Fix Canvas resize Issue //Basic init graphComponent = (Component) glCanvas; // graphComponent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); //False lets the components appear on top of the canvas JPopupMenu.setDefaultLightWeightPopupEnabled(false); ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false); }
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"); } }};
/** * Creates a new GltfViewerJogl */ public GltfViewerJogl() { GLProfile profile = getGLProfile(); logger.config("GLProfile: " + profile); GLCapabilities capabilities = new GLCapabilities(profile); capabilities.setNumSamples(2); capabilities.setSampleBuffers(true); glComponent = new GLCanvas(capabilities); glComponent.addGLEventListener(glEventListener); // Without setting the minimum size, the canvas cannot // be resized when it is embedded in a JSplitPane glComponent.setMinimumSize(new Dimension(10, 10)); glContext = new GlContextJogl(); }
/** * 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; }
canvas.addGLEventListener(this);
public Listener() { GLProfile glp = GLProfile.getDefault(); GLCapabilities caps = new GLCapabilities(glp); GLCanvas canvas = new GLCanvas(caps); setSize(300, 300); add(canvas); setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); canvas.addGLEventListener(this); canvas.addKeyListener(this); FPSAnimator animator = new FPSAnimator(canvas, 60); animator.start(); }
private static void addCameraMoveListener(GLCanvas canvas, final CameraMoveListener cameraMoveListener) { canvas.addKeyListener(cameraMoveListener); canvas.addMouseMotionListener(cameraMoveListener); canvas.addMouseListener(cameraMoveListener); }
protected void setCanvasProvider(CanvasProvider canvasProvider) { final GLCanvas oldCanvas = getCanvas(); final GLEventListener glEventListener = getGlEventListener(); if(oldCanvas != null) oldCanvas.removeGLEventListener(glEventListener); this.canvasProvider = canvasProvider; if(canvasProvider != null){ final GLCanvas canvas = canvasProvider.getCanvas(); final GL gl = canvas.getGL(); final Class<? extends GL> desiredClass = getGLClass(); if(! desiredClass.isAssignableFrom(gl.getClass())){ throw new IllegalArgumentException( "CanvasProvider gives a "+gl.getClass().getName()+ " but expected a GL instance of type "+desiredClass.getName());} canvas.addGLEventListener(glEventListener); } }//end setCanvasProvider()
animator.start(); canvas.addGLEventListener(new OpenGLMain()); canvas.requestFocus();
@Override public void run() { canvas.setFocusTraversalKeysEnabled(false); canvas.addGLEventListener(glEventListener); getContentPane().add(canvas); setFocusTraversalKeysEnabled(false); setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);//We'll handle the closing process so we don't lose context during a pending shutdown. setTitle("Terminal Recall"); try{RootWindow.this.setIconImage(ImageIO.read(this.getClass().getResource(ICON_PATH)));} catch(Exception e){e.printStackTrace();} RootWindow.this.setMinimumSize(new Dimension(100,100)); } });
public void init(GLAutoDrawable drawable){ // prevent initializing twice on restart if (!wasInited){ wasInited = true; canvas.requestFocus(); super.internalCreate(); logger.fine("Display created."); renderer.initialize(); listener.initialize(); } }
@Override public V get(){ final GLContext context = canvas.getContext(); if(!super.isDone()) if( context != null ) { if(context.isCurrent()) run(); } else throw new IllegalStateException("GL Context is closed."); return super.get(); } }//end GLFutureTask
@Override public int getHeight() { return glComponent.getHeight(); }