diff options
| author | Ray <raysan5@gmail.com> | 2016-06-21 08:59:29 +0200 |
|---|---|---|
| committer | Ray <raysan5@gmail.com> | 2016-06-21 08:59:29 +0200 |
| commit | 6062201e8f543c227a0adbb77f3a0941772be889 (patch) | |
| tree | 32233ad6ce270f1529b09528a922633ae7a09e75 /src | |
| parent | b01f5ff6a7e0d7a91057da618a688000eec6365d (diff) | |
| download | raylib-6062201e8f543c227a0adbb77f3a0941772be889.tar.gz raylib-6062201e8f543c227a0adbb77f3a0941772be889.zip | |
Simplify Oculus example...
...to align it with standard raylib code. Final goal would be having the
same code work for every platform with no changes...
Diffstat (limited to 'src')
| -rw-r--r-- | src/core.c | 5 | ||||
| -rw-r--r-- | src/rlgl.c | 12 | ||||
| -rw-r--r-- | src/rlgl.h | 1 |
3 files changed, 15 insertions, 3 deletions
@@ -607,13 +607,14 @@ void Begin3dMode(Camera camera) rlEnableDepthTest(); // Enable DEPTH_TEST for 3D - //if (vrEnabled) BeginVrMode(); + if (VrEnabled()) BeginOculusDrawing(); } // Ends 3D mode and returns to default 2D orthographic mode void End3dMode(void) { - rlglDraw(); // Draw Buffers (Only OpenGL 3+ and ES2) + if (VrEnabled()) EndOculusDrawing(); + else rlglDraw(); // Draw Buffers (Only OpenGL 3+ and ES2) rlMatrixMode(RL_PROJECTION); // Switch to projection matrix rlPopMatrix(); // Restore previous matrix (PROJECTION) from matrix stack @@ -76,7 +76,7 @@ #include "standard_shader.h" // Standard shader to embed #endif -#define RLGL_OCULUS_SUPPORT // Enable Oculus Rift code +//#define RLGL_OCULUS_SUPPORT // Enable Oculus Rift code #if defined(RLGL_OCULUS_SUPPORT) #include "external/OculusSDK/LibOVR/Include/OVR_CAPI_GL.h" // Oculus SDK for OpenGL #endif @@ -268,6 +268,7 @@ static unsigned int frameIndex = 0; // Oculus frames counter, used to discar #endif static bool vrSimulator = false; // VR simulator (stereo rendering on window, without vr device) +static bool vrEnabled = false; // VR enabled flag (required by core module) // Compressed textures support flags static bool texCompDXTSupported = false; // DDS texture compression support @@ -2523,6 +2524,7 @@ void InitOculusDevice(void) } #else vrSimulator = true; + vrEnabled = true; #endif if (vrSimulator) @@ -2548,6 +2550,14 @@ void CloseOculusDevice(void) // TODO: Unload stereo framebuffer and texture // TODO: Unload oculus-distortion shader } + + vrEnabled = false; +} + +// Track stereoscopic rendering +bool VrEnabled(void) +{ + return vrEnabled; } // Update Oculus Rift tracking (position and orientation) @@ -362,6 +362,7 @@ void UpdateOculusTracking(void); // Update Oculus Rift tracking (posi void SetOculusView(int eye); // Set internal projection and modelview matrix depending on eyes tracking data void BeginOculusDrawing(void); // Begin Oculus drawing configuration void EndOculusDrawing(void); // End Oculus drawing process (and desktop mirror) +bool VrEnabled(void); // Track stereoscopic rendering #ifdef __cplusplus } |
