From 89fb76eea970f59ca8e1dc842eb20086cad5f93a Mon Sep 17 00:00:00 2001 From: Julien Gouesse Date: Sun, 17 Mar 2013 21:37:07 +0100 Subject: Adds setVSyncEnabled(boolean) into AWT-based canvases --- .../main/java/com/ardor3d/framework/jogl/JoglAwtCanvas.java | 12 ++++++++++++ .../java/com/ardor3d/framework/jogl/JoglNewtAwtCanvas.java | 10 ++++++++++ 2 files changed, 22 insertions(+) (limited to 'ardor3d-jogl/src/main/java/com') diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglAwtCanvas.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglAwtCanvas.java index 36cc77e..6e3d140 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglAwtCanvas.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglAwtCanvas.java @@ -13,6 +13,8 @@ package com.ardor3d.framework.jogl; import java.lang.reflect.InvocationTargetException; import java.util.concurrent.CountDownLatch; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLRunnable; import javax.media.opengl.awt.GLCanvas; import javax.swing.SwingUtilities; @@ -90,4 +92,14 @@ public class JoglAwtCanvas extends GLCanvas implements Canvas { public JoglCanvasRenderer getCanvasRenderer() { return _canvasRenderer; } + + public void setVSyncEnabled(final boolean enabled) { + invoke(true, new GLRunnable() { + @Override + public boolean run(final GLAutoDrawable glAutoDrawable) { + glAutoDrawable.getGL().setSwapInterval(enabled ? 1 : 0); + return false; + } + }); + } } diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtAwtCanvas.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtAwtCanvas.java index fa91851..0de1c99 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtAwtCanvas.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtAwtCanvas.java @@ -93,4 +93,14 @@ public class JoglNewtAwtCanvas extends NewtCanvasAWT implements Canvas, NewtWind public GLWindow getNewtWindow() { return (GLWindow) getNEWTChild(); } + + public void setVSyncEnabled(final boolean enabled) { + getNewtWindow().invoke(true, new GLRunnable() { + @Override + public boolean run(final GLAutoDrawable glAutoDrawable) { + glAutoDrawable.getGL().setSwapInterval(enabled ? 1 : 0); + return false; + } + }); + } } -- cgit v1.2.3