Project

General

Profile

OPENXR Scol plugin
renderer.h
1
2#ifndef S_OPEN_XR_RENDERER_H
3#define S_OPEN_XR_RENDERER_H
4
5// Same as SO3Engine
6enum RenderSystem
7{
8 XR_NONE_RENDER_SYSTEM = -1,
9 XR_DIRECTX9_RENDERER,
10 XR_DIRECTX11_RENDERER,
11 XR_OPENGL_RENDERER,
12 XR_OPENGL3_RENDERER,
13 XR_VULKAN_RENDERER,
14 XR_METAL_RENDERER,
15 XR_TINY_RENDERER,
16 XR_MAX_RENDERER
17};
18
19#ifdef _WIN32
20# include "glad.h"
21
22//linux (void*)glXGetProcAddressARB((const GLubyte*)procname);
23//GLES (void*)eglGetProcAddress(name);
24//apple return dlsym (RTLD_DEFAULT, name);
25
26static void* getProcAddress(const char* procname)
27{
28 void* res = (void*)wglGetProcAddress(procname);
29
30 if (!res)
31 {
32 static HMODULE libgl = LoadLibraryA("opengl32.dll");
33 res = (void*)GetProcAddress(libgl, procname);
34 }
35
36 return res;
37}
38
39#elif defined(XR_USE_GRAPHICS_API_OPENGL_ES)
40#include <GLES3/gl3.h>
41#include <EGL/egl.h>
42#else
43# include <gl/GL.h>
44#endif // _WIN32
45
47{
48 virtual ~IRenderer() = default;
49
50 virtual const XrBaseInStructure* GetBindings() const = 0;
51
52 // OpenXR instance-level extensions required by this platform.
53 virtual const char* GetExtension() const = 0;
54
55 virtual bool Setup() = 0;
56 virtual bool Check(XrSystemId systemId, XrInstance instance) = 0;
57 virtual bool GetSwapchainFormat(XrInstance instance, XrSession session, int64_t &format) = 0;
58 virtual bool CreateSwapchainImage(XrInstance instance, uint32 viewCount, XrSwapchain swapchain, uint32_t pos) = 0;
59 virtual void UpdateTextures(SCOL_PTR_TYPE leftTexture, SCOL_PTR_TYPE rightTexture, uint32_t acquiredIndex, int32_t width, int32_t height, uint32_t pos) = 0;
60};
61
62std::shared_ptr<IRenderer> CreateRenderer(RenderSystem rsys);
63
64
65#endif