We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › VeryBad Performance: Converting BApplet to PApplet
Page Index Toggle Pages: 1
VeryBad Performance: Converting BApplet to PApplet (Read 410 times)
VeryBad Performance: Converting BApplet to PApplet
Jul 11th, 2007, 7:21am
 
Hi,

I have an old application I want to convert to use the newest core.jar. Here are some problems I face:

In setup() I create a graphics object grph = new BGraphics(width, height);

First, I cannot use P2D anymore - it tells me: java.lang.RuntimeException: P2D is not yet implemented, use JAVA2D or P3D instead.

So I changed my code to:

size(640, 480, JAVA2D);
grph = new PGraphicsJava2D(width, height, this);

I also had to call grph.loadPixels() in my migrated code - otherwise the pixel[] Array is null which triggers an Exception when I want to manipulate the Array.

Now it does run but probably 10 times slower and using much more CPU power...what is going wrong here? Internally I guess I am using a BufferedImage instead of a toolkit image - is that the reason?

calling loadPixels() happens really fast and isn't called very often - still once I have the pixels[] Array most of the operations should happen on this Array. So I wonder why the performance sucks now that I migrated from BApplet to PApplet?
Is it the drawing with Java2D which takes so much longer then with P2D? I doubt it - it must be the operations on the pixels[] Array or writing back that info to the PGraphicsJava2D object or the BufferedImage it contains? How do I get back the performance?

Cheers,
sb
Re: VeryBad Performance: Converting BApplet to PAp
Reply #1 - Jul 11th, 2007, 7:57am
 
java2d is known to be slower but more accurate. have you read the changes page already?

http://processing.org/reference/changes.html

try switching to P3D instead of Java2D and i think you should use createGraphics instead new ...

http://processing.org/learning/basics/creategraphics.html
http://processing.org/reference/createGraphics_.html

F
Page Index Toggle Pages: 1