Code:import codeanticode.glgraphics.*;
import processing.opengl.*;
GLGraphicsOffScreen one;
GLTexture oneTex,twoTex;
int w=400,h=200;
void setup(){
size(w*2,h,GLConstants.GLGRAPHICS);
one = new GLGraphicsOffScreen(this, w, h);
oneTex = new GLTexture(this,w,h);
twoTex=new GLTexture(this,w,h);//
}
void draw(){
one.beginDraw();
one.background(100,100,255);
one.fill(255,0,0);
one.ellipse(mouseX,mouseY,20,20);
one.endDraw();
oneTex=one.getTexture();
image(oneTex, 0,0);
// ------------------------------------------
// copying pixels form one texture to another
oneTex.loadPixels();
oneTex.updateTexture();
twoTex.loadPixels();
twoTex.updateTexture();
for (int i = 0; i < w*h; i++) {
if(red(oneTex.pixels[i])>127){
twoTex.pixels[i]=color(255);
}
}
oneTex.loadTexture();
oneTex.updatePixels();
twoTex.loadTexture();
twoTex.updatePixels();
image(twoTex,w,0);
// CLEAR twoTex
twoTex.loadPixels();
twoTex.updateTexture();
for (int i = 0; i < w*h; i++)
twoTex.pixels[i]=color(0); // CLEAR twoTex SCREEN
twoTex.loadTexture();
twoTex.updatePixels();
}
is there any better way to copy and process pixels from one texture to another. What I am doing is video frame calculations. Ant this code seems to work slow.
Thanks