Improving Oculus Rift example...
Under design... looking for the easiest and most comprehensive way for the user to use VR...
This commit is contained in:
parent
9fdf4420d5
commit
24c9b1f717
5 changed files with 40 additions and 25 deletions
|
@ -51,27 +51,31 @@ int main()
|
|||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
BeginOculusDrawing();
|
||||
Begin3dMode(camera);
|
||||
//BeginOculusDrawing(camera); // Add it to Begin3dMode() ?
|
||||
|
||||
for (int eye = 0; eye < 2; eye++)
|
||||
{
|
||||
// TODO: Probably projection and view matrices could be created here...
|
||||
// ...without the need to create it internally through Begin3dMode()
|
||||
Begin3dMode(camera);
|
||||
for (int eye = 0; eye < 2; eye++)
|
||||
{
|
||||
// TODO: Probably projection and view matrices could be created here...
|
||||
// ...without the need to create it internally through Begin3dMode()
|
||||
//Begin3dMode(camera);
|
||||
|
||||
SetOculusView(eye);
|
||||
|
||||
SetOculusMatrix(eye);
|
||||
|
||||
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED);
|
||||
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON);
|
||||
|
||||
DrawGrid(10, 1.0f);
|
||||
|
||||
// TODO: Call internal buffers drawing directly (rlglDraw()) and...
|
||||
// ...reset internal matrices, instead of letting End3dMode() do that
|
||||
End3dMode();
|
||||
}
|
||||
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED);
|
||||
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON);
|
||||
|
||||
DrawGrid(10, 1.0f);
|
||||
|
||||
// TODO: Call internal buffers drawing directly (rlglDraw()) and...
|
||||
// ...reset internal matrices, instead of letting End3dMode() do that
|
||||
//End3dMode();
|
||||
|
||||
DrawDefaultBuffers(); // Process internal dynamic buffers
|
||||
}
|
||||
|
||||
EndOculusDrawing();
|
||||
End3dMode();
|
||||
//EndOculusDrawing(); // Add it to End3dMode() ?
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
|
|
10
src/core.c
10
src/core.c
|
@ -606,6 +606,8 @@ void Begin3dMode(Camera camera)
|
|||
rlMultMatrixf(MatrixToFloat(cameraView)); // Multiply MODELVIEW matrix by view matrix (camera)
|
||||
|
||||
rlEnableDepthTest(); // Enable DEPTH_TEST for 3D
|
||||
|
||||
//if (vrEnabled) BeginVrMode();
|
||||
}
|
||||
|
||||
// Ends 3D mode and returns to default 2D orthographic mode
|
||||
|
@ -1015,6 +1017,14 @@ Matrix GetCameraMatrix(Camera camera)
|
|||
return MatrixLookAt(camera.position, camera.target, camera.up);
|
||||
}
|
||||
|
||||
// Update and draw default buffers vertex data
|
||||
// NOTE: This data has been stored dynamically during frame on each Draw*() call
|
||||
void DrawDefaultBuffers(void)
|
||||
{
|
||||
rlglUpdateDefaultBuffers(); // Upload frame vertex data to GPU
|
||||
rlglDrawDefaultBuffers(); // Draw vertex data into framebuffer
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Functions Definition - Input (Keyboard, Mouse, Gamepad) Functions
|
||||
//----------------------------------------------------------------------------------
|
||||
|
|
|
@ -572,6 +572,7 @@ void EndTextureMode(void); // Ends drawing to r
|
|||
Ray GetMouseRay(Vector2 mousePosition, Camera camera); // Returns a ray trace from mouse position
|
||||
Vector2 GetWorldToScreen(Vector3 position, Camera camera); // Returns the screen space position from a 3d world space position
|
||||
Matrix GetCameraMatrix(Camera camera); // Returns camera transform matrix (view matrix)
|
||||
void DrawDefaultBuffers(void); // Update and draw default buffers vertex data (stored dynamically in frame)
|
||||
|
||||
void SetTargetFPS(int fps); // Set target FPS (maximum)
|
||||
float GetFPS(void); // Returns current FPS
|
||||
|
@ -853,7 +854,7 @@ void DestroyLight(Light light); // Destroy a
|
|||
void InitOculusDevice(void); // Init Oculus Rift device
|
||||
void CloseOculusDevice(void); // Close Oculus Rift device
|
||||
void UpdateOculusTracking(void); // Update Oculus Rift tracking (position and orientation)
|
||||
void SetOculusMatrix(int eye); // Set internal projection and modelview matrix depending on eyes tracking data
|
||||
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)
|
||||
|
||||
|
|
10
src/rlgl.c
10
src/rlgl.c
|
@ -297,8 +297,8 @@ static void UnloadDefaultShader(void); // Unload default shader
|
|||
static void UnloadStandardShader(void); // Unload standard shader
|
||||
|
||||
static void LoadDefaultBuffers(void); // Load default internal buffers (lines, triangles, quads)
|
||||
static void UpdateDefaultBuffers(void); // Update default internal buffers (VAOs/VBOs) with vertex data
|
||||
static void DrawDefaultBuffers(void); // Draw default internal buffers vertex data
|
||||
void rlglUpdateDefaultBuffers(void); // Update default internal buffers (VAOs/VBOs) with vertex data
|
||||
void rlglDrawDefaultBuffers(void); // Draw default internal buffers vertex data
|
||||
static void UnloadDefaultBuffers(void); // Unload default internal buffers vertex data from CPU and GPU
|
||||
|
||||
static void SetShaderLights(Shader shader); // Sets shader uniform values for lights array
|
||||
|
@ -2542,7 +2542,7 @@ void UpdateOculusTracking(void)
|
|||
//if (sessionStatus.IsVisible) // the game or experience has VR focus and is visible in the HMD.
|
||||
}
|
||||
|
||||
void SetOculusMatrix(int eye)
|
||||
void SetOculusView(int eye)
|
||||
{
|
||||
rlViewport(layer.eyeLayer.Viewport[eye].Pos.x, layer.eyeLayer.Viewport[eye].Pos.y, layer.eyeLayer.Viewport[eye].Size.w, layer.eyeLayer.Viewport[eye].Size.h);
|
||||
|
||||
|
@ -3089,7 +3089,7 @@ static void LoadDefaultBuffers(void)
|
|||
// Update default internal buffers (VAOs/VBOs) with vertex array data
|
||||
// NOTE: If there is not vertex data, buffers doesn't need to be updated (vertexCount > 0)
|
||||
// TODO: If no data changed on the CPU arrays --> No need to re-update GPU arrays (change flag required)
|
||||
static void UpdateDefaultBuffers(void)
|
||||
void rlglUpdateDefaultBuffers(void)
|
||||
{
|
||||
// Update lines vertex buffers
|
||||
if (lines.vCounter > 0)
|
||||
|
@ -3159,7 +3159,7 @@ static void UpdateDefaultBuffers(void)
|
|||
|
||||
// Draw default internal buffers vertex data
|
||||
// NOTE: We draw in this order: lines, triangles, quads
|
||||
static void DrawDefaultBuffers(void)
|
||||
void rlglDrawDefaultBuffers(void)
|
||||
{
|
||||
// Set current shader and upload current MVP matrix
|
||||
if ((lines.vCounter > 0) || (triangles.vCounter > 0) || (quads.vCounter > 0))
|
||||
|
|
|
@ -357,7 +357,7 @@ void TraceLog(int msgType, const char *text, ...);
|
|||
void InitOculusDevice(void); // Init Oculus Rift device
|
||||
void CloseOculusDevice(void); // Close Oculus Rift device
|
||||
void UpdateOculusTracking(void); // Update Oculus Rift tracking (position and orientation)
|
||||
void SetOculusMatrix(int eye); // Set internal projection and modelview matrix depending on eyes tracking data
|
||||
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)
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue