From ca6fd8c563e060d519c834cfa5dc8c41a4fa3f95 Mon Sep 17 00:00:00 2001 From: MitchellHansen Date: Wed, 20 Jan 2016 14:23:05 -0800 Subject: [PATCH] Just messing around, I'll save anyway. Profiled the multi to linear function being called each time in Update. And moved it to the class constructor but it actually slowed it down. Might be cache related? As it is the difference between computing the value on the fly vs. getting the stored value --- Conways.sln | 3 +++ Conways/Conways.vcxproj | 3 ++- Conways/Node.h | 6 ++++-- Conways/main.cpp | 13 ++++++++----- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Conways.sln b/Conways.sln index 508f212..371ba6d 100644 --- a/Conways.sln +++ b/Conways.sln @@ -6,6 +6,9 @@ MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Conways", "Conways\Conways.vcxproj", "{9035B83C-F117-480E-9DEB-435AA0EBEA3F}" EndProject Global + GlobalSection(Performance) = preSolution + HasPerformanceSessions = true + EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 diff --git a/Conways/Conways.vcxproj b/Conways/Conways.vcxproj index 4fe71f9..354f50e 100644 --- a/Conways/Conways.vcxproj +++ b/Conways/Conways.vcxproj @@ -147,12 +147,13 @@ Level3 - MaxSpeed + Full true true NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true Z:\Cpp_Libs\SFML-Visual_Studio2015RCx64\include;%(AdditionalIncludeDirectories) + Speed Console diff --git a/Conways/Node.h b/Conways/Node.h index eacb959..a3f9ca4 100644 --- a/Conways/Node.h +++ b/Conways/Node.h @@ -4,8 +4,8 @@ class Node { public: - static const int x_bound = 1000; - static const int y_bound = 1000; + static const int x_bound = 300; + static const int y_bound = 300; Node(sf::Vector2i position_); ~Node(); @@ -23,5 +23,7 @@ private: sf::Vector2i position; int curr_state; int next_state; + + }; diff --git a/Conways/main.cpp b/Conways/main.cpp index 99b1dfd..a69dbed 100644 --- a/Conways/main.cpp +++ b/Conways/main.cpp @@ -6,8 +6,8 @@ #include #include -const int WINDOW_X = 1000; -const int WINDOW_Y = 1000; +const int WINDOW_X = 300; +const int WINDOW_Y = 300; float elap_time() { static __int64 start = 0; @@ -43,7 +43,7 @@ int main() { for (int x = 0; x < Node::x_bound; x++) { for (int y = 0; y < Node::y_bound; y++) { node_vec.push_back(Node(sf::Vector2i(x, y))); - if ((x % 30 == 0)) { + if ((x % 5 == 0) || (y % 8 == 0)) { node_vec.at(node_vec.size() - 1).Revive(); } } @@ -63,6 +63,7 @@ int main() { texture.create(WINDOW_X, WINDOW_Y); sf::Sprite sprite(texture); + while (window.isOpen()) { sf::Event event; @@ -107,12 +108,14 @@ int main() { } else { - //pixel_array[i * 4] *= 0.999;// 49; // R? - pixel_array[i * 4 + 1] *= 0.999;//68; // G? + pixel_array[i * 4] *= 0.999;// 49; // R? + //pixel_array[i * 4 + 1] *= 0.999;//68; // G? pixel_array[i * 4 + 2] *= 0.999;//72; // B? pixel_array[i * 4 + 3] *= 0.999;//255; // A? } } + + window.clear(); texture.update(pixel_array); window.draw(sprite);