Capture blender window stream to opengl texture

I’m trying to capture and stream the blender 3d view to a 2d plane in opengl so I can send that to a vr headset.
I’m on windows and tried a screencapture, it just gives me a black texture.
HBITMAP isn’t working,
I’m wondering if there’s a way to grab the screen using glReadPixels and a PBO?
I saw on some other forum there was a way to read the front buffer :

I might try that.
Anyways, opengl suggestions on texturing and suggestions on how to get the Blender viewport would be great. I know there is screenshot/screencast : bpy.ops.screencast() , but I have not looked into how this is done yet -I’m not entirely sure how to grep the blender source on this.

C code wise if I remember correctly the color picker that relies on gReadPixels() function as fallback. The code should be located in editors/interface/interface_eyedropper_color.c

Navigating the code from that source file should give you all the info you need.

I do not know if its really possible to do this via python but it should be possible via C.

Thanks , I did it via C.
The results are here :VR camera in Blender realtime [working /WIP]

1 Like