GLTexture are white rendered
in
Contributed Library Questions
•
2 years ago
Hi,
I'vo got problem while loading a lot of images with multithread. I load each image in a separated thread and when is done I resize the image and put it into a GLTexture with putImage on the main thread. When I click on one image, I load again the same image but full size and put it into another GLTexture. All seem to work fine, but while opening more images the smallest ones loose image and becomes white randomly. The same happens randomly while open a big one. I don't know if is something related to the delete() method of GLTexture.
This is a look like piece of code:
private PImage image;
private GLTexture texture;
private boolean loading;
public void draw()
{
// load the image only 1 time
if (image == null && loading == false)
{
loading = true;
loadImageWithThread("image.jpg");
}
else if (image != null)
{
texture
=
new
GLTexture(this
);
texture.putImage(image);
image.delete();
image = null;
}
if (texture != null && texture.available())
{
image(texture, 0, 0);
}
}
private loadImageWithThread(String filename)
{
Thread thread = new Thread( new Runnable()
{
@Override
public void run()
{
image = loadImage(filename);
}
thread.start();
});
thread.start();
}
paolofuse
1