浏览代码

Improve vr support and simulator

pull/260/head
Ray 8 年前
父节点
当前提交
fdf8501e81
共有 2 个文件被更改,包括 8 次插入15 次删除
  1. +3
    -11
      examples/core/core_vr_simulator.c
  2. +5
    -4
      src/rlgl.c

+ 3
- 11
examples/core/core_vr_simulator.c 查看文件

@ -1,16 +1,8 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [core] example - Oculus Rift CV1
* raylib [core] example - VR Simulator (Oculus Rift CV1 parameters)
* *
* Compile example using:
* gcc -o $(NAME_PART).exe $(FILE_NAME) -I..\src\external -I..\src\external\OculusSDK\LibOVR\Include /
* -L. -L..\src\external\OculusSDK\LibOVR -lLibOVRRT32_1 -lraylib -lglfw3 -lopengl32 -lgdi32 -std=c99 /
* -Wl,-allow-multiple-definition
*
* #define SUPPORT_OCULUS_RIFT_CV1 / RLGL_OCULUS_SUPPORT
* Enable Oculus Rift CV1 functionality
*
* This example has been created using raylib 1.5 (www.raylib.com)
* This example has been created using raylib 1.7 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2016 Ramon Santamaria (@raysan5) * Copyright (c) 2016 Ramon Santamaria (@raysan5)
@ -28,7 +20,7 @@ int main()
// NOTE: screenWidth/screenHeight should match VR device aspect ratio // NOTE: screenWidth/screenHeight should match VR device aspect ratio
InitWindow(screenWidth, screenHeight, "raylib [core] example - oculus rift");
InitWindow(screenWidth, screenHeight, "raylib [core] example - vr simulator");
InitVrSimulator(HMD_OCULUS_RIFT_CV1); // Init VR simulator (Oculus Rift CV1 parameters) InitVrSimulator(HMD_OCULUS_RIFT_CV1); // Init VR simulator (Oculus Rift CV1 parameters)

+ 5
- 4
src/rlgl.c 查看文件

@ -57,6 +57,7 @@
// Default configuration flags (supported features) // Default configuration flags (supported features)
//------------------------------------------------- //-------------------------------------------------
#define SUPPORT_VR_SIMULATION #define SUPPORT_VR_SIMULATION
#define SUPPORT_DISTORTION_SHADER
//------------------------------------------------- //-------------------------------------------------
#include "rlgl.h" #include "rlgl.h"
@ -2240,7 +2241,7 @@ void *rlglReadTexturePixels(Texture2D texture)
pixels = (unsigned char *)malloc(texture.width*texture.height*4*sizeof(unsigned char)); pixels = (unsigned char *)malloc(texture.width*texture.height*4*sizeof(unsigned char));
// NOTE: Despite FBO color texture is RGB, we read data as RGBA... reading as RGB doesn't work... o__O
// NOTE: We read data as RGBA because FBO texture is configured as RGBA, despite binding a RGB texture...
glReadPixels(0, 0, texture.width, texture.height, GL_RGBA, GL_UNSIGNED_BYTE, pixels); glReadPixels(0, 0, texture.width, texture.height, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
// Re-attach internal FBO color texture before deleting it // Re-attach internal FBO color texture before deleting it
@ -2558,7 +2559,7 @@ void InitVrSimulator(int vrDevice)
hmd.chromaAbCorrection[2] = 1.014f; // HMD chromatic aberration correction parameter 2 hmd.chromaAbCorrection[2] = 1.014f; // HMD chromatic aberration correction parameter 2
hmd.chromaAbCorrection[3] = 0.0f; // HMD chromatic aberration correction parameter 3 hmd.chromaAbCorrection[3] = 0.0f; // HMD chromatic aberration correction parameter 3
TraceLog(WARNING, "Initializing VR Simulator (Oculus Rift DK2)");
TraceLog(INFO, "Initializing VR Simulator (Oculus Rift DK2)");
} }
else if ((vrDevice == HMD_DEFAULT_DEVICE) || (vrDevice == HMD_OCULUS_RIFT_CV1)) else if ((vrDevice == HMD_DEFAULT_DEVICE) || (vrDevice == HMD_OCULUS_RIFT_CV1))
{ {
@ -2585,11 +2586,11 @@ void InitVrSimulator(int vrDevice)
hmd.chromaAbCorrection[2] = 1.014f; // HMD chromatic aberration correction parameter 2 hmd.chromaAbCorrection[2] = 1.014f; // HMD chromatic aberration correction parameter 2
hmd.chromaAbCorrection[3] = 0.0f; // HMD chromatic aberration correction parameter 3 hmd.chromaAbCorrection[3] = 0.0f; // HMD chromatic aberration correction parameter 3
TraceLog(WARNING, "Initializing VR Simulator (Oculus Rift CV1)");
TraceLog(INFO, "Initializing VR Simulator (Oculus Rift CV1)");
} }
else else
{ {
TraceLog(WARNING, "VR Simulator doesn't support current device yet,");
TraceLog(WARNING, "VR Simulator doesn't support selected device parameters,");
TraceLog(WARNING, "using default VR Simulator parameters"); TraceLog(WARNING, "using default VR Simulator parameters");
} }

正在加载...
取消
保存