oxr: add XR_TYPE_SWAPCHAIN_IMAGE_OPENGL_ES_KHR support

This commit is contained in:
Simon Ser 2019-10-30 15:43:01 +01:00
parent 81cace0250
commit c395f85565
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48

View file

@ -41,20 +41,34 @@ oxr_swapchain_gl_enumerate_images(struct oxr_logger *log,
{
struct xrt_swapchain_gl *xsc = (struct xrt_swapchain_gl *)sc->swapchain;
XrSwapchainImageOpenGLKHR *gl_imgs = NULL;
XrSwapchainImageOpenGLESKHR *gles_imgs = NULL;
assert(count > 0);
if (images[0].type != XR_TYPE_SWAPCHAIN_IMAGE_OPENGL_KHR) {
switch (images[0].type) {
case XR_TYPE_SWAPCHAIN_IMAGE_OPENGL_KHR:
gl_imgs = (XrSwapchainImageOpenGLKHR *)images;
break;
case XR_TYPE_SWAPCHAIN_IMAGE_OPENGL_ES_KHR:
gles_imgs = (XrSwapchainImageOpenGLESKHR *)images;
break;
default:
return oxr_error(log, XR_ERROR_VALIDATION_FAILURE,
"unsupported XrSwapchainImageBaseHeader type");
}
XrSwapchainImageOpenGLKHR *gl_imgs =
(XrSwapchainImageOpenGLKHR *)images;
for (uint32_t i = 0; i < count; i++) {
if (gl_imgs[i].type != images[0].type) {
if ((gl_imgs != NULL && gl_imgs[i].type != images[0].type) ||
(gles_imgs != NULL &&
gles_imgs[i].type != images[0].type)) {
return oxr_error(log, XR_ERROR_VALIDATION_FAILURE,
"images array contains mixed types");
}
gl_imgs[i].image = xsc->images[i];
if (gl_imgs != NULL) {
gl_imgs[i].image = xsc->images[i];
}
if (gles_imgs != NULL) {
gles_imgs[i].image = xsc->images[i];
}
}
return oxr_session_success_result(sc->sess);