We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › GLTextures question.
Page Index Toggle Pages: 1
GLTextures question. (Read 956 times)
GLTextures question.
Dec 9th, 2009, 3:27am
 
Hello.  I have made a sketch runs with opencv, glgraphics, gltextures.
I want to call image in the dataface in random order every frame.
To avoid memory leak, I used GLTextures instead of loadImage on draw();  How can I make this sketch feed random images every frame?

thanks

--------



int mapping1 = round(random(0,imgs1.length-1));

void setup(){

 rimg1 = loadImage(imgs1[mapping1]);

 tex1 = new GLTexture(this, 85,85);

 tex1.loadTexture(imgs1[mapping1]);

 rimg1 = new PImage(tex1.width, tex1.height);

 tex1.getImage(rimg1);

}

void draw(){

image(rimg1,0,0,100,100);

}
Re: GLTextures question.
Reply #1 - Dec 9th, 2009, 3:56am
 
that code doesn't appear to be using tex1 and i think the GLTexture thing isn't going to help anyway.

if you have 100 images and you want to display them at random per frame then there's no avoiding loading them all into memory at once (in setup) - loading them as needed (in draw) will be too slow. if your images are only 100x100 as per your example then it won't take too much memory for each one.

(you could have a buffer containing, say, 10 images and load any others you need from disk into an image slot that isn't being used. do it in a separate thread so as not to cause too much delay in the draw())
Re: GLTextures question.
Reply #2 - Dec 11th, 2009, 3:21pm
 
Hello
Well I wanted to load nearly 500images in setup, these images  will be replaced to new images later.  so the images in the memory can't be updated. that's the problem..
Page Index Toggle Pages: 1