REDESIGNED: Vr stereo mode
This commit is contained in:
parent
84d0d21f23
commit
b3f75b91ff
3 changed files with 13 additions and 27 deletions
|
@ -101,7 +101,9 @@ int main(void)
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
BeginVrStereoMode(target, config);
|
BeginTextureMode(target);
|
||||||
|
ClearBackground(RAYWHITE);
|
||||||
|
BeginVrStereoMode(config);
|
||||||
BeginMode3D(camera);
|
BeginMode3D(camera);
|
||||||
|
|
||||||
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED);
|
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED);
|
||||||
|
@ -111,6 +113,7 @@ int main(void)
|
||||||
|
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
EndVrStereoMode();
|
EndVrStereoMode();
|
||||||
|
EndTextureMode();
|
||||||
|
|
||||||
BeginShaderMode(distortion);
|
BeginShaderMode(distortion);
|
||||||
DrawTextureRec(target.texture, (Rectangle){ 0, 0, (float)target.texture.width, (float)-target.texture.height }, (Vector2){ 0.0f, 0.0f }, WHITE);
|
DrawTextureRec(target.texture, (Rectangle){ 0, 0, (float)target.texture.width, (float)-target.texture.height }, (Vector2){ 0.0f, 0.0f }, WHITE);
|
||||||
|
|
19
src/core.c
19
src/core.c
|
@ -2067,36 +2067,19 @@ void EndScissorMode(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Begin VR drawing configuration
|
// Begin VR drawing configuration
|
||||||
void BeginVrStereoMode(RenderTexture2D target, VrStereoConfig config)
|
void BeginVrStereoMode(VrStereoConfig config)
|
||||||
{
|
{
|
||||||
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
|
||||||
rlEnableFramebuffer(target.id); // Setup framebuffer for stereo rendering
|
|
||||||
//glEnable(GL_FRAMEBUFFER_SRGB); // Enable SRGB framebuffer (only if required)
|
|
||||||
rlClearScreenBuffers(); // Clear current framebuffer
|
|
||||||
|
|
||||||
rlEnableStereoRender();
|
rlEnableStereoRender();
|
||||||
|
|
||||||
// Set stereo render matrices
|
// Set stereo render matrices
|
||||||
rlSetMatrixProjectionStereo(config.projection[0], config.projection[1]);
|
rlSetMatrixProjectionStereo(config.projection[0], config.projection[1]);
|
||||||
rlSetMatrixViewOffsetStereo(config.viewOffset[0], config.viewOffset[1]);
|
rlSetMatrixViewOffsetStereo(config.viewOffset[0], config.viewOffset[1]);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// End VR drawing process (and desktop mirror)
|
// End VR drawing process (and desktop mirror)
|
||||||
void EndVrStereoMode(void)
|
void EndVrStereoMode(void)
|
||||||
{
|
{
|
||||||
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
|
||||||
rlDisableStereoRender();
|
rlDisableStereoRender();
|
||||||
|
|
||||||
rlDisableFramebuffer(); // Unbind current framebuffer
|
|
||||||
|
|
||||||
// Reset viewport and default projection-modelview matrices
|
|
||||||
rlViewport(0, 0, GetScreenWidth(), GetScreenHeight());
|
|
||||||
rlSetMatrixProjection(MatrixOrtho(0.0, GetScreenWidth(), GetScreenHeight(), 0.0, 0.0, 1.0));
|
|
||||||
rlSetMatrixModelview(MatrixIdentity());
|
|
||||||
|
|
||||||
rlDisableDepthTest();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load VR stereo config for VR simulator device parameters
|
// Load VR stereo config for VR simulator device parameters
|
||||||
|
|
|
@ -965,7 +965,7 @@ RLAPI void BeginBlendMode(int mode); // Begin blend
|
||||||
RLAPI void EndBlendMode(void); // End blending mode (reset to default: alpha blending)
|
RLAPI void EndBlendMode(void); // End blending mode (reset to default: alpha blending)
|
||||||
RLAPI void BeginScissorMode(int x, int y, int width, int height); // Begin scissor mode (define screen area for following drawing)
|
RLAPI void BeginScissorMode(int x, int y, int width, int height); // Begin scissor mode (define screen area for following drawing)
|
||||||
RLAPI void EndScissorMode(void); // End scissor mode
|
RLAPI void EndScissorMode(void); // End scissor mode
|
||||||
RLAPI void BeginVrStereoMode(RenderTexture2D target, VrStereoConfig config); // Begin stereo rendering (requires VR simulator)
|
RLAPI void BeginVrStereoMode(VrStereoConfig config); // Begin stereo rendering (requires VR simulator)
|
||||||
RLAPI void EndVrStereoMode(void); // End stereo rendering (requires VR simulator)
|
RLAPI void EndVrStereoMode(void); // End stereo rendering (requires VR simulator)
|
||||||
|
|
||||||
// VR stereo config functions for VR simulator
|
// VR stereo config functions for VR simulator
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue