From 937fcf9ee382970d30d09ae44e4bc98c87644d1d Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Wed, 14 Aug 2019 02:19:31 -0400 Subject: [PATCH] Use by value --- examples/textures/textures_bunnymark.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/textures/textures_bunnymark.cpp b/examples/textures/textures_bunnymark.cpp index 7766212..ad80454 100644 --- a/examples/textures/textures_bunnymark.cpp +++ b/examples/textures/textures_bunnymark.cpp @@ -58,7 +58,7 @@ int main(void) // Load bunny texture const raylib::Texture2D texBunny("resources/wabbit_alpha.png"); - std::vector bunnies; + std::vector bunnies; SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- @@ -75,15 +75,15 @@ int main(void) { if (bunnies.size() < MAX_BUNNIES) { - bunnies.push_back(new Bunny()); + bunnies.push_back(Bunny()); } } } // Update bunnies - for (std::vector::iterator bunny = bunnies.begin() ; bunny != bunnies.end(); ++bunny) { - (*bunny)->Update(texBunny); + for (std::vector::iterator bunny = bunnies.begin() ; bunny != bunnies.end(); ++bunny) { + (*bunny).Update(texBunny); } //---------------------------------------------------------------------------------- @@ -93,14 +93,14 @@ int main(void) ClearBackground(RAYWHITE); - for (std::vector::iterator bunny = bunnies.begin() ; bunny != bunnies.end(); ++bunny) { + for (std::vector::iterator bunny = bunnies.begin() ; bunny != bunnies.end(); ++bunny) { // NOTE: When internal batch buffer limit is reached (MAX_BATCH_ELEMENTS), // a draw call is launched and buffer starts being filled again; // before issuing a draw call, updated vertex data from internal CPU buffer is send to GPU... // Process of sending data is costly and it could happen that GPU data has not been completely // processed for drawing while new data is tried to be sent (updating current in-use buffers) // it could generates a stall and consequently a frame drop, limiting the number of drawn bunnies - DrawTexture(texBunny, (*bunny)->position.x, (*bunny)->position.y, (*bunny)->color); + DrawTexture(texBunny, (*bunny).position.x, (*bunny).position.y, (*bunny).color); } DrawRectangle(0, 0, screenWidth, 40, BLACK);