From: Kenneth B. R. <kbr...@al...> - 2001-11-08 16:58:56
|
> I read somewhere deriving from GLCanvas was the "old way" of doing things. > Is there a "new way", and if so, which of the two gives the best > performance? The new mechanism is a listener mechanism which avoids subclassing. It offers higher performance, especially for GLAnimCanvas, because in certain circumstances OpenGL context switches can be avoided. (The details of this are hidden from the programmer.) To use this new mechanism: - Create a gl4java.GLCapabilities object indicating the use of RGBA mode, etc. - Pass this capabilities object to gl4java.drawable.GLDrawableFactory.getFactory(). create[type] - Call addGLEventListener on the resulting GLDrawable to set up your listener, which should implement at least init() and display(). For highest performance: - Call GLDrawableFactory.createGLAnimCanvas() - Call setUseRepaint(false), setUseFpsSleep(false), and setUseYield(false) on the resulting GLAnimCanvas Note on GLJPanel: the implementation currently renders to an off-screen buffer and copies the pixels to the lightweight component. This leads to slowdowns over GLAnimCanvas because the rendering is not hardware-accelerated and because of the copying overhead. It is possible that the implementation could be changed to walk the lightweight component hierarchy to find the bounds of the GLJPanel within its parent heavyweight component and clip the OpenGL rendering region to fit (if the GLJPanel itself isn't overlapped by another lightweight component), which should speed it up significantly, though this kind of code is tricky to write. |