82 lines
2.2 KiB
Markdown
82 lines
2.2 KiB
Markdown
# Linux-VR-Compositor-Dev
|
|
|
|
Still experimental !
|
|
|
|
------------------------------
|
|
|
|
EGL 1.5 is required + 3 extensions :
|
|
- [EGL_MESA_drm_image](https://www.khronos.org/registry/EGL/extensions/MESA/EGL_MESA_drm_image.txt)
|
|
- [EGL_MESA_image_dma_buf_export](https://www.khronos.org/registry/EGL/extensions/MESA/EGL_MESA_image_dma_buf_export.txt)
|
|
- [EGL_EXT_image_dma_buf_import](https://www.khronos.org/registry/EGL/extensions/EXT/EGL_EXT_image_dma_buf_import.txt)
|
|
|
|
No OpenGL version requirement, just one extension required :
|
|
- [OES_EGL_image](https://www.khronos.org/registry/OpenGL/extensions/OES/OES_EGL_image.txt)
|
|
|
|
------------------------------
|
|
|
|
NOTE :
|
|
|
|
openglexample from [OpenHMD](https://github.com/OpenHMD/OpenHMD)
|
|
|
|
------------------------------
|
|
|
|
```C
|
|
#define GL_GLEXT_PROTOTYPES
|
|
#include <GL/gl.h> // must include OpenGL before including the Linux VR Compositor header
|
|
|
|
#include <lvrc.h>
|
|
|
|
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 your OpenGL context using as usual
|
|
// Note that only EGL is supported right now
|
|
EGLDisplay display = eglGetDisplay(...);
|
|
EGLContext context = eglCreateContext(display, ...);
|
|
EGLSurface surface = eglCreateWindowSurface(display, ...);
|
|
eglMakeCurrent(display, surface, surface, context);
|
|
|
|
//
|
|
// Initialize HMD rendering
|
|
bool bRenderingInit = lvrcInitRenderingEGL(compositor, gl.egl_display, gl.egl_context, gl.egl_surface);
|
|
|
|
//
|
|
// Initialize the Swap Chain (currently 2 textures)
|
|
GLuint textures [2];
|
|
bool bSwapChainCreated = lvrcInitSwapChain(compositor, width, height, textures);
|
|
|
|
//
|
|
// Main Loop
|
|
while (true)
|
|
{
|
|
ohmd_ctx_update(ctx); // Update OpenHMD as usual
|
|
|
|
lvrcBeginFrame(compositor);
|
|
|
|
... // Render to left & right textures as usual
|
|
|
|
eglSwapBuffers(display, surface); // Swap buffers as usual
|
|
|
|
lvrcEndFrame(compositor);
|
|
}
|
|
|
|
lvrcReleaseSwapChain(compositor);
|
|
|
|
// You should destroy your EGL context here
|
|
|
|
lvrcDestroyInstance(compositor);
|
|
|
|
ohmd_ctx_destroy(ctx);
|
|
}
|
|
```
|
|
|