/** * Convenience method for retrieving the Camera set on the current RenderContext. Similar to * ContextManager.getCurrentContext().getCurrentCamera() but with null checks for current context. * * @return the Camera on the current RenderContext. */ public static Camera getCurrentCamera() { if (ContextManager.getCurrentContext() == null) { return null; } return ContextManager.getCurrentContext().getCurrentCamera(); }
if (ContextManager.getCurrentContext() != null) { if (value == GLContext.CONTEXT_CURRENT_NEW) { ContextManager.getCurrentContext().contextLost(); if (ContextManager.getContextForKey(_context) != null) { ContextManager.switchContext(_context);
/** * Should only be called on a thread with an active context. */ public void contextLost() { // Notify any interested parties of the deletion. ContextManager.fireCleanContextEvent(this); // invalidate our render states invalidateStates(); // force camera update if (_currentCamera != null) { _currentCamera.update(); } } }
private static void handleVBODelete(final IShaderUtils utils, final Multimap<RenderContextRef, Integer> idMap) { Object currentGLRef = null; // Grab the current context, if any. if (utils != null && ContextManager.getCurrentContext() != null) { currentGLRef = ContextManager.getCurrentContext().getGlContextRef(); } // For each affected context... for (final RenderContextRef glref : idMap.keySet()) { // If we have a deleter and the context is current, immediately delete if (utils != null && glref.equals(currentGLRef)) { utils.deleteBuffers(idMap.get(glref)); } // Otherwise, add a delete request to that context's render task queue. else { GameTaskQueueManager.getManager(ContextManager.getContextForRef(glref)) .render(new RendererCallable<Void>() { public Void call() throws Exception { getRenderer().getShaderUtils().deleteBuffers(idMap.get(glref)); return null; } }); } } }
private void activate() { if (_active == 0) { try { _oldContext = ContextManager.getCurrentContext(); _pbuffer.makeCurrent(); ContextManager.switchContext(_pbuffer); ContextManager.getCurrentContext().clearEnforcedStates(); ContextManager.getCurrentContext().enforceStates(_enforcedStates); if (_bgColorDirty) { GL11.glClearColor(_backgroundColor.getRed(), _backgroundColor.getGreen(), _backgroundColor.getBlue(), _backgroundColor.getAlpha()); _bgColorDirty = false; } } catch (final LWJGLException e) { logger.logp(Level.SEVERE, this.getClass().toString(), "activate()", "Exception", e); throw new Ardor3dException(); } } _active++; }
if (_pbuffer != null) { giveBackContext(); ContextManager.removeContext(_pbuffer); ContextManager.addContext(contextKey, new RenderContext(contextKey, caps, ContextManager.getCurrentContext()));
if (settings.getShareContext() != null) { sharedContext = ContextManager .getContextForKey(settings.getShareContext().getRenderContext().getContextKey()); _currentContext = new RenderContext(this, caps, sharedContext); ContextManager.addContext(this, _currentContext); ContextManager.switchContext(this);
public void makeCurrentContext() throws Ardor3dException { _canvasCallback.makeCurrent(false); ContextManager.switchContext(this); }
ContextManager.addContext(this, currentContext); ContextManager.switchContext(this);
private static void handleDisplayListDelete(final Renderer deleter, final Multimap<Object, Integer> idMap) { Object currentGLRef = null; // Grab the current context, if any. if (deleter != null && ContextManager.getCurrentContext() != null) { currentGLRef = ContextManager.getCurrentContext().getGlContextRep(); } // For each affected context... for (final Object glref : idMap.keySet()) { // If we have a deleter and the context is current, immediately delete if (deleter != null && glref.equals(currentGLRef)) { deleter.deleteDisplayLists(idMap.get(glref)); } // Otherwise, add a delete request to that context's render task queue. else { GameTaskQueueManager.getManager(ContextManager.getContextForRef(glref)).render( new RendererCallable<Void>() { public Void call() throws Exception { getRenderer().deleteDisplayLists(idMap.get(glref)); return null; } }); } } } }
_offscreenDrawable.destroy(); giveBackContext(); ContextManager.removeContext(_offscreenDrawable.getContext()); ContextManager.addContext(_context, new JoglRenderContext(_context, contextCaps, ContextManager.getCurrentContext()));
private void activate() { if (_active == 0) { _oldContext = ContextManager.getCurrentContext(); _context.makeCurrent(); ContextManager.switchContext(_context); ContextManager.getCurrentContext().clearEnforcedStates(); ContextManager.getCurrentContext().enforceStates(_enforcedStates); if (_bgColorDirty) { final GL gl = GLContext.getCurrentGL(); gl.glClearColor(_backgroundColor.getRed(), _backgroundColor.getGreen(), _backgroundColor.getBlue(), _backgroundColor.getAlpha()); _bgColorDirty = false; } } _active++; }
sharedContext = ContextManager.getContextForKey(settings.getShareContext().getRenderContext() .getContextKey()); _currentContext = new RenderContext(this, caps, sharedContext); ContextManager.addContext(this, _currentContext); ContextManager.switchContext(this);
private void giveBackContext() { _parentContext.makeCurrent(); ContextManager.switchContext(_oldContext.getContextKey()); }
/** * Convenience method for retrieving the Camera set on the current RenderContext. Similar to * ContextManager.getCurrentContext().getCurrentCamera() but with null checks for current context. * * @return the Camera on the current RenderContext. */ public static Camera getCurrentCamera() { if (ContextManager.getCurrentContext() == null) { return null; } return ContextManager.getCurrentContext().getCurrentCamera(); }
private static void handleVBODelete(final Renderer deleter, final Multimap<Object, Integer> idMap) { Object currentGLRef = null; // Grab the current context, if any. if (deleter != null && ContextManager.getCurrentContext() != null) { currentGLRef = ContextManager.getCurrentContext().getGlContextRep(); } // For each affected context... for (final Object glref : idMap.keySet()) { // If we have a deleter and the context is current, immediately delete if (deleter != null && glref.equals(currentGLRef)) { deleter.deleteVBOs(idMap.get(glref)); } // Otherwise, add a delete request to that context's render task queue. else { GameTaskQueueManager.getManager(ContextManager.getContextForRef(glref)).render( new RendererCallable<Void>() { public Void call() throws Exception { getRenderer().deleteVBOs(idMap.get(glref)); return null; } }); } } }
sharedContext = ContextManager.getContextForKey(settings.getShareContext().getRenderContext() .getContextKey()); _currentContext = new JoglRenderContext(_context, caps, sharedContext); ContextManager.addContext(_context, _currentContext); ContextManager.switchContext(_context);
public void makeCurrentContext() throws Ardor3dException { try { _canvasCallback.makeCurrent(); GLContext.useContext(_context); ContextManager.switchContext(this); } catch (final LWJGLException e) { throw new Ardor3dException("Failed to claim OpenGL context.", e); } }
/** * Should only be called on a thread with an active context. */ public void contextLost() { // Notify any interested parties of the deletion. ContextManager.fireCleanContextEvent(this); // invalidate our render states invalidateStates(); // force camera update if (_currentCamera != null) { _currentCamera.update(); } } }
@Override public void deleteBuffer(final AbstractBufferData<?> buffer) { if (buffer == null) { return; } final int id = buffer.removeBufferId(ContextManager.getCurrentContext()); if (id == 0) { // Not on card... return. return; } GL15C.glDeleteBuffers(id); if (logger.isLoggable(Level.FINE)) { logger.fine("deleting buffer " + id); } }