protected void initDrawable(GLAutoDrawable drawable) { this.drawable = drawable; drawable.addGLEventListener(this); }
public void setQueryHandler(OTFQueryControl queryHandler) { this.queryHandler = queryHandler; ((GLAutoDrawable) canvas).addGLEventListener(((GLAutoDrawable) canvas).getGLEventListenerCount()-2, queryHandler); }
private void prepareSideContext() { if (sideContext == null) { GLDrawableFactory factory = canvas.getFactory(); sideContext = factory.createOffscreenAutoDrawable(null, chosenCapabilities, null, 1, 1); sideContext.addGLEventListener(g2dglListener); } Runnable work = new Runnable() { @Override public void run() { sideContext.display(); } }; if (Threading.isOpenGLThread()) { work.run(); } else { Threading.invokeOnOpenGLThread(false, work); } }
/** * Moves the designated {@link GLEventListener} from {@link GLAutoDrawable} <code>src</code> to <code>dest</code>. * If <code>preserveInitState</code> is <code>true</code>, it's initialized state is preserved * and {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape(..)} issued w/ the next {@link GLAutoDrawable#display()} call. * <p> * Note that it is only legal to pass <code>preserveInitState := true</code>, * if the {@link GLContext} of both <code>src</code> and <code>dest</code> are shared, or has itself moved from <code>src</code> to <code>dest</code>. * </p> * <p> * Also note that the caller is encouraged to pause an attached {@link GLAnimatorControl}. * </p> * @param src * @param dest * @param listener * @param preserveInitState */ public static final void moveGLEventListener(final GLAutoDrawable src, final GLAutoDrawable dest, final GLEventListener listener, final boolean preserveInitState) { final boolean initialized = src.getGLEventListenerInitState(listener); if( preserveInitState ) { src.removeGLEventListener(listener); dest.addGLEventListener(listener); if( initialized ) { dest.setGLEventListenerInitState(listener, true); dest.invoke(false, new ReshapeGLEventListener(listener, true)); } } else { src.disposeGLEventListener(listener, true); dest.addGLEventListener(listener); } }
/** * Detaches the given {@link GLAutoDrawable} from this tile renderer. * @see #attachAutoDrawable(GLAutoDrawable) * @see #getAttachedDrawable() */ public final void detachAutoDrawable() { if( null != glad ) { glad.removeGLEventListener(tiledGLEL); final int aSz = listenersInit.length; for(int i=0; i<aSz; i++) { final GLEventListener l = listeners[i]; if( l instanceof TileRendererListener ) { ((TileRendererListener)l).removeTileRendererNotify(this); } glad.addGLEventListener(l); glad.setGLEventListenerInitState(l, listenersInit[i]); } glad.setAutoSwapBufferMode(gladAutoSwapBufferMode); if( DEBUG ) { System.err.println("TileRenderer: detached: "+glad); System.err.println("TileRenderer: "+glad.getChosenGLCapabilities()); } listeners = null; listenersInit = null; glad = null; } }
/** * Sets the {@code JComponent} that will be drawn to the OpenGL canvas. */ public void setDrawableComponent(JComponent component) { if (component == drawableComponent) { return; } if (g2dglListener != null) { canvas.removeGLEventListener(g2dglListener); if (sideContext != null) { sideContext.removeGLEventListener(g2dglListener); } } if (drawableComponent != null) { remove(drawableComponent); } drawableComponent = component; if (drawableComponent != null) { verifyHierarchy(drawableComponent); g2dglListener = createG2DListener(drawableComponent); canvas.addGLEventListener(g2dglListener); if (sideContext != null) { sideContext.addGLEventListener(g2dglListener); } add(drawableComponent); } }
/** * Detaches the given {@link GLAutoDrawable} from this tile renderer. * @see #attachAutoDrawable(GLAutoDrawable) * @see #getAttachedDrawable() */ public final void detachAutoDrawable() { if( null != glad ) { glad.removeGLEventListener(tiledGLEL); final int aSz = listenersInit.length; for(int i=0; i<aSz; i++) { final GLEventListener l = listeners[i]; if( l instanceof TileRendererListener ) { ((TileRendererListener)l).removeTileRendererNotify(this); } glad.addGLEventListener(l); glad.setGLEventListenerInitState(l, listenersInit[i]); } glad.setAutoSwapBufferMode(gladAutoSwapBufferMode); if( DEBUG ) { System.err.println("TileRenderer: detached: "+glad); System.err.println("TileRenderer: "+glad.getChosenGLCapabilities()); } listeners = null; listenersInit = null; glad = null; } }
/** * Sets the {@code JComponent} that will be drawn to the OpenGL canvas. */ public void setDrawableComponent(JComponent component) { if (component == drawableComponent) { return; } if (g2dglListener != null) { canvas.removeGLEventListener(g2dglListener); if (sideContext != null) { sideContext.removeGLEventListener(g2dglListener); } } if (drawableComponent != null) { remove(drawableComponent); } drawableComponent = component; if (drawableComponent != null) { verifyHierarchy(drawableComponent); g2dglListener = createG2DListener(drawableComponent); canvas.addGLEventListener(g2dglListener); if (sideContext != null) { sideContext.addGLEventListener(g2dglListener); } add(drawableComponent); } }
/** * Moves the designated {@link GLEventListener} from {@link GLAutoDrawable} <code>src</code> to <code>dest</code>. * If <code>preserveInitState</code> is <code>true</code>, it's initialized state is preserved * and {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape(..)} issued w/ the next {@link GLAutoDrawable#display()} call. * <p> * Note that it is only legal to pass <code>preserveInitState := true</code>, * if the {@link GLContext} of both <code>src</code> and <code>dest</code> are shared, or has itself moved from <code>src</code> to <code>dest</code>. * </p> * <p> * Also note that the caller is encouraged to pause an attached {@link GLAnimatorControl}. * </p> * @param src * @param dest * @param listener * @param preserveInitState */ public static final void moveGLEventListener(final GLAutoDrawable src, final GLAutoDrawable dest, final GLEventListener listener, final boolean preserveInitState) { final boolean initialized = src.getGLEventListenerInitState(listener); if( preserveInitState ) { src.removeGLEventListener(listener); dest.addGLEventListener(listener); if( initialized ) { dest.setGLEventListenerInitState(listener, true); dest.invoke(false, new ReshapeGLEventListener(listener, true)); } } else { src.disposeGLEventListener(listener, true); dest.addGLEventListener(listener); } }
public OTFHostControl(OTFServer aServer, Component aCanvas) { server = aServer; canvas = aCanvas; Collection<Double> steps = getTimeStepsdrawer(); if (steps != null) { // Movie mode with timesteps Double[] dsteps = steps.toArray(new Double[steps.size()]); int min = dsteps[0].intValue(); int max = dsteps[dsteps.length-1].intValue(); simTime = new DefaultBoundedRangeModel(min, 0 /* extent */, min, max); } else { // Live mode without timesteps simTime = new DefaultBoundedRangeModel(0 /* value */, 0 /* extent */, 0 /* value */, Integer.MAX_VALUE /* max */); } simTime.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { canvas.repaint(); } }); animator = new Animator(); animator.add(((GLAutoDrawable) canvas)); ((GLAutoDrawable) canvas).addGLEventListener(this); simTime.setValue(server.getLocalTime()); }
this.otfVisConfig = otfVisConfig; this.canvas = canvas; ((GLAutoDrawable) canvas).addGLEventListener(new OGLSimpleStaticNetLayer()); ((GLAutoDrawable) canvas).addGLEventListener(this); ((GLAutoDrawable) canvas).addGLEventListener(new OTFScaleBarDrawer()); ((GLAutoDrawable) canvas).addGLEventListener(new OTFGLOverlay("/res/matsim_logo_blue.png", -0.03f, 0.05f, 1.5f, false)); ((GLAutoDrawable) canvas).addGLEventListener(new ScreenshotTaker(this.hostControlBar)); clientQ.getConstData();
private void prepareSideContext() { if (sideContext == null) { GLDrawableFactory factory = canvas.getFactory(); sideContext = factory.createOffscreenAutoDrawable(null, chosenCapabilities, null, 1, 1); ((GLOffscreenAutoDrawable) sideContext).setSharedContext(canvas.getContext()); sideContext.addGLEventListener(g2dglListener); } Runnable work = new Runnable() { @Override public void run() { sideContext.display(); } }; if (Threading.isOpenGLThread()) { work.run(); } else { Threading.invokeOnOpenGLThread(false, work); } }
glad.addGLEventListener(tiledGLEL); gladAutoSwapBufferMode = glad.getAutoSwapBufferMode(); gladRequiresPreSwap = this.reqPreSwapBuffers(glad.getChosenGLCapabilities());
glad.addGLEventListener(tiledGLEL); gladAutoSwapBufferMode = glad.getAutoSwapBufferMode(); gladRequiresPreSwap = this.reqPreSwapBuffers(glad.getChosenGLCapabilities());
dest.addGLEventListener( l ); dest.setGLEventListenerInitState(l, listenersInit[i]); listeners[i] = null;
dest.addGLEventListener( l ); dest.setGLEventListenerInitState(l, listenersInit[i]); listeners[i] = null;
canvas.addGLEventListener(g2dglListener); add((Component) canvas, 0);
/** * Calling {@link GLCanvas#removeNotify()} destroys the GLContext. We could * mess with that internally, but this is slightly easier. * <p> * This method is particularly important for docking frameworks and moving the * panel from one window to another. This is simple for normal Swing * components, but GL contexts are destroyed when {@code removeNotify()} is * called. * </p> * <p> * Our workaround is to use context sharing. The pbuffer is initialized and by * drawing into it at least once, we automatically share all textures, etc. * with the new pbuffer. This pbuffer holds the data until we can initialize * our new JOGL canvas. We share the pbuffer canvas with the new JOGL canvas * and everything works nicely from then on. * </p> * <p> * This has the unfortunate side-effect of leaking memory. I'm not sure how to * fix this yet. * </p> */ @Override public void removeNotify() { prepareSideContext(); remove((Component) canvas); super.removeNotify(); canvas = createGLComponent(chosenCapabilities, sideContext.getContext()); canvas.addGLEventListener(g2dglListener); add((Component) canvas, 0); }
public GLCore(int w, int h) { super(w, h); activeWindowGL = new WindowGL(0, 0, w, h); glGraphics = new GLGraphics2D(); graphic = new AWTGraphics3D(w,h); canvas.addMouseMotionListener(getMouse()); canvas.addMouseWheelListener(getMouse()); canvas.addMouseListener(getMouse()); canvas.getCanvas().addGLEventListener(this); animator = new FPSAnimator(REFRESH_FPS, true); animator.add(canvas.getCanvas()); initLoaders(); }
public OffscreenCanvas(int width, int height, boolean transparentBackground, int antialiasing) { super(); final GLProfile glp = GLProfile.get(GLProfile.GL2); final GLCapabilities caps = getCaps(); caps.setOnscreen(false); caps.setDoubleBuffered(false); if (antialiasing == 0) { caps.setSampleBuffers(false); } else { caps.setSampleBuffers(true); caps.setNumSamples(antialiasing); } final GLDrawableFactory factory = GLDrawableFactory.getFactory(glp); drawable = factory.createOffscreenAutoDrawable(null, caps, null, width, height); drawable.addGLEventListener(this); cameraLocation = vizController.getDrawable().getCameraLocation(); cameraTarget = vizController.getDrawable().getCameraTarget(); engine = VizController.getInstance().getEngine(); globalScale = VizController.getInstance().getDrawable().getGlobalScale(); this.transparentBackground = transparentBackground; }