From: Jacob M. <ja...@ma...> - 2002-02-08 10:56:51
|
Hi, My first gl4java application was written using the old model where you derive from GLAnimCanvas. I have just ported it to the new model where I just implement GLEventListener. It all works fine with one exception: For the very first frame display() is called before reshape(). Reshape is then called for the second frame and all is good. However it is custom in all the OpenGL implementations I have seen to call the equivalent of reshape() before any calls to display(). So I think this is a bug. A workaround is simply to call reshape() as the last instruction in init(). ------ And then a little tip: I have noted that many demos do this or something similar: Dimension ps = applet.getPreferredSize(); f.setBounds(-100,-100,99,99); f.setVisible(true); f.setVisible(false); f.setVisible(true); Insets i = f.getInsets(); f.setBounds(0,0, ps.width+i.left+i.right, ps.height+i.top+i.bottom); f.setVisible(true); Showing the frame seems to be needed to make the insets be correct. However, I have found that it can be done simpler and faster as (I have only tested it with applications not applets): Dimension ps = applet.getPreferredSize(); f.pack(); Insets i = f.getInsets(); f.setBounds(0,0, ps.width+i.left+i.right, ps.height+i.top+i.bottom); f.setVisible(true); --------------------- PS: Thanks Kenneth for answering my newbie question a few days ago. I have since then learned much I feel that I am quite capable of writing gl4java apps. Sincerely, Jacob Marner |