开发者

c++ OpenGL Multithreading with buffer resource

I have an OpenGL program that needs to periodically update the textures. But at the same time I want the program to be responsive (specifically, to continue running the draw/display code) while it's updating these textures.

But this seems impossible: If I make thread1 do the draw/display code and thread2 to the texture moving, then they will conflict under the resource GL_ARRAY_BUFFER_ARB because thread2 has to keep that resource to move some textures over to a vbo. And I need GL_ARRAY_BUFFER_ARB to do the draw/display code for thread1 because that uses different vbo's.

For example this code

glBindBufferARB(GL_ARRAY_BUFFER_ARB, tVboId);
    glBufferDataARB(GL_ARRAY_BUFFER_ARB, numVertices*2*sizeof(GLfloat), texCoords, GL_DYNAMIC_DRAW_ARB);  
    glBindBufferARB(GL_ARRAY开发者_运维知识库_BUFFER_ARB,0);

will move some textures over but it will take a while. During that time the display code is supposed to run many times but it will instead crash, because GL_ARRAY_BUFFER_ARB is in use.

I thought I could do something like GL_ARRAY_BUFFER_ARB2 but there is no such thing, I think.


Use PBOs they allow you to do asynchronous transfers, read more here.


This should help: http://hacksoflife.blogspot.com/2008/02/creating-opengl-objects-in-second.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜