
Originally Posted by
Lele
I want to do it synchronously in order to prevent another memcpy of the buffer, I'd like to receive the buffer pointer and write the content directly to the framebuffer of the graphic board. (the display must be as fast as possible, now I have to use update() )
But there's no way to make OpenGl calls work when called from external thread.
It doesn't have to be a synchronous call. Buffers can be allocated dynamically and pushed onto a list or something like that...
Worker thread:
MyBufer *b = new MyBuffer();
b->fillWithData(somedata);
mutex.lock();
bufferqueue.push(b);
mutex.unlock();
//...
MyBufer *b = new MyBuffer();
b->fillWithData(somedata);
mutex.lock();
bufferqueue.push(b);
mutex.unlock();
//...
To copy to clipboard, switch view to plain text mode
Main thread:
mutex.lock();
MyBuffer *buf =bufferqueue.pop();
bufferqueue.clear(); // clear unused items (aka "skip frames")
mutex.unlock();
Display(buf);
//...
mutex.lock();
MyBuffer *buf =bufferqueue.pop();
bufferqueue.clear(); // clear unused items (aka "skip frames")
mutex.unlock();
Display(buf);
//...
To copy to clipboard, switch view to plain text mode
Of course the code is simply an idea and not a complete solution. Another possibility would be to use custom events instead of the queue.
Bookmarks