Answer the question
In order to leave comments, you need to log in
Have you mixed Boost.Thread and OpenGL?
I wanted to show the process of executing one capacious function (well, which would draw "remaining ... from ...") in a separate thread, but found that I can not force OpenGL to draw in a separate
thread Boots
void f(){
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_LINES);
glVertex2i(-200,-200);
glVertex2i(200,200);
glEnd();
glfwSwapBuffers(app.window);//меняет буфферы - функция GLFW
}
int main(){
glfwInit();
GLFWwindow* window=prepare(400,400);//prepare - пользовательский; создаёт окно, подключает callback... не в нём дело, и обнаружил в другом месте (могу потом выложить)
f();
return 0;
}
void f(){
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_LINES);
glVertex2i(-200,-200);
glVertex2i(200,200);
glEnd();
glfwSwapBuffers(app.window);//меняет буфферы - функция GLFW
}
int main(){
glfwInit();
GLFWwindow* window=prepare(400,400);//prepare - пользовательский; создаёт окно, подключает callback... не в нём дело - тестировал Очень далеко от него
boost::thread th(f);
th.join();
return 0;
}
Answer the question
In order to leave comments, you need to log in
In the general case, they use the approach not to draw from different threads, but to draw in one thread and in others to do the drawing calculation, i.e. opengl commands are called only from one thread.
(roughly where initialized there and draw to avoid)
Actually, the opengl context is tied to the thread, see the description of glXMakeCurrent, wglMakeCurrent of its type can be used in another thread, but must first be freed in the current one.
But if you are completely confused, then you can still draw from different streams using overlays - details here www.opengl.org/archives/resources/faq/technical/co...
but it seems to me that you still don’t want to draw from different threads, but just want to do the calculation in another one, then just carefully make sure that the MakeCurrent command and all subsequent drawing commands work in the same thread.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question