diff options
| author | Maiko Steeman <[email protected]> | 2022-04-24 10:48:50 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-04-24 11:48:50 +0200 |
| commit | ccfac59c60f292685cd4785233f1ac972bc74142 (patch) | |
| tree | adc200417b1fc1dddc73ee740586a9f6fef04ba0 /examples/core/core_vr_simulator.c | |
| parent | e1ee4b1466062d130b85e4a7763ceb7c3e05986f (diff) | |
| download | raylib-ccfac59c60f292685cd4785233f1ac972bc74142.tar.gz raylib-ccfac59c60f292685cd4785233f1ac972bc74142.zip | |
Fix for vr rendering not taking render target size into account (#2424)
Diffstat (limited to 'examples/core/core_vr_simulator.c')
| -rw-r--r-- | examples/core/core_vr_simulator.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/examples/core/core_vr_simulator.c b/examples/core/core_vr_simulator.c index 65f0dec6..c0f1b8d2 100644 --- a/examples/core/core_vr_simulator.c +++ b/examples/core/core_vr_simulator.c @@ -78,7 +78,11 @@ int main(void) // Initialize framebuffer for stereo rendering // NOTE: Screen size should match HMD aspect ratio - RenderTexture2D target = LoadRenderTexture(GetScreenWidth(), GetScreenHeight()); + RenderTexture2D target = LoadRenderTexture(device.hResolution, device.vResolution); + + // The target's height is flipped (in the source Rectangle), due to OpenGL reasons + Rectangle sourceRec = { 0.0f, 0.0f, (float)target.texture.width, -(float)target.texture.height }; + Rectangle destRec = { 0.0f, 0.0f, (float)GetScreenWidth(), (float)GetScreenHeight() }; // Define the camera to look into our 3d world Camera camera = { 0 }; @@ -121,8 +125,7 @@ int main(void) BeginDrawing(); ClearBackground(RAYWHITE); BeginShaderMode(distortion); - DrawTextureRec(target.texture, (Rectangle){ 0, 0, (float)target.texture.width, - (float)-target.texture.height }, (Vector2){ 0.0f, 0.0f }, WHITE); + DrawTexturePro(target.texture, sourceRec, destRec, (Vector2){ 0.0f, 0.0f }, 0.0f, WHITE); EndShaderMode(); DrawFPS(10, 10); EndDrawing(); |
