热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

com.jogamp.opengl.GLDrawable.setRealized()方法的使用及代码示例

本文整理了Java中com.jogamp.opengl.GLDrawable.setRealized()方法的一些代码示例,展示了GLDrawable.se

本文整理了Java中com.jogamp.opengl.GLDrawable.setRealized()方法的一些代码示例,展示了GLDrawable.setRealized()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GLDrawable.setRealized()方法的具体详情如下:
包路径:com.jogamp.opengl.GLDrawable
类名称:GLDrawable
方法名:setRealized

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:

  • Update the GLCapabilities, which are associated with the attached NativeSurface's AbstractGraphicsConfiguration.
  • Release the lock with NativeSurface#unlockSurface().

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);

推荐阅读
  • 本文详细介绍了 org.apache.commons.io.IOCase 类中的 checkCompareTo() 方法,通过多个代码示例展示其在不同场景下的使用方法。 ... [详细]
  • 本文详细解析了Java中hashCode()和equals()方法的实现原理及其在哈希表结构中的应用,探讨了两者之间的关系及其实现时需要注意的问题。 ... [详细]
  • 本文探讨了如何在Classic ASP中实现与PHP的hash_hmac('SHA256', $message, pack('H*', $secret))函数等效的哈希生成方法。通过分析不同实现方式及其产生的差异,提供了一种使用Microsoft .NET Framework的解决方案。 ... [详细]
  • 使用JS、HTML5和C3创建自定义弹出窗口
    本文介绍如何结合JavaScript、HTML5和C3.js来实现一个功能丰富的自定义弹出窗口。通过具体的代码示例,详细讲解了实现过程中的关键步骤和技术要点。 ... [详细]
  • 优雅实现 jQuery 折叠展开下拉菜单
    本文介绍了一种使用 jQuery 实现的优雅折叠和展开效果的下拉菜单,通过简单的 HTML 结构和 CSS 样式,结合 jQuery 脚本,可以轻松创建出美观且功能强大的下拉菜单。 ... [详细]
  • 本题探讨了在一个有向图中,如何根据特定规则将城市划分为若干个区域,使得每个区域内的城市之间能够相互到达,并且划分的区域数量最少。题目提供了时间限制和内存限制,要求在给定的城市和道路信息下,计算出最少需要划分的区域数量。 ... [详细]
  • 本文详细探讨了HTML表单中GET和POST请求的区别,包括它们的工作原理、数据传输方式、安全性及适用场景。同时,通过实例展示了如何在Servlet中处理这两种请求。 ... [详细]
  • 本文详细介绍了 Java 中的 org.apache.hadoop.registry.client.impl.zk.ZKPathDumper 类,提供了丰富的代码示例和使用指南。通过这些示例,读者可以更好地理解如何在实际项目中利用 ZKPathDumper 类进行注册表树的转储操作。 ... [详细]
  • 对象自省自省在计算机编程领域里,是指在运行时判断一个对象的类型和能力。dir能够返回一个列表,列举了一个对象所拥有的属性和方法。my_list[ ... [详细]
  • 反向投影技术主要用于在大型输入图像中定位特定的小型模板图像。通过直方图对比,它能够识别出最匹配的区域或点,从而确定模板图像在输入图像中的位置。 ... [详细]
  • JavaScript 基础语法指南
    本文详细介绍了 JavaScript 的基础语法,包括变量、数据类型、运算符、语句和函数等内容,旨在为初学者提供全面的入门指导。 ... [详细]
  • 本文介绍如何使用 Android 的 Canvas 和 View 组件创建一个简单的绘图板应用程序,支持触摸绘画和保存图片功能。 ... [详细]
  • 2018-2019学年第六周《Java数据结构与算法》学习总结
    本文总结了2018-2019学年第六周在《Java数据结构与算法》课程中的学习内容,重点介绍了非线性数据结构——树的相关知识及其应用。 ... [详细]
  • 本文详细介绍了如何使用 HTML 和 CSS 对文件上传按钮进行样式美化,使用户界面更加友好和美观。 ... [详细]
  • 本文详细介绍了Java库XChart中的XYSeries类下的setLineColor()方法,并提供了多个实际应用场景的代码示例。 ... [详细]
author-avatar
Happy_Kelly尊荣
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有