use of com.jogamp.newt.opengl.GLWindow in project narchy by automenta.
the class JoglSpace method updateWindowInfo.
private void updateWindowInfo() {
GLWindow rww = window;
if (rww == null)
return;
if (!rww.isRealized() || !rww.isVisible() || !rww.isNativeValid()) {
return;
}
if (gettingScreenPointer.compareAndSet(false, true)) {
window.getScreen().getDisplay().getEDTUtil().invoke(false, () -> {
try {
Point p = rww.getLocationOnScreen(new Point());
windowX = p.getX();
windowY = p.getY();
} finally {
gettingScreenPointer.set(false);
}
});
}
}
use of com.jogamp.newt.opengl.GLWindow in project narchy by automenta.
the class JoglWindow method window.
static GLWindow window(GLCapabilitiesImmutable config, JoglWindow j) {
GLWindow w = GLWindow.create(config);
w.addGLEventListener(j);
w.addWindowListener(j);
return w;
}
use of com.jogamp.newt.opengl.GLWindow in project narchy by automenta.
the class PreviewMain method main.
public static void main(String... argv) throws Exception {
// Frame frame = new Frame("Vorschau der Szene");
/*
GLCapabilities caps = new GLCapabilities(GLProfile.getDefault());
caps.setStencilBits(1);
GLJPanel canvas = new GLJPanel(caps);
*/
// http://jogamp.org/git/?p=jogl-demos.git;a=blob;f=src/demos/es2/RawGL2ES2demo.java;hb=HEAD
GLCapabilities caps = new GLCapabilities(GLProfile.getDefault());
// We may at this point tweak the caps and request a translucent drawable
caps.setBackgroundOpaque(false);
caps.setStencilBits(1);
caps.setHardwareAccelerated(true);
GLWindow glWindow = GLWindow.create(caps);
// Registieren des OpenGL-Objekts:
glWindow.addGLEventListener(new OpenGLBox());
// Animator erzeugen:
final Animator animator = new Animator();
animator.add(glWindow);
glWindow.addWindowListener(new WindowAdapter() {
@Override
public void windowDestroyNotify(com.jogamp.newt.event.WindowEvent windowEvent) {
animator.stop();
System.exit(0);
}
@Override
public void windowGainedFocus(com.jogamp.newt.event.WindowEvent windowEvent) {
animator.start();
}
@Override
public void windowLostFocus(com.jogamp.newt.event.WindowEvent windowEvent) {
animator.stop();
}
});
// Fenster anzeigen:
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
glWindow.setSize(d.width, d.height);
// glWindow.setExtendedState(Frame.MAXIMIZED_BOTH);
glWindow.setVisible(true);
}
use of com.jogamp.newt.opengl.GLWindow in project narchy by automenta.
the class NEWTWin method shutdownImpl.
private void shutdownImpl(boolean withScreen) {
if (null != window) {
deactivateGLContext();
final GLWindow _window = window;
window = null;
_window.destroy();
// if( null != Globals.applet && null != canvasObj) {
// final java.applet.Applet applet = (java.applet.Applet) Globals.applet;
// final NativeSurface NativeSurface = (NativeSurface) canvasObj;
// final Runnable appletRemoveAction = () -> {
// applet.remove(NativeSurface);
// applet.validate();
// };
// if( java.awt.EventQueue.isDispatchThread() ) {
// appletRemoveAction.run();
// } else {
// try {
// java.awt.EventQueue.invokeAndWait(appletRemoveAction);
// } catch (Throwable e) {
// System.err.println("Catched "+e.getClass().getName()+": "+e.getMessage());
// e.printStackTrace();
// }
// }
// NativeSurface.setNEWTChild(null);
// canvasObj = null;
// }
}
if (withScreen && null != screen) {
try {
screen.destroy();
} catch (Throwable e) {
System.err.println("Catched " + e.getClass().getName() + ": " + e.getMessage());
e.printStackTrace();
}
screen = null;
}
}
use of com.jogamp.newt.opengl.GLWindow in project tdme by andreasdr.
the class PhysicsTest2 method main.
/**
* Main
* @param args
*/
public static void main(String[] args) {
Logger.getLogger("").setLevel(Level.WARNING);
// create GL canvas
GLProfile glp = Engine.getProfile();
GLCapabilities caps = new GLCapabilities(glp);
// create GL window
GLWindow glWindow = GLWindow.create(caps);
glWindow.setTitle("PhysicsTest2");
// animator
FPSAnimator animator = new FPSAnimator(glWindow, 60);
// tdme level editor
PhysicsTest2 physicsTest2 = new PhysicsTest2();
// GL Window
glWindow.addGLEventListener(physicsTest2);
glWindow.setSize(800, 600);
glWindow.setVisible(true);
glWindow.addKeyListener(physicsTest2);
glWindow.addMouseListener(physicsTest2);
glWindow.addWindowListener(physicsTest2);
// start animator
animator.setUpdateFPSFrames(3, null);
animator.start();
}
Aggregations