# Linux-VR-Compositor-Dev This is preview release ! (WIP) ------------------------------ NOTE : openglexample from [OpenHMD](https://github.com/OpenHMD/OpenHMD) Currently requires 3 EGL extensions + 1 OpenGL extensions : https://www.khronos.org/registry/EGL/extensions/MESA/EGL_MESA_drm_image.txt https://www.khronos.org/registry/EGL/extensions/MESA/EGL_MESA_image_dma_buf_export.txt https://www.khronos.org/registry/EGL/extensions/EXT/EGL_EXT_image_dma_buf_import.txt https://www.khronos.org/registry/OpenGL/extensions/OES/OES_EGL_image.txt ------------------------------ ```C #define GL_GLEXT_PROTOTYPES #include // must include OpenGL before including the Linux VR Compositor header #include void main() { // // Initialize OpenHMD device as usual ohmd_context * ctx = ohmd_ctx_create(); ohmd_device * hmd = ...; // // Create instance, the only public object exposed by the API struct lvrcInstance * compositor = lvrcCreateInstance(hmd); // // Initialize Linux VR Compositor SwapChain bool bSwapChainCreated = lvrcInitSwapChain(compositor); // // Initialize OpenGL using EGL // This is mostly as usual, the only change is that you must use the provided NativeDisplay/NativeWindow EGLDisplay display = eglGetDisplay(lvrcSwapChainGetNativeDisplay(compositor)); EGLContext context = eglCreateContext(display, ...); EGLSurface surface = eglCreateWindowSurface(display, lvrcSwapChainGetNativeWindow(compositor), ...); eglMakeCurrent(display, surface, surface, >context); // // The compositor needs to create some resources that will be used during frame composition // NOTE : the EGL context MUST be bound when calling this function bool bCompositorInit = lvrcInitFrameResources(compositor); // // Main Loop while (true) { ohmd_ctx_update(ctx); // Update OpenHMD as usual lvrcBeginFrame(compositor); ... // Render to left & right textures as usual lvrcSubmitFrameLeft(compositor, left_texture); lvrcSubmitFrameRight(compositor, right_texture); eglSwapBuffers(display, surface); // Swap buffers as usual lvrcEndFrame(compositor); } lvrcReleaseFrameResources(compositor); // You should destroy your EGL context here lvrcReleaseSwapChain(compositor); lvrcDestroyInstance(compositor); ohmd_ctx_destroy(ctx); } ```