Ubuntu 11.10 64bit and AWT vs. NEWT
Posted by Martin Hegedus on Jan 12, 2012; 9:01pm
URL: https://forum.jogamp.org/Ubuntu-11-10-64bit-and-AWT-vs-NEWT-tp3654908.html
Just recently installed Ubuntu 11.10 64bit and am having problems running jogl applications. When I try to run a jogl code all I get is a frozen window and the GLCanvas is white. So it hasn't repainted itself to black yet. I installed gluegen and jogl according to the build instructions. I did run junit.run and things seemed resonable, well until the windowing system froze, but that may be because of Ubuntu's Unity windowing system.
So then I grabbed the TestGears programs. Strangely, TestGearsAWT does not work but TestGearsNEWT does work. I did not go through ant when running the TestGears programs since I'm not familiar with how that is done. I just copied the TestGearsAWT.java, TestGearsNEWT.java and Gears.java files and got them to compile.
At the top level, the only difference is with using GLCanvas or GLWindow. I dug into GLWindow.java but can't figure out the magic which makes TestGearsNEWT work. Anyone have any ideas? Both programs work under SUSE 10.1 (32 and 64). The machine which now has Ubuntu was configured with SUSE 10.1 64, and jogl worked with that too.
Here is the source code for TestGearsAWT
import java.awt.Frame;
import javax.media.opengl.awt.GLCanvas;
import com.jogamp.opengl.util.Animator;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLProfile;
import java.lang.reflect.InvocationTargetException;
public class TestGearsAWT {
static long duration = 500; // ms
public static void main(String args[]) {
try {
(new TestGearsAWT()).runTestGL();
} catch (Exception e) {
}
}
protected void runTestGL() throws InterruptedException, InvocationTargetException {
final Frame glWindow = new Frame();
glWindow.setTitle("Gears AWT Test");
final GLCanvas glCanvas = new GLCanvas(new GLCapabilities(GLProfile.getDefault()));
glWindow.add(glCanvas);
glCanvas.addGLEventListener(new Gears());
Animator animator = new Animator(glCanvas);
glWindow.setSize(512,512);
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
glWindow.setVisible(true);
}});
animator.setUpdateFPSFrames(60, System.err);
animator.start();
while(animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
Thread.sleep(100);
}
animator.stop();
glWindow.setVisible(false);
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
glWindow.remove(glCanvas);
glWindow.dispose();
}});
}
}
Here is the source code for TestGearsNEWT.java
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.util.Animator;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLProfile;
public class TestGearsNEWT {
static long duration = 500; // ms
public static void main(String args[]) {
try {
(new TestGearsNEWT()).runTestGL();
} catch (Exception e) {
}
}
protected void runTestGL() throws InterruptedException {
GLWindow glWindow = GLWindow.create(new GLCapabilities(GLProfile.getDefault()));
glWindow.setTitle("Gears NEWT Test");
glWindow.addGLEventListener(new Gears());
Animator animator = new Animator(glWindow);
glWindow.setSize(512,512);
glWindow.setVisible(true);
animator.setUpdateFPSFrames(60, System.err);
animator.start();
while(animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
Thread.sleep(100);
}
animator.stop();
glWindow.destroy();
}
}