brandonborkholder / glg2d

Graphics2D wrapper for JOGL
77 stars 31 forks source link

use of pushMatrix and popMatrix #14

Closed hervegirod closed 11 years ago

hervegirod commented 11 years ago

There is a limit of 30 in the matrix stack in most OpenGL implementations. When using Swing its current to go outside this limit, which will trigger this error. I suggest using a loadMatrix instead, and perform the matrix composition in the Java world

brandonborkholder commented 11 years ago

You mean because of deep Swing hierarchies? That makes sense. I'd like to see if there's any performance penalty for doing the matrix manipulation in Java.

hervegirod commented 11 years ago

Yes, we had a problem when using JTable for example. We changed the code ourselves, but unfortunately we still use the version before you did a huge refactoring so I don't think that the patch would be helpful to you. However the code is there, we just changed the create() method of the GLGraphics2D class which is used whenever Swing opens a new child: http://j661.svn.sourceforge.net/viewvc/j661/j661/trunk/src/ogl/glg2d/GLGraphics2D.java?revision=2602&view=markup

We did not find any performance penalty in our use cases (huge Swing hierarchies), but it may depend on the use case. However we use pretty much any kind of standard Swing widgets. We also have custom widgets which draw vector graphic content on them.

hervegirod commented 11 years ago

And the dispose() also of course, sorry for not mentioning it. But there is maybe a simpler way to do the same thing.

brandonborkholder commented 11 years ago

I'm glad to see you thought through the use of OpenGL stencils for non-rectangular clips. This is something I hadn't looked at yet.

hervegirod commented 11 years ago

ah yes,I forgot about that.

brandonborkholder commented 11 years ago

I fixed the matrix issue with 5058cf967305d872cfd6b47f021a163459ffa49d. Thanks for reporting it.