Hi,
I'd like to know if that's possible to load the pixels of the offscreen's image (glTexture).
In the code below, it is! but it's like if it was taking the first frame only... I'm quite confused about this one..
thanks
Code:import processing.opengl.*;
import damkjer.ocd.*;
import codeanticode.glgraphics.*;
GLGraphicsOffScreen o;
GLTexture srcTex, bloomMask, destTex;
GLTexture tex0, tex2, tex4, tex8, tex16;
GLTextureFilter extractBloom, blur, blend4, toneMap;
Camera cam;
void setup(){
size(720, 480, GLConstants.GLGRAPHICS);
hint( ENABLE_OPENGL_4X_SMOOTH );
// Loading required filters.
extractBloom = new GLTextureFilter(this, "ExtractBloom.xml");
blur = new GLTextureFilter(this, "Blur.xml");
blend4 = new GLTextureFilter(this, "Blend4.xml");
toneMap = new GLTextureFilter(this, "ToneMap.xml");
destTex = new GLTexture(this, width, height);
// Initializing bloom mask and blur textures.
bloomMask = new GLTexture(this, width, height, GLTexture.FLOAT);
tex0 = new GLTexture(this, width, height, GLTexture.FLOAT);
tex2 = new GLTexture(this, width / 2, height / 2, GLTexture.FLOAT);
tex4 = new GLTexture(this, width / 4, height / 4, GLTexture.FLOAT);
tex8 = new GLTexture(this, width / 8, height / 8, GLTexture.FLOAT);
tex16 = new GLTexture(this, width / 16, height / 16, GLTexture.FLOAT);
cam = new Camera(this, 0, 0, 300);
o = new GLGraphicsOffScreen(this, width, height, true, 4);
frameRate(30);
}
void draw(){
float fx = 0.2;
float fy = 0.4;
srcTex = o.getTexture();
o.beginDraw();
o.background(0);
cam.circle(0.05);
cam.feed();
o.stroke(0);
o.pushMatrix();
o.rotateX(QUARTER_PI);
o.rotateY(-QUARTER_PI);
o.rotateZ(QUARTER_PI);
o.fill(255,0,0);
o.box(140);
o.popMatrix();
o.pushMatrix();
o.fill(50,50,50);
o.box(150);
o.popMatrix();
o.endDraw();
// Extracting the bright regions from input texture.
extractBloom.setParameterValue("bright_threshold", fx);
extractBloom.apply(srcTex, tex0);
// Downsampling with blur.
tex0.filter(blur, tex2);
tex2.filter(blur, tex4);
tex4.filter(blur, tex8);
tex8.filter(blur, tex16);
// Blending downsampled textures.
blend4.apply(new GLTexture[]{tex2, tex4, tex8, tex16}, new GLTexture[]{bloomMask});
// Final tone mapping into destination texture.
toneMap.setParameterValue("exposure", fy);
toneMap.setParameterValue("bright", fx);
toneMap.apply(new GLTexture[]{srcTex, bloomMask}, new GLTexture[]{destTex});
image(destTex, 0, 0, width, height);
///////////////////////////////////////////
///////////////////////////////////////////
//THE PROBLEM ..
int halfImage = width*height/2;
loadPixels();
for (int i = 0; i < halfImage; i++) {
pixels[i+halfImage] = pixels[i];
}
updatePixels();
}