We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello,
I have a 2D tile game going in processing. I just added scaling by {scale(zoom);} and noticed that going -1 on the zoom made my frames draw way quicker. I understood that processing handles drawing images in an bottom to top order and therefore drawing tiles upside down lets it overwrite previous tiles in one swoop. Rather than inserting every tile overwrite separately. The problem is that i need overwriting to happen the right way up, not upside down.
My question is: Is there a way to set how is code drawn to the screen in processing?. To have the processing draw pixels on top first. Renderer is default (JAVA2D)
If there is no way to change that behavior i can just stick with the lower framerate.
Answers
I have just found out about the experimental FX2D renderer and it works great here, but this renderer has many bugs. I would prefer JAVA2D if this can be done.
Can you share a simple demo sketch (MVCE) to demonstrate the slowdown / speedy-up you are seeing with scale(-1)?
When you say "way quicker" what kind of then difference / framerate do you mean?
On JAVA2D textures right side up i have around 11-15 frames. But when i call scale with a negative number before each draw the textures get upside down due to how negative scale works in math. then the framerate gets well above 40 for my eyes. I have pinned it down to upside down texturing by calling rotate(radians(180)); and having the same effect.
FX2D is fast enough to give a good framerate in texturing both ways, though it is buggy and causes problems with the key variable. I'm going to move the code to a different PC for OpenGL support and see if P2D runs good.
i cant replicate the issue without posting the entire code as it has to do with drawing 500 image tiles every frame and have them ovewrite the pervios ones in sme degree. The entire code is needed for such operation and i don't want to open it up.
If you can't get a demo sketch that replicates the problem, the reason probably is an error in your full code.
You can try using the Video Export library to create a small video clip showing your problem. However, the best way is to get a small complete runnable code.
Kf
I got OpenGL support and P2D gives good enough framerate. Just a quick note that JAVA2D doesn't like drawing images over images above many times per frame, but is fine with drawing the same amount of images over images that are below the current one.