Reputation: 11506
I want to know if it is possible to do the following in Java.I am working on a Java based OpenGL app using LWJGL wrapper.In the render loop on each frame render finish I am saving the pixels from the GL frame into image file.The problem is that the size of the frame sometimes is pretty large and it creates a noticeable overhead during the time of writing the pixels into file till the next start of the render loop.What I think to do is the following:
I wonder if such a technique will be of any help?Will the next render loop start without waiting to the image file save if it is done on a separate thread? Is it feasible at all with threads? What I want to achieve is that the GL render loop shouldn't wait for the file write but proceed with the rendering while fetching new pixel data at the end of each render loop into the file writing object.
Upvotes: 2
Views: 235
Reputation: 5506
Write a thread class as below to run individual running thread.
public class WritePixelsToImageThread extends Thread {
public void run(){
// place your code here for
// read pixels from Frame and write that image.
// this is an individual process
}
}
after start that thread as
new WritePixelsToImageThread().start();
Upvotes: 3