热门标签 | 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);

推荐阅读
  • Java学习笔记之面向对象编程(OOP)
    本文介绍了Java学习笔记中的面向对象编程(OOP)内容,包括OOP的三大特性(封装、继承、多态)和五大原则(单一职责原则、开放封闭原则、里式替换原则、依赖倒置原则)。通过学习OOP,可以提高代码复用性、拓展性和安全性。 ... [详细]
  • 配 ... [详细]
  • 如何自行分析定位SAP BSP错误
    The“BSPtag”Imentionedintheblogtitlemeansforexamplethetagchtmlb:configCelleratorbelowwhichi ... [详细]
  • Java太阳系小游戏分析和源码详解
    本文介绍了一个基于Java的太阳系小游戏的分析和源码详解。通过对面向对象的知识的学习和实践,作者实现了太阳系各行星绕太阳转的效果。文章详细介绍了游戏的设计思路和源码结构,包括工具类、常量、图片加载、面板等。通过这个小游戏的制作,读者可以巩固和应用所学的知识,如类的继承、方法的重载与重写、多态和封装等。 ... [详细]
  • Iamtryingtomakeaclassthatwillreadatextfileofnamesintoanarray,thenreturnthatarra ... [详细]
  • 向QTextEdit拖放文件的方法及实现步骤
    本文介绍了在使用QTextEdit时如何实现拖放文件的功能,包括相关的方法和实现步骤。通过重写dragEnterEvent和dropEvent函数,并结合QMimeData和QUrl等类,可以轻松实现向QTextEdit拖放文件的功能。详细的代码实现和说明可以参考本文提供的示例代码。 ... [详细]
  • 本文讨论了一个关于cuowu类的问题,作者在使用cuowu类时遇到了错误提示和使用AdjustmentListener的问题。文章提供了16个解决方案,并给出了两个可能导致错误的原因。 ... [详细]
  • JDK源码学习之HashTable(附带面试题)的学习笔记
    本文介绍了JDK源码学习之HashTable(附带面试题)的学习笔记,包括HashTable的定义、数据类型、与HashMap的关系和区别。文章提供了干货,并附带了其他相关主题的学习笔记。 ... [详细]
  • 内容多有疏漏,有问题欢迎提出目录java内存模型的概念原子性(Atomicity)可见性(Visibility࿰ ... [详细]
  • 开发笔记:PyQt5QSlider(滑动条)控件使用
    本文由编程笔记#小编为大家整理,主要介绍了PyQt5-QSlider(滑动条)控件使用相关的知识,希望对你有一定的参考价值。QSlider控件提供了一个垂直或者水平的滑动条,滑 ... [详细]
  • vue使用
    关键词: ... [详细]
  • Linux重启网络命令实例及关机和重启示例教程
    本文介绍了Linux系统中重启网络命令的实例,以及使用不同方式关机和重启系统的示例教程。包括使用图形界面和控制台访问系统的方法,以及使用shutdown命令进行系统关机和重启的句法和用法。 ... [详细]
  • Java序列化对象传给PHP的方法及原理解析
    本文介绍了Java序列化对象传给PHP的方法及原理,包括Java对象传递的方式、序列化的方式、PHP中的序列化用法介绍、Java是否能反序列化PHP的数据、Java序列化的原理以及解决Java序列化中的问题。同时还解释了序列化的概念和作用,以及代码执行序列化所需要的权限。最后指出,序列化会将对象实例的所有字段都进行序列化,使得数据能够被表示为实例的序列化数据,但只有能够解释该格式的代码才能够确定数据的内容。 ... [详细]
  • JVM 学习总结(三)——对象存活判定算法的两种实现
    本文介绍了垃圾收集器在回收堆内存前确定对象存活的两种算法:引用计数算法和可达性分析算法。引用计数算法通过计数器判定对象是否存活,虽然简单高效,但无法解决循环引用的问题;可达性分析算法通过判断对象是否可达来确定存活对象,是主流的Java虚拟机内存管理算法。 ... [详细]
  • Python正则表达式学习记录及常用方法
    本文记录了学习Python正则表达式的过程,介绍了re模块的常用方法re.search,并解释了rawstring的作用。正则表达式是一种方便检查字符串匹配模式的工具,通过本文的学习可以掌握Python中使用正则表达式的基本方法。 ... [详细]
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社区 版权所有