View Full Version : How can I use OpenGL in multi-thread program?
09-23-2003, 07:57 PM
I want to develop a multi-thread OpenGL program using VC6.
In this program, I calculate some triangles in one thread and use glBegin and glEnd o save the result(Is there any other methods to save the result in buffers?), and after finished the calculation, the calculate thread send a message to draw thread, then in the draw thread, I swapbuffers. But there is no change in the screen.
09-23-2003, 10:42 PM
Not sure if I got you right here glBegin/glEnd does not "save" the result, it is rendered to the framebuffer, OpenGL is a pipeline engine so nothing is actually saved.
What you might be interested in doing would be for example to use display lists (glGenLists...), here you can save static geometry and later render it using glCallList(s).
I hope that is what you are looking for, if you could post a piece of the code that doesn't work it would be easier.
09-24-2003, 12:47 AM
But I can not use display lists, because my data are dynamic.
I want to know in multi-thread program, the framebuffer is not used by every thread? How can I save the data to the same framebuffer?
only one thread can have one framebuffer active, so if you have glMakeCurrent(..); in the main thread, then the calculation thread cannot use the framebuffer, not until the main does a glMakeCurrent(0,0); and the calculation thread does a glMakeCurrent(rc,dc); , but then the main thread cannot do any gl commmands.. so this is about syncronization.
09-24-2003, 04:41 AM
oh, I see.
I will try other ways to solve the problem.
Thanks a lot!
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.