protected void setCanvas(GLContext context) { glDrawable = context.getGLDrawable(); glContext = context; for (G2DDrawingHelper helper : helpers) { helper.setG2D(this); } }
public JavaCVCL(GLContext shareWith) { this(getDefaultGLCapabilities(shareWith == null ? null : shareWith.getGLDrawable().getGLProfile()), shareWith, null); } public JavaCVCL(GLCapabilitiesImmutable caps, GLContext shareWith, CLDevice device) {
public final StringBuilder append(final StringBuilder sb) { sb.append("Version ").append(getGLVersion()).append(" [GL ").append(getGLVersionNumber()).append(", vendor ").append(getGLVendorVersionNumber()); sb.append("], options 0x"); sb.append(Integer.toHexString(ctxOptions)); sb.append(", this "); sb.append(toHexString(hashCode())); sb.append(", handle "); sb.append(toHexString(contextHandle)); sb.append(", isShared "+isShared()+", "); sb.append(getGL()); sb.append(",\n\t quirks: "); if(null != glRendererQuirks) { glRendererQuirks.toString(sb); } else { sb.append("n/a"); } if(getGLDrawable()!=getGLReadDrawable()) { sb.append(",\n\tRead Drawable : "); sb.append(getGLReadDrawable()); sb.append(",\n\tWrite Drawable: "); sb.append(getGLDrawable()); } else { sb.append(",\n\tDrawable: "); sb.append(getGLDrawable()); } return sb; }
public final StringBuilder append(final StringBuilder sb) { sb.append("Version ").append(getGLVersion()).append(" [GL ").append(getGLVersionNumber()).append(", vendor ").append(getGLVendorVersionNumber()); sb.append("], options 0x"); sb.append(Integer.toHexString(ctxOptions)); sb.append(", this "); sb.append(toHexString(hashCode())); sb.append(", handle "); sb.append(toHexString(contextHandle)); sb.append(", isShared "+isShared()+", "); sb.append(getGL()); sb.append(",\n\t quirks: "); if(null != glRendererQuirks) { glRendererQuirks.toString(sb); } else { sb.append("n/a"); } if(getGLDrawable()!=getGLReadDrawable()) { sb.append(",\n\tRead Drawable : "); sb.append(getGLReadDrawable()); sb.append(",\n\tWrite Drawable: "); sb.append(getGLDrawable()); } else { sb.append(",\n\tDrawable: "); sb.append(getGLDrawable()); } return sb; }
public static boolean isRetina(final GL pGL) { final int[] trialSizes = new int[2]; trialSizes[0] = 512; trialSizes[1] = 512; pGL.getContext() .getGLDrawable() .getNativeSurface() .convertToPixelUnits(trialSizes); if (trialSizes[0] == 512 && trialSizes[1] == 512) { return false; } else { return true; } }
public static StringBuilder getGLInfo(final GL gl, StringBuilder sb, final boolean withAvailabilityInfo, final boolean withCapabilitiesInfo, final boolean withExtensionInfo) { final AbstractGraphicsDevice device = gl.getContext().getGLDrawable().getNativeSurface() .getGraphicsConfiguration().getScreen().getDevice(); if(null==sb) { sb = new StringBuilder(); } sb.append(VersionUtil.SEPERATOR).append(Platform.getNewline()); sb.append(device.getClass().getSimpleName()).append("[type ") .append(device.getType()).append(", connection ").append(device.getConnection()).append("]: ").append(Platform.getNewline()); if( withAvailabilityInfo ) { GLProfile.glAvailabilityToString(device, sb, "\t", 1); } sb.append(Platform.getNewline()); sb = getGLStrings(gl, sb, withExtensionInfo); if( withCapabilitiesInfo ) { sb = getAllAvailableCapabilitiesInfo(device, sb); } return sb; }
public static StringBuilder getGLInfo(final GL gl, StringBuilder sb, final boolean withAvailabilityInfo, final boolean withCapabilitiesInfo, final boolean withExtensionInfo) { final AbstractGraphicsDevice device = gl.getContext().getGLDrawable().getNativeSurface() .getGraphicsConfiguration().getScreen().getDevice(); if(null==sb) { sb = new StringBuilder(); } sb.append(VersionUtil.SEPERATOR).append(Platform.getNewline()); sb.append(device.getClass().getSimpleName()).append("[type ") .append(device.getType()).append(", connection ").append(device.getConnection()).append("]: ").append(Platform.getNewline()); if( withAvailabilityInfo ) { GLProfile.glAvailabilityToString(device, sb, "\t", 1); } sb.append(Platform.getNewline()); sb = getGLStrings(gl, sb, withExtensionInfo); if( withCapabilitiesInfo ) { sb = getAllAvailableCapabilitiesInfo(device, sb); } return sb; }
@Override protected void swapBuffersImpl(final boolean doubleBuffered) { final GLContext ctx = GLContext.getCurrent(); boolean doPostSwap; if( null != ctx && ctx.getGLDrawable() == this && fboBound ) { swapFBOImpl(ctx); doPostSwap = true; fboSwapped = true; if(DEBUG_SWAP) { System.err.println("Post FBO swap(@swap): done"); } } else { doPostSwap = false; } if( null != swapBufferContext ) { swapBufferContext.swapBuffers(doubleBuffered); } if(doPostSwap) { swapFBOImplPost(ctx); } }
@Override protected void swapBuffersImpl(final boolean doubleBuffered) { final GLContext ctx = GLContext.getCurrent(); boolean doPostSwap; if( null != ctx && ctx.getGLDrawable() == this && fboBound ) { swapFBOImpl(ctx); doPostSwap = true; fboSwapped = true; if(DEBUG_SWAP) { System.err.println("Post FBO swap(@swap): done"); } } else { doPostSwap = false; } if( null != swapBufferContext ) { swapBufferContext.swapBuffers(doubleBuffered); } if(doPostSwap) { swapFBOImplPost(ctx); } }
/** * Method will set the {@link GLRendererQuirks#NoSurfacelessCtx} * if it has not been set already. * * @param context the context to probe, must be current * @see GLRendererQuirks#NoSurfacelessCtx */ protected final void setNoSurfacelessCtxQuirk(final GLContext context) { final boolean noSurfacelessCtxQuirk = context.hasRendererQuirk(GLRendererQuirks.NoSurfacelessCtx); if( !noSurfacelessCtxQuirk ) { final GLDrawable origDrawable = context.getGLDrawable(); final AbstractGraphicsDevice device = origDrawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice(); setNoSurfacelessCtxQuirkImpl(device, context); } } private final void setNoSurfacelessCtxQuirkImpl(final AbstractGraphicsDevice device, final GLContext context) {
/** * Method will set the {@link GLRendererQuirks#NoSurfacelessCtx} * if it has not been set already. * * @param context the context to probe, must be current * @see GLRendererQuirks#NoSurfacelessCtx */ protected final void setNoSurfacelessCtxQuirk(final GLContext context) { final boolean noSurfacelessCtxQuirk = context.hasRendererQuirk(GLRendererQuirks.NoSurfacelessCtx); if( !noSurfacelessCtxQuirk ) { final GLDrawable origDrawable = context.getGLDrawable(); final AbstractGraphicsDevice device = origDrawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice(); setNoSurfacelessCtxQuirkImpl(device, context); } } private final void setNoSurfacelessCtxQuirkImpl(final AbstractGraphicsDevice device, final GLContext context) {
public final synchronized void initGL(final GL gl) { final GLContext glCtx = gl.getContext(); final boolean glCtxCurrent = glCtx.isCurrent(); final GLProfile glp = gl.getGLProfile(); final GLDrawableFactory factory = GLDrawableFactory.getFactory(glp); final AbstractGraphicsDevice device = glCtx.getGLDrawable().getNativeSurface().getGraphicsConfiguration().getScreen().getDevice(); dummyDrawable = factory.createDummyDrawable(device, true, glCtx.getGLDrawable().getChosenGLCapabilities(), null); // own device! dummyDrawable.setRealized(true); sharedGLCtx = dummyDrawable.createContext(glCtx); makeCurrent(sharedGLCtx); if( glCtxCurrent ) { makeCurrent(glCtx); } else { sharedGLCtx.release(); } } public final synchronized void doPause(final boolean waitUntilDone) {
reqStencil = 16; } else if( CHOSEN_BITS == reqBits ) { final GLCapabilitiesImmutable caps = gl.getContext().getGLDrawable().getChosenGLCapabilities(); reqDepth = caps.getDepthBits(); reqStencil = caps.getStencilBits(); } else if( REQUESTED_BITS == reqBits ) { final GLCapabilitiesImmutable caps = gl.getContext().getGLDrawable().getRequestedGLCapabilities(); reqDepth = caps.getDepthBits(); reqStencil = caps.getStencilBits();
reqStencil = 16; } else if( CHOSEN_BITS == reqBits ) { final GLCapabilitiesImmutable caps = gl.getContext().getGLDrawable().getChosenGLCapabilities(); reqDepth = caps.getDepthBits(); reqStencil = caps.getStencilBits(); } else if( REQUESTED_BITS == reqBits ) { final GLCapabilitiesImmutable caps = gl.getContext().getGLDrawable().getRequestedGLCapabilities(); reqDepth = caps.getDepthBits(); reqStencil = caps.getStencilBits();
@Override public final void swapBuffers() throws GLException { if( !realized ) { // volatile OK (locked below) return; // destroyed already } final int lockRes = lockSurface(); // it's recursive, so it's ok within [makeCurrent .. release] if (NativeSurface.LOCK_SURFACE_NOT_READY == lockRes) { return; } try { if( realized ) { // volatile OK final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable)surface.getGraphicsConfiguration().getChosenCapabilities(); if ( caps.getDoubleBuffered() ) { if(!surface.surfaceSwap()) { swapBuffersImpl(true); } } else { final GLContext ctx = GLContext.getCurrent(); if(null!=ctx && ctx.getGLDrawable()==this) { ctx.getGL().glFlush(); } swapBuffersImpl(false); } } } finally { unlockSurface(); } surface.surfaceUpdated(this, surface, System.currentTimeMillis()); }
@Override public final void swapBuffers() throws GLException { if( !realized ) { // volatile OK (locked below) return; // destroyed already } final int lockRes = lockSurface(); // it's recursive, so it's ok within [makeCurrent .. release] if (NativeSurface.LOCK_SURFACE_NOT_READY == lockRes) { return; } try { if( realized ) { // volatile OK final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable)surface.getGraphicsConfiguration().getChosenCapabilities(); if ( caps.getDoubleBuffered() ) { if(!surface.surfaceSwap()) { swapBuffersImpl(true); } } else { final GLContext ctx = GLContext.getCurrent(); if(null!=ctx && ctx.getGLDrawable()==this) { ctx.getGL().glFlush(); } swapBuffersImpl(false); } } } finally { unlockSurface(); } surface.surfaceUpdated(this, surface, System.currentTimeMillis()); }
.getGLDrawable() .getSurfaceWidth() / scaleFactor; final int windowSizeY = mGL.getContext() .getGLDrawable() .getSurfaceHeight() / scaleFactor;
final GLDrawable origDrawable = context.getGLDrawable(); final AbstractGraphicsDevice device = origDrawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice();
final GLDrawable origDrawable = context.getGLDrawable(); final AbstractGraphicsDevice device = origDrawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice();