diff --git a/examples/core/core_smooth_pixelperfect.c b/examples/core/core_smooth_pixelperfect.c index 2b01f3fef..24f77e4ad 100644 --- a/examples/core/core_smooth_pixelperfect.c +++ b/examples/core/core_smooth_pixelperfect.c @@ -52,7 +52,7 @@ int main(void) // 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 = { -virtualRatio, -virtualRatio, screenWidth + (virtualRatio*2), screenHeight + (virtualRatio*2) }; + Rectangle destRec = { (screenWidth - screenWidth/1.25f)/2.0f, (screenHeight - screenHeight/1.25f)/2.0f, screenWidth/1.25f, screenHeight/1.25f }; Vector2 origin = { 0.0f, 0.0f }; @@ -61,6 +61,9 @@ int main(void) float cameraX = 0.0f; float cameraY = 0.0f; + bool smoothOn = true; + bool overscan = false; + SetTargetFPS(60); //-------------------------------------------------------------------------------------- @@ -86,6 +89,18 @@ int main(void) worldSpaceCamera.target.y = truncf(screenSpaceCamera.target.y); screenSpaceCamera.target.y -= worldSpaceCamera.target.y; screenSpaceCamera.target.y *= virtualRatio; + + if (IsKeyPressed(KEY_S)) smoothOn = !smoothOn; + if (IsKeyPressed(KEY_O)) overscan = !overscan; + + if (overscan) + { + destRec = (Rectangle) { -virtualRatio, -virtualRatio, screenWidth + (virtualRatio*2), screenHeight + (virtualRatio*2) }; + } + else + { + destRec = (Rectangle) { (screenWidth - screenWidth/1.25f)/2.0f, (screenHeight - screenHeight/1.25f)/2.0f, screenWidth/1.25f, screenHeight/1.25f }; + } //---------------------------------------------------------------------------------- // Draw @@ -101,14 +116,23 @@ int main(void) EndTextureMode(); BeginDrawing(); - ClearBackground(RED); + ClearBackground(LIGHTGRAY); - BeginMode2D(screenSpaceCamera); + if (smoothOn) + { + BeginMode2D(screenSpaceCamera); + DrawTexturePro(target.texture, sourceRec, destRec, origin, 0.0f, WHITE); + EndMode2D(); + } + else + { DrawTexturePro(target.texture, sourceRec, destRec, origin, 0.0f, WHITE); - EndMode2D(); + } DrawText(TextFormat("Screen resolution: %ix%i", screenWidth, screenHeight), 10, 10, 20, DARKBLUE); DrawText(TextFormat("World resolution: %ix%i", virtualScreenWidth, virtualScreenHeight), 10, 40, 20, DARKGREEN); + DrawText(TextFormat("Smooth: %s", (smoothOn ? "ON" : "OFF")), 10, screenHeight - 60, 20, RED); + DrawText(TextFormat("Overscan: %s", (overscan ? "ON" : "OFF")), 10, screenHeight - 30, 20, RED); DrawFPS(GetScreenWidth() - 95, 10); EndDrawing(); //---------------------------------------------------------------------------------- @@ -122,4 +146,4 @@ int main(void) //-------------------------------------------------------------------------------------- return 0; -} \ No newline at end of file +} diff --git a/examples/core/core_smooth_pixelperfect.png b/examples/core/core_smooth_pixelperfect.png index d3b6ce012..30c8ec523 100644 Binary files a/examples/core/core_smooth_pixelperfect.png and b/examples/core/core_smooth_pixelperfect.png differ