mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-06-03 02:17:39 +00:00
Added an OpenVR video driver (thanks @cnlohr!)
This commit is contained in:
parent
569691797d
commit
e81e917c5e
10 changed files with 5060 additions and 0 deletions
|
@ -337,6 +337,7 @@ dep_option(SDL_VIVANTE "Use Vivante EGL video driver" ON "${UNIX_SYS
|
|||
dep_option(SDL_VULKAN "Enable Vulkan support" ON "SDL_VIDEO;ANDROID OR APPLE OR LINUX OR FREEBSD OR WINDOWS" OFF)
|
||||
dep_option(SDL_RENDER_VULKAN "Enable the Vulkan render driver" ON "SDL_RENDER;SDL_VULKAN" OFF)
|
||||
dep_option(SDL_METAL "Enable Metal support" ON "APPLE" OFF)
|
||||
set_option(SDL_OPENVR "Use OpenVR video driver" OFF)
|
||||
dep_option(SDL_KMSDRM "Use KMS DRM video driver" ${UNIX_SYS} "SDL_VIDEO" OFF)
|
||||
dep_option(SDL_KMSDRM_SHARED "Dynamically load KMS DRM support" ON "SDL_KMSDRM" OFF)
|
||||
set_option(SDL_OFFSCREEN "Use offscreen video driver" ON)
|
||||
|
@ -1544,6 +1545,7 @@ elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU)
|
|||
CheckOpenGL()
|
||||
CheckOpenGLES()
|
||||
CheckWayland()
|
||||
CheckOpenVR()
|
||||
CheckVivante()
|
||||
CheckVulkan()
|
||||
CheckQNXScreen()
|
||||
|
|
|
@ -662,6 +662,19 @@ macro(CheckVivante)
|
|||
endif()
|
||||
endmacro()
|
||||
|
||||
# Requires:
|
||||
# - n/a
|
||||
macro(CheckOpenVR)
|
||||
if(SDL_OPENVR)
|
||||
set(HAVE_OPENVR TRUE)
|
||||
set(HAVE_OPENVR_VIDEO TRUE)
|
||||
|
||||
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/video/openvr/*.c")
|
||||
set(SDL_VIDEO_DRIVER_OPENVR 1)
|
||||
sdl_link_dependency(egl LIBS EGL)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# Requires:
|
||||
# - nada
|
||||
macro(CheckGLX)
|
||||
|
|
|
@ -2629,6 +2629,17 @@ extern "C" {
|
|||
*/
|
||||
#define SDL_HINT_OPENGL_ES_DRIVER "SDL_OPENGL_ES_DRIVER"
|
||||
|
||||
/**
|
||||
* Mechanism to specify openvr_api library location
|
||||
*
|
||||
* By default, when using the OpenVR driver, it will search for the API
|
||||
* library in the current folder. But, if you wish to use a system API
|
||||
* you can specify that by using this hint. This should be the full or
|
||||
* relative path to a .dll on Windows or .so on Linux.
|
||||
*
|
||||
*/
|
||||
#define SDL_HINT_OPENVR_LIBRARY "SDL_OPENVR_LIBRARY"
|
||||
|
||||
/**
|
||||
* A variable controlling which orientations are allowed on iOS/Android.
|
||||
*
|
||||
|
|
|
@ -1282,6 +1282,11 @@ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetWindowParent(SDL_Window *window)
|
|||
* - `SDL_PROP_WINDOW_COCOA_METAL_VIEW_TAG_NUMBER`: the NSInteger tag
|
||||
* assocated with metal views on the window
|
||||
*
|
||||
* On OpenVR:
|
||||
*
|
||||
* - `SDL_PROP_WINDOW_OPENVR_OVERLAY_ID`: the OpenVR Overlay Handle ID for
|
||||
* the associated overlay window.
|
||||
*
|
||||
* On Vivante:
|
||||
*
|
||||
* - `SDL_PROP_WINDOW_VIVANTE_DISPLAY_POINTER`: the EGLNativeDisplayType
|
||||
|
@ -1354,6 +1359,7 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetWindowProperties(SDL_Window
|
|||
#define SDL_PROP_WINDOW_KMSDRM_GBM_DEVICE_POINTER "SDL.window.kmsdrm.gbm_dev"
|
||||
#define SDL_PROP_WINDOW_COCOA_WINDOW_POINTER "SDL.window.cocoa.window"
|
||||
#define SDL_PROP_WINDOW_COCOA_METAL_VIEW_TAG_NUMBER "SDL.window.cocoa.metal_view_tag"
|
||||
#define SDL_PROP_WINDOW_OPENVR_OVERLAY_ID "SDL.window.openvr.overlay_id"
|
||||
#define SDL_PROP_WINDOW_VIVANTE_DISPLAY_POINTER "SDL.window.vivante.display"
|
||||
#define SDL_PROP_WINDOW_VIVANTE_WINDOW_POINTER "SDL.window.vivante.window"
|
||||
#define SDL_PROP_WINDOW_VIVANTE_SURFACE_POINTER "SDL.window.vivante.surface"
|
||||
|
|
|
@ -397,6 +397,7 @@
|
|||
#cmakedefine SDL_VIDEO_DRIVER_VITA @SDL_VIDEO_DRIVER_VITA@
|
||||
#cmakedefine SDL_VIDEO_DRIVER_VIVANTE @SDL_VIDEO_DRIVER_VIVANTE@
|
||||
#cmakedefine SDL_VIDEO_DRIVER_VIVANTE_VDK @SDL_VIDEO_DRIVER_VIVANTE_VDK@
|
||||
#cmakedefine SDL_VIDEO_DRIVER_OPENVR @SDL_VIDEO_DRIVER_OPENVR@
|
||||
#cmakedefine SDL_VIDEO_DRIVER_WAYLAND @SDL_VIDEO_DRIVER_WAYLAND@
|
||||
#cmakedefine SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC @SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC@
|
||||
#cmakedefine SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR @SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR@
|
||||
|
|
|
@ -521,6 +521,7 @@ extern VideoBootStrap Emscripten_bootstrap;
|
|||
extern VideoBootStrap OFFSCREEN_bootstrap;
|
||||
extern VideoBootStrap NGAGE_bootstrap;
|
||||
extern VideoBootStrap QNX_bootstrap;
|
||||
extern VideoBootStrap OPENVR_bootstrap;
|
||||
|
||||
// Use SDL_OnVideoThread() sparingly, to avoid regressions in use cases that currently happen to work
|
||||
extern bool SDL_OnVideoThread(void);
|
||||
|
|
|
@ -139,6 +139,9 @@ static VideoBootStrap *bootstrap[] = {
|
|||
#ifdef SDL_INPUT_LINUXEV
|
||||
&DUMMY_evdev_bootstrap,
|
||||
#endif
|
||||
#endif
|
||||
#ifdef SDL_VIDEO_DRIVER_OPENVR
|
||||
&OPENVR_bootstrap,
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
|
@ -2339,6 +2342,10 @@ SDL_Window *SDL_CreateWindowWithProperties(SDL_PropertiesID props)
|
|||
flags |= SDL_DefaultGraphicsBackends(_this);
|
||||
}
|
||||
|
||||
#if defined(SDL_VIDEO_OPENGL) && defined(SDL_VIDEO_DRIVER_OPENVR)
|
||||
flags |= SDL_WINDOW_OPENGL;
|
||||
#endif
|
||||
|
||||
if (flags & SDL_WINDOW_OPENGL) {
|
||||
if (!_this->GL_CreateContext) {
|
||||
SDL_ContextNotSupported("OpenGL");
|
||||
|
|
1728
src/video/openvr/SDL_openvrvideo.c
Normal file
1728
src/video/openvr/SDL_openvrvideo.c
Normal file
File diff suppressed because it is too large
Load diff
109
src/video/openvr/SDL_openvrvideo.h
Normal file
109
src/video/openvr/SDL_openvrvideo.h
Normal file
|
@ -0,0 +1,109 @@
|
|||
#ifndef _SDL_OPENVRVIDEO_H
|
||||
#define _SDL_OPENVRVIDEO_H
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_WINDOWS
|
||||
#ifdef EXTERN_C
|
||||
#undef EXTERN_C
|
||||
#endif
|
||||
#define GL_APIENTRY
|
||||
#define GL_APICALL
|
||||
#endif
|
||||
|
||||
// OpenVR has a LOT of unused variables that GCC will freak out on.
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-variable"
|
||||
#endif
|
||||
|
||||
#include "openvr_capi.h"
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef SDL_VIDEO_DRIVER_WINDOWS
|
||||
|
||||
#include <GLES3/gl3.h>
|
||||
#include <GLES3/gl32.h>
|
||||
#include <EGL/egl.h>
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct SDL_WindowData
|
||||
{
|
||||
#ifdef SDL_VIDEO_DRIVER_WINDOWS
|
||||
SDL_Window *window;
|
||||
HWND hwnd;
|
||||
HWND parent;
|
||||
HDC hdc;
|
||||
HDC mdc;
|
||||
#else
|
||||
int dummy;
|
||||
#endif
|
||||
} SDL_WindowData;
|
||||
|
||||
typedef struct SDL_VideoData {
|
||||
void * openVRLIB;
|
||||
intptr_t vrtoken;
|
||||
intptr_t (*FN_VR_InitInternal)( EVRInitError *peError, EVRApplicationType eType );
|
||||
const char *(*FN_VR_GetVRInitErrorAsEnglishDescription)( EVRInitError error );
|
||||
intptr_t (*FN_VR_GetGenericInterface)( const char *pchInterfaceVersion, EVRInitError *peError );
|
||||
|
||||
int is_buffer_rendering;
|
||||
|
||||
unsigned int overlaytexture;
|
||||
|
||||
unsigned int fbo, rbo;
|
||||
|
||||
int saved_texture_state;
|
||||
|
||||
struct VR_IVRSystem_FnTable *oSystem;
|
||||
struct VR_IVROverlay_FnTable *oOverlay;
|
||||
struct VR_IVRInput_FnTable * oInput;
|
||||
VROverlayHandle_t overlayID, thumbID, cursorID;
|
||||
|
||||
char * sOverlayName;
|
||||
|
||||
VRActionSetHandle_t input_action_set;
|
||||
VRActionHandle_t * input_action_handles_buttons;
|
||||
int input_action_handles_buttons_count;
|
||||
VRActionHandle_t * input_action_handles_axes;
|
||||
int input_action_handles_axes_count;
|
||||
VRActionHandle_t input_action_handles_haptics[2];
|
||||
|
||||
bool bKeyboardShown;
|
||||
bool bHasShownOverlay;
|
||||
int targw, targh;
|
||||
int last_targw, last_targh;
|
||||
int swap_interval;
|
||||
|
||||
bool bDidCreateOverlay;
|
||||
bool renderdoc_debugmarker_frame_end;
|
||||
bool bIconOverridden;
|
||||
|
||||
SDL_Window * window;
|
||||
|
||||
SDL_Joystick *virtual_joystick;
|
||||
#ifdef SDL_VIDEO_DRIVER_WINDOWS
|
||||
HDC hdc;
|
||||
HGLRC hglrc;
|
||||
#else
|
||||
EGLDisplay eglDpy;
|
||||
EGLContext eglCtx;
|
||||
#endif
|
||||
} SDL_VideoData;
|
||||
|
||||
|
||||
typedef struct SDL_DisplayData
|
||||
{
|
||||
int dummy;
|
||||
} SDL_DisplayData;
|
||||
|
||||
|
||||
#endif
|
3182
src/video/openvr/openvr_capi.h
Normal file
3182
src/video/openvr/openvr_capi.h
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue