Per-pixel manipulations in Processing 2.0
in
Library and Tool Development
•
2 years ago
I was reading the upcoming changes for Processing 2.0
P2D and P3D have been removed. Using P2D will simply use the default (JAVA2D) renderer, and P3D will try to use OpenGL. We made this change to simplify things for us, and focus our efforts on better feature parity across other implementations. This fits better with the situation on Android and with JavaScript, for instance. This will cause some sketches to actually run slower, but the bottom line is that we simply don't have anyone to help maintain all of this extra code. We hope to sort out the performance problems over time—if you see something weird, please report a bug.
And on a lesser note:
textMode(SCREEN) has been removed. SCREEN was a super fast/efficient way of rendering text with P2D and P3D, but since they're going bye-bye and it's actually slower in the remaining renderers, it's going away.
I understand the reasoning, but I also tend to do a LOT of per-pixel manipulation. So I figured: why not start a topic on how to change your code to keep the sketches reasonably fast, or maybe make them even faster?
Here's what I'm already doing with GLGraphics on computers that fully support textures:
- GLTexture GL2D; // I suck at good variable names
- void setup(){
- GL2D = new GLTexture(this, width, height);
- GL2D.clear(0);
- }
- void display(){
- //replaces loadPixels()
- GL2D.updateTexture();
- //replaces pixels[something] = something
- GL2D.pixels[something] = something
- //replaces updatePixels();
- GL2D.loadTexture();
- GL2D.render();
- }
I haven't benchmarked it against P2D, but logically, as long as you keep the transfer of pixeldata between the texture and regular RAM to a minimum (that is: don't run
GL2D.updateTexture()/GL2D.loadTexture() too often, preferably only once per loop)
it should be faster. I mostly use it because it can be combined with shaders.
Sadly, this doesn't work
on my netbook (crashes). If I use the current built-in OpenGL renderer there, I need to update the screen twice to avoid flickering. That is to say: once, and then in the next draw() loop. I'll look up the code I use for that later (haven't acces to it right now). Don't recall if it's faster or slower than P2D, will test that.
So, who else has ideas?