本文整理了Java中com.jogamp.opengl.GLDrawable.setRealized()
方法的一些代码示例,展示了GLDrawable.setRealized()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GLDrawable.setRealized()
方法的具体详情如下:
包路径:com.jogamp.opengl.GLDrawable
类名称:GLDrawable
方法名:setRealized
[英]Indicates to GLDrawable implementations whether the underlying NativeSurface has been created and can be drawn into.
If realized, the #getHandle() may become valid while it's NativeSurface is being NativeSurface#lockSurface().
End users do not need to call this method; it is not necessary to call setRealized
on a GLAutoDrawableas these perform the appropriate calls on their underlying GLDrawables internally.
Developers implementing new OpenGL components for various window toolkits need to call this method against GLDrawables obtained from the GLDrawableFactory via the GLDrawableFactory#createGLDrawable(NativeSurface) method. It must typically be called with an argument of true
when the component associated with the GLDrawable is realized and with an argument of false
just before the component is unrealized. For the AWT, this means calling setRealized(true)
in the addNotify
method and with an argument of false
in the removeNotify
method.
GLDrawable
implementations should handle multiple cycles of setRealized(true)
/ setRealized(false)
calls. Most, if not all, Java window toolkits have a persistent object associated with a given component, regardless of whether that component is currently realized. The GLDrawable
object associated with a particular component is intended to be similarly persistent. A GLDrawable
is intended to be created for a given component when it is constructed and live as long as that component. setRealized
allows the GLDrawable
to re-initialize and destroy any associated resources as the component becomes realized and unrealized, respectively.
With an argument of true
, the minimum implementation shall call NativeSurface#lockSurface() and if successful:
This is important since NativeSurface#lockSurface()ensures resolving the window/surface handles, and the drawable's GLCapabilitiesmight have changed.
Calling this method has no other effects. For example, if removeNotify
is called on a Canvas implementation for which a GLDrawable has been created, it is also necessary to destroy all OpenGL contexts associated with that GLDrawable. This is not done automatically by the implementation.
[中]向GLDrawable实现指示是否已创建基础NativeSurface并可将其绘制到中。
如果实现,#getHandle()可能在其NativeSurface为NativeSurface#lockSurface()时变为有效。
最终用户不需要调用此方法;无需对GLAutoDrawables调用setRealized
,因为它们在内部对其基础GLDrawables执行适当的调用。
为各种窗口工具包实现新OpenGL组件的开发人员需要对通过GLDrawableFactory#createGLDrawable(NativeSurface)方法从GLDrawableFactory获得的GLDrawables调用此方法。当与GLDrawable关联的组件实现时,通常必须使用参数true
调用它,并且在组件未实现之前使用参数false
调用它。对于AWT,这意味着在addNotify
方法中调用setRealized(true)
,在removeNotify
方法中使用false
参数。GLDrawable
实现应处理setRealized(true)
/setRealized(false)
调用的多个周期。大多数(如果不是全部的话)Java窗口工具包都有一个与给定组件关联的持久对象,而不管该组件当前是否实现。与特定组件关联的GLDrawable
对象旨在具有类似的持久性。GLDrawable
是为了在给定组件构建时为其创建的,并且与该组件的寿命一样长。setRealized
允许GLDrawable
在组件分别实现和未实现时重新初始化和销毁任何相关资源。
参数为true
时,最小实现应调用NativeSurface#lockSurface(),如果成功:
*更新与连接的NativeSurface的AbstractGraphics配置关联的GLCapabilities。
*使用NativeSurface#unlockSurface()释放锁。
这一点很重要,因为NativeSurface#lockSurface()可确保解析窗/曲面控制柄,并且绘图表的GLCapabilities可能已更改。
调用此方法没有其他影响。例如,如果在已为其创建GLDrawable的画布实现上调用removeNotify
,则还需要销毁与该GLDrawable关联的所有OpenGL上下文。这不是由实现自动完成的。
代码示例来源:origin: runelite/runelite
glDrawable.setRealized(true);
代码示例来源:origin: org.jogamp.jogl/jogl-all-noawt
@Override
public final GLAutoDrawable createDummyAutoDrawable(final AbstractGraphicsDevice deviceReq, final boolean createNewDevice, final GLCapabilitiesImmutable capsRequested, final GLCapabilitiesChooser chooser) {
final GLDrawable drawable = createDummyDrawable(deviceReq, createNewDevice, capsRequested, chooser);
try {
drawable.setRealized(true);
} catch( final GLException gle) {
try {
drawable.setRealized(false);
} catch( final GLException gle2) { /* ignore */ }
throw gle;
}
final GLAutoDrawable sharedDrawable = new GLAutoDrawableDelegate(drawable, null, null, true /*ownDevice*/, null) { };
return sharedDrawable;
}
代码示例来源:origin: org.jogamp.jogl/jogl
@Override
public final GLAutoDrawable createDummyAutoDrawable(final AbstractGraphicsDevice deviceReq, final boolean createNewDevice, final GLCapabilitiesImmutable capsRequested, final GLCapabilitiesChooser chooser) {
final GLDrawable drawable = createDummyDrawable(deviceReq, createNewDevice, capsRequested, chooser);
try {
drawable.setRealized(true);
} catch( final GLException gle) {
try {
drawable.setRealized(false);
} catch( final GLException gle2) { /* ignore */ }
throw gle;
}
final GLAutoDrawable sharedDrawable = new GLAutoDrawableDelegate(drawable, null, null, true /*ownDevice*/, null) { };
return sharedDrawable;
}
代码示例来源:origin: org.jogamp.jogl/jogl-all-noawt
@Override
public final GLOffscreenAutoDrawable createOffscreenAutoDrawable(final AbstractGraphicsDevice deviceReq,
final GLCapabilitiesImmutable capsRequested,
final GLCapabilitiesChooser chooser,
final int width, final int height) {
final GLDrawable drawable = createOffscreenDrawable( deviceReq, capsRequested, chooser, width, height );
try {
drawable.setRealized(true);
} catch( final GLException gle) {
try {
drawable.setRealized(false);
} catch( final GLException gle2) { /* ignore */ }
throw gle;
}
if(drawable instanceof GLFBODrawableImpl) {
return new GLOffscreenAutoDrawableImpl.FBOImpl( (GLFBODrawableImpl)drawable, null, null, null );
}
return new GLOffscreenAutoDrawableImpl( drawable, null, null, null);
}
代码示例来源:origin: org.jogamp.jogl/jogl
@Override
public final GLOffscreenAutoDrawable createOffscreenAutoDrawable(final AbstractGraphicsDevice deviceReq,
final GLCapabilitiesImmutable capsRequested,
final GLCapabilitiesChooser chooser,
final int width, final int height) {
final GLDrawable drawable = createOffscreenDrawable( deviceReq, capsRequested, chooser, width, height );
try {
drawable.setRealized(true);
} catch( final GLException gle) {
try {
drawable.setRealized(false);
} catch( final GLException gle2) { /* ignore */ }
throw gle;
}
if(drawable instanceof GLFBODrawableImpl) {
return new GLOffscreenAutoDrawableImpl.FBOImpl( (GLFBODrawableImpl)drawable, null, null, null );
}
return new GLOffscreenAutoDrawableImpl( drawable, null, null, null);
}
代码示例来源:origin: org.scijava/j3dcore
@Override
public void addNotify() {
super.addNotify();
nativeWindow = (JAWTWindow)NativeWindowFactory.getNativeWindow(this, awtConfig);
nativeWindow.lockSurface();
try {
glDrawable = GLDrawableFactory.getFactory(profile).createGLDrawable(nativeWindow);
}
finally {
nativeWindow.unlockSurface();
}
glDrawable.setRealized(true);
}
代码示例来源:origin: org.scijava/j3dcore
@Override
void destroyContext(Drawable drawable, Context ctx) {
if (VERBOSE) System.err.println("JoglPipeline.destroyContext()");
JoglDrawable joglDrawable = (JoglDrawable)drawable;
GLContext cOntext= context(ctx);
if (GLContext.getCurrent() == context) {
context.release();
}
context.destroy();
// assuming this is the right point at which to make this call
joglDrawable.getGLDrawable().setRealized(false);
joglDrawable.destroyNativeWindow();
}
代码示例来源:origin: org.jogamp.jogl/jogl-all-noawt
@Override
public final void setRealized(final boolean realized) {
final RecursiveLock _lock = getUpstreamLock();
_lock.lock();
try {
final GLDrawable _drawable = drawable;
if( null == _drawable || realized && ( 0 >= _drawable.getSurfaceWidth() || 0 >= _drawable.getSurfaceHeight() ) ) {
return;
}
_drawable.setRealized(realized);
if( realized && _drawable.isRealized() ) {
sendReshape=true; // ensure a reshape is being send ..
}
} finally {
_lock.unlock();
}
}
代码示例来源:origin: org.jogamp.jogl/jogl
@Override
public final void setRealized(final boolean realized) {
final RecursiveLock _lock = getUpstreamLock();
_lock.lock();
try {
final GLDrawable _drawable = drawable;
if( null == _drawable || realized && ( 0 >= _drawable.getSurfaceWidth() || 0 >= _drawable.getSurfaceHeight() ) ) {
return;
}
_drawable.setRealized(realized);
if( realized && _drawable.isRealized() ) {
sendReshape=true; // ensure a reshape is being send ..
}
} finally {
_lock.unlock();
}
}
代码示例来源:origin: org.scijava/j3dcore
private void doQuery() {
if (alreadyRan)
return;
GLContext cOntext= glDrawable.createContext(null);
int res = context.makeCurrent();
if (res != GLContext.CONTEXT_NOT_CURRENT) {
try {
chooser.init(context);
} finally {
context.release();
}
}
context.destroy();
alreadyRan = true;
glDrawable.setRealized(false);
nativeWindow.destroy();
}
}
代码示例来源:origin: org.jogamp.jogl/jogl
if( destIsRealized && null != aUpSurface ) {
dest.getDelegatedDrawable().setRealized(false);
dest.getDelegatedDrawable().setRealized(true);
代码示例来源:origin: org.jogamp.jogl/jogl-all-noawt
drawable.setRealized(true);
zeroDrawable.setRealized(false);
drawable.setRealized(false);
代码示例来源:origin: org.scijava/j3dcore
glDrawable.setRealized(true);
glDrawable.setRealized(false);
代码示例来源:origin: org.jogamp.jogl/jogl-all-noawt
private void destroySharedGL() {
if( null != sharedGLCtx ) {
if( sharedGLCtx.isCreated() ) {
// Catch dispose GLExceptions by GLEventListener, just 'print' them
// so we can continue with the destruction.
try {
sharedGLCtx.destroy();
} catch (final GLException gle) {
gle.printStackTrace();
}
}
sharedGLCtx = null;
}
if( null != dummyDrawable ) {
final AbstractGraphicsDevice device = dummyDrawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice();
dummyDrawable.setRealized(false);
dummyDrawable = null;
device.close();
}
}
代码示例来源:origin: org.jogamp.jogl/jogl
final ProxySurface zeroSurface = createSurfacelessImpl(device, true, caps, caps, null, 64, 64);
zeroDrawable = createOnscreenDrawableImpl(zeroSurface);
zeroDrawable.setRealized(true);
zeroDrawable.setRealized(false);
代码示例来源:origin: org.jogamp.jogl/jogl-all-noawt
final ProxySurface zeroSurface = createSurfacelessImpl(device, true, caps, caps, null, 64, 64);
zeroDrawable = createOnscreenDrawableImpl(zeroSurface);
zeroDrawable.setRealized(true);
zeroDrawable.setRealized(false);
代码示例来源:origin: org.jogamp.jogl/jogl-all-noawt
zeroDrawable.setRealized(false);
代码示例来源:origin: org.scijava/j3dcore
glDrawble.setRealized(false);
glDrawble.setRealized(true);
代码示例来源:origin: org.jogamp.jogl/jogl-all-noawt
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) {
代码示例来源:origin: org.scijava/j3dcore
glDrawable.setRealized(true);