vialab / SMT

Simple Multi-Touch (SMT) Toolkit
http://vialab.science.uoit.ca/smt
GNU General Public License v3.0
43 stars 18 forks source link

Resize extra_graphics when Zone is resized or scaled #190

Closed JimWallace closed 10 years ago

JimWallace commented 10 years ago

extra_graphics (Zone back buffer) needs to be resized as Zones are resized. Currently, if a Zone is scaled up it loses fidelity rather quickly (although we're running this on a 16MP display, so it may be more obvious for us).

kiwistrongis commented 10 years ago

There's an additional condition where extra_graphics should be resized, but isn't - Zone.setSize().

kiwistrongis commented 10 years ago

done as of abbe18d.

Programmers can call Zone.refreshResolution() ( or ViewportZone.refresh() ) after a resize or scale to cause an automatic resize of an indirect zone's graphics object. Alternatively, Zone.setResolution( Dimension) can manually set the desired resolution of an indirect zone's graphics object. See examples/Tests/viewport line 78 for an example. When the viewport tutorial is completed, that will contain an example of this too.

This is not done automatically on resize, because of a processing limitation. It is currently impossible to resize a PGraphics3D object after creation. This means we must create a new graphics object on each call of Zone.setResolution( Dimension). Unfortunately processing graphics objects also cannot be destroyed, so refreshing on each frame a zone is resizing on causes massive fps lag and horrible memory leak. Refreshing after the zone resize has completed still has a small memory leak, but this is acceptable. We now leave it to the programmer to decide when to invoke a refresh.