Hi,
I’m trying to understand the gpuParticleSystem example and have been playing around loading data to FBOs and reading them back, but there is a problem that I cannot figure out.
When I load data to an FBO with getTextureReference().loadData(.....)
everything is fine. But when I try to read it back like this in update()
and print just for debugging, some of the pixels are always changing. I tried to wrap it to fbo.begin()/end()
as well but didn’t make any difference.
ofPixels pixels;
fbo1.getTextureReference().readToPixels(pixels);
ofLog(OF_LOG_NOTICE) << "FBO1";
for(int x = 0; x < textureRes; x++){
for(int y = 0; y < textureRes; y++){
ofLog(OF_LOG_NOTICE) << x << " " << y << ": " << pixels.getColor(x, y);
}
}
And the output is something like:
[notice ] FBO1
[notice ] 0 0: 82, 62, 0, 255
[notice ] 0 1: 47, 32, 74, 255
[notice ] 1 0: 166, 149, 0, 255
[notice ] 1 1: 94, 0, 241, 255
[notice ] FBO1
[notice ] 0 0: 82, 62, 0, 255
[notice ] 0 1: 10, 32, 74, 255
[notice ] 1 0: 166, 149, 0, 255
[notice ] 1 1: 94, 0, 241, 255
[notice ] FBO1
[notice ] 0 0: 82, 62, 0, 255
[notice ] 0 1: 11, 160, 74, 255
[notice ] 1 0: 166, 149, 0, 255
[notice ] 1 1: 94, 0, 241, 255
I’m attaching the example code.
Thanks so much for the help!
pingPongExample.zip (35.2 KB)