开发者

is it possible to render to framebuffer object outside of main render loop

i am using a separate framebuffer object for color picking 2d objects in opengl. i am curious if its possible to only draw to the framebuffer and read the color when needed.

what i am doing now is in the main render loop i draw the scene to the main framebuffer and then render just the selectable objects to the "picking" framebuffer.

when the user clicks the mouse it binds the "picking" framebuffer and reads the pixel and i know which object is selected. the problem with this is i only need the "picking" framebuffer when a user clicks the mouse so doing this every frame is inefficient.

i have tried rendering to the "picking" framebuffer when the user clicks the mouse and then reading directly but all i get is white (the background color and not the color to tell me which object it is). drawing the "picking" framebuffer just shows the entire thing as white like nothing was actually rendered to it at all.

do i need to stop drawing in the main loop while rendering to the "picking" framebuffer? or is开发者_Go百科 there something im missing that would make this possible?

EDIT: i have tried not drawing in the main loop while rendering to the picking framebuffer and that did not work either.


You need to check that you made your GL context the current one using either wglMakeCurrent or glXMakeCurrent. Also, it has to be done in the same thread, since only one thread can have a current context.


"No".

But you can multiple GPUs (if you have it). Here or here you can find the OpenGL specification; the driver must support *WGL_NV_gpu_affinity* or *AMD_gpu_association* extension.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜