/** * Making this public made possible to mix 3d and 2D easily */ public void setCanvas(GLAutoDrawable drawable) { glContext = drawable.getContext(); for (G2DDrawingHelper helper : helpers) { helper.setG2D(this); } }
public GLContext getCurrentContext() { GLAutoDrawable c = getCanvasAsGLAutoDrawable(); GLContext context = c.getContext(); return context; }
public void setCanvas(GLAutoDrawable glDrawable) { this.glContext = glDrawable.getContext(); for (G2DDrawingHelper helper : helpers) { helper.setG2D(this); } }
/** * Called before any painting is done. This should setup the matrices and ask * the {@code GLGraphics2D} object to setup any client state. */ protected void prePaint(GLAutoDrawable drawable) { setupViewport(drawable); g2d.prePaint(drawable.getContext()); // clip to only the component we're painting g2d.translate(comp.getX(), comp.getY()); g2d.clipRect(0, 0, comp.getWidth(), comp.getHeight()); }
/** * @param shared returns the shared GLContext, based on set shared GLAutoDrawable * or GLContext. Maybe null if none is set. * @return true if initialization is pending due to a set shared GLAutoDrawable or GLContext * which is not ready yet. Otherwise false. */ public boolean isSharedGLContextPending(final GLContext[] shared) { final GLContext shareWith; final boolean pending; if ( null != sharedAutoDrawable ) { shareWith = sharedAutoDrawable.getContext(); pending = null == shareWith || !shareWith.isCreated() || !sharedAutoDrawable.areAllGLEventListenerInitialized(); } else { shareWith = sharedContext; pending = null != shareWith && !shareWith.isCreated(); } shared[0] = shareWith; return pending; }
/** * @param shared returns the shared GLContext, based on set shared GLAutoDrawable * or GLContext. Maybe null if none is set. * @return true if initialization is pending due to a set shared GLAutoDrawable or GLContext * which is not ready yet. Otherwise false. */ public boolean isSharedGLContextPending(final GLContext[] shared) { final GLContext shareWith; final boolean pending; if ( null != sharedAutoDrawable ) { shareWith = sharedAutoDrawable.getContext(); pending = null == shareWith || !shareWith.isCreated() || !sharedAutoDrawable.areAllGLEventListenerInitialized(); } else { shareWith = sharedContext; pending = null != shareWith && !shareWith.isCreated(); } shared[0] = shareWith; return pending; }
wait && ( !drawable.isRealized() || null==drawable.getContext() ) ) { return false;
public void getGL(GLAutoDrawable glDrawable) { context = glDrawable.getContext(); glContext = context.hashCode(); setThread(Thread.currentThread()); gl = context.getGL(); gl2 = gl.getGL2ES2(); try { gl2x = gl.getGL2(); } catch (com.jogamp.opengl.GLException e) { gl2x = null; } try { gl3 = gl.getGL2GL3(); } catch (com.jogamp.opengl.GLException e) { gl3 = null; } try { gl3es3 = gl.getGL3ES3(); } catch (com.jogamp.opengl.GLException e) { gl3es3 = null; } }
wait && ( !drawable.isRealized() || null==drawable.getContext() ) ) { return false;
protected GL2 getGL2(GLAutoDrawable drawable) { LOGGER.info("GL context : " + drawable.getContext()); LOGGER.info("GL profile : " + drawable.getGLProfile()); LOGGER.info("GL impl : " + drawable.getGL().getClass().getSimpleName()); LOGGER.info("isGL : " + drawable.getGL().isGL()); LOGGER.info("isGL2 : " + drawable.getGL().isGL2()); LOGGER.info("isGLES1 : " + drawable.getGL().isGL2ES1()); LOGGER.info("isGLES2 : " + drawable.getGL().isGL2ES2()); LOGGER.info("isGLES3 : " + drawable.getGL().isGL2ES3()); LOGGER.info("isGL2GL3 : " + drawable.getGL().isGL2GL3()); LOGGER.info("isGL3 : " + drawable.getGL().isGL3()); LOGGER.info("isGL3core : " + drawable.getGL().isGL3core()); LOGGER.info("isGL3ES3 : " + drawable.getGL().isGL3ES3()); LOGGER.info("isGL4 : " + drawable.getGL().isGL4()); LOGGER.info("isGL4bc : " + drawable.getGL().isGL4bc()); if (drawable.getGL() instanceof GL4bcImpl) { return drawable.getGL().getGL3().getGL2();//(GL2)drawable;//drawable.getGL().getGL2();//getGL3().getGL2(); } else { return (GL2)drawable;//drawable.getGL().getGL2(); } }
wait && ( !drawable.isRealized() || null==drawable.getContext() ) ) { return false;
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); } }
wait && ( !drawable.isRealized() || null==drawable.getContext() ) ) { return false;
keepLocked ? srcUpstreamLock : null, srcSurfaceLocked && keepLocked ? srcSurface : null, src.getContext(), aSz, srcAnim, srcAnimStarted);
keepLocked ? srcUpstreamLock : null, srcSurfaceLocked && keepLocked ? srcSurface : null, src.getContext(), aSz, srcAnim, srcAnimStarted);
super.removeNotify(); canvas = createGLComponent(chosenCapabilities, sideContext.getContext()); 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); }
b.disposeGLEventListener(b.getGLEventListener(i), false); b.setContext( a.setContext( b.getContext(), false ), false );
b.disposeGLEventListener(b.getGLEventListener(i), false); b.setContext( a.setContext( b.getContext(), false ), false );