Re: Switched to JDK 1.7, GLCanvas buggy on mac
Posted by
Xerxes Rånby on
Jul 11, 2012; 11:52am
URL: https://forum.jogamp.org/Switched-to-JDK-1-7-GLCanvas-buggy-on-mac-tp4025496p4025497.html
2012-07-11 12:56, Fauldsh [via jogamp] skrev:
I haven't started a bug report because I'm not
entirely sure whether this is a bug in jogl or elsewhere (or how
to submit a bug report).
I recently started using some Java 1.7 features in a project that
I've been working on in both Windows and OSX. This worked fine in
Windows but now GLCanvas is behaving weirdly in OSX. The best way
to describe it is that the contents if GLCanvas is resizing
randomly. I provided a video of it happening in a stripped down
test case:
VIDEO: http://www.youtube.com/watch?v=4cXzDPvsJYA
CODE: https://gist.github.com/3089608
The console output reveals that the canvas is actually maintaining
the appropriate size despite the appearance to the contrary.
The error "XXXX-XX-XX XX:XX:XX.XXX java[XXXX:XXX] invalid
drawable" is received each time it renders inaccurately.
In my actual application this is happening not just when resizing
(I haven't nailed down exactly why it's happening at the
particular point it is but it's just after adding more objects to
render).
Remember that Swing and AWT is a single threaded framework, you must
guarantee that Swing and AWT calls runs on the Event Dispatch Thread
or strange things will/may happen.
If you want the full background then read the JavaSE swing
concurrency tutorial:
http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html
For example try use the SwingUtilities.invokeLater to make sure that
swing and awt updates happens on the Event Dispatch Thread.
Change
canvas.setPreferredSize(new Dimension(drawable.getWidth(), drawable.getHeight()));
to
SwingUtilities.invokeLater(new Runnable() {
public void run() {
canvas.setPreferredSize(new Dimension(drawable.getWidth(), drawable.getHeight()));
}
});
and change
public static void main(String
... args) {
new Main();
}
to
public static void main(String ...
args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new Main();
}
});
}
I hope this helps.