Unexpected lag after using new 4k images

Hello,

I was in the process of programming a custom launcher for a game when I suddenly realized that I need to make a 4k version for 4k resolution monitors obviously, because the sketch window would appear smaller. I changed all my png images to 4k images and did a monitor resolution check in the void settings() function. Because I thought it would affect performance to constantly resize the image in draw(), I did ALL the resizing in setup() (PImage.resize(int, int)). I try to run the sketch and all my animations are lagging as heck. I check the FPS using println(frameRate) and it barely reaches 30, while I had my sketch set at a high FPS for smooth animations. I didn't change anything in the draw() except for a multiplicator variable in the images' coordinates but I refuse to believe calling reapeatedly an int would cause such lag. Since I'm resizing them in setup(), why is it lagging so much since I changed my images?

Thanks

EDIT: I'm new to this forum, if I didn't file my question in the right forum section, please let me know. Also, I forgot to tag this as a question.

Tagged:

Answers

  • Answer ✓

    The simple fact that canvas's size() is now 4K, already slows down the sketch immensely. :(
    If you're not using P3D, you may try out FX2D renderer instead. [-O<

  • Thank you very much! Can you explain why FX2D fixes this? Cheers

  • I haven't said anything about fix. Only that FX2D would help out the performance.
    By any chance, has it worked? @-)

  • The FPS is reaching the frameRate(120) I set for the sketch, animations are working smoothly now. But, while I think about it, I do not have a 4k monitor and cannot test it. Could the 4k version be lagging while the "normal" version does not?

  • I don't have 1 either. But the bigger the # of pixels, the slower it becomes. =;

Sign In or Register to comment.