Panagiotis Christopoulos Charitos 14 ani în urmă
părinte
comite
f6a1393a39

+ 1 - 1
build/release_llvm/gen.cfg.py

@@ -10,6 +10,6 @@ executableName = "anki"
 compiler = "clang++"
 compiler = "clang++"
 linker = "llvm-ld"
 linker = "llvm-ld"
 
 
-compilerFlags = "-DPLATFORM_LINUX -DMATH_INTEL_SIMD -DNDEBUG -DBOOST_DISABLE_ASSERTS -DREVISION=\\\"`svnversion ../..`\\\" -c -pedantic-errors -pedantic -ansi -Wall -Wextra -W -Wno-long-long -pipe -msse4 -O3 -mtune=core2 -ffast-math -emit-llvm"
+compilerFlags = "-DPLATFORM_LINUX -DMATH_INTEL_SIMD -DNDEBUG -DBOOST_DISABLE_ASSERTS -DREVISION=\\\"`svnversion ../..`\\\" -c -pedantic-errors -pedantic -ansi -Wall -Wextra -W -Wno-long-long -pipe -msse4 -O3 -mtune=core2 -ffast-math"
 
 
 linkerFlags = "-L../../extern/lib-x86-64-linux -lBulletSoftBody -lBulletDynamics -lBulletCollision -lLinearMath -lGLEW -lGLU -lGL -ljpeg -lSDL -lpng -lpython2.6 -lboost_system -lboost_python -lboost_filesystem -lboost_thread -lfreetype"
 linkerFlags = "-L../../extern/lib-x86-64-linux -lBulletSoftBody -lBulletDynamics -lBulletCollision -lLinearMath -lGLEW -lGLU -lGL -ljpeg -lSDL -lpng -lpython2.6 -lboost_system -lboost_python -lboost_filesystem -lboost_thread -lfreetype"

+ 30 - 27
src/Main.cpp

@@ -372,20 +372,20 @@ void mainLoop()
 		prevUpdateTime = crntTime;
 		prevUpdateTime = crntTime;
 		crntTime = HighRezTimer::getCrntTime();
 		crntTime = HighRezTimer::getCrntTime();
 
 
+		//
+		// Update
+		//
 		mainLoopExtra();
 		mainLoopExtra();
-
 		AppSingleton::getInstance().execStdinScpripts();
 		AppSingleton::getInstance().execStdinScpripts();
 		SceneSingleton::getInstance().getPhysMasterContainer().update(prevUpdateTime, crntTime);
 		SceneSingleton::getInstance().getPhysMasterContainer().update(prevUpdateTime, crntTime);
 		SceneSingleton::getInstance().updateAllWorldStuff();
 		SceneSingleton::getInstance().updateAllWorldStuff();
 		SceneSingleton::getInstance().doVisibilityTests(*AppSingleton::getInstance().getActiveCam());
 		SceneSingleton::getInstance().doVisibilityTests(*AppSingleton::getInstance().getActiveCam());
 		SceneSingleton::getInstance().updateAllControllers();
 		SceneSingleton::getInstance().updateAllControllers();
 		Event::ManagerSingleton::getInstance().updateAllEvents(prevUpdateTime, crntTime);
 		Event::ManagerSingleton::getInstance().updateAllEvents(prevUpdateTime, crntTime);
-
 		MainRendererSingleton::getInstance().render(*AppSingleton::getInstance().getActiveCam());
 		MainRendererSingleton::getInstance().render(*AppSingleton::getInstance().getActiveCam());
 
 
 		painter->setPosition(Vec2(0.0, 0.1));
 		painter->setPosition(Vec2(0.0, 0.1));
 		painter->setColor(Vec4(1.0));
 		painter->setColor(Vec4(1.0));
-
 		//painter->drawText("A");
 		//painter->drawText("A");
 		painter->drawText("Once upon a time in a place called Kickapoo.");
 		painter->drawText("Once upon a time in a place called Kickapoo.");
 
 
@@ -406,39 +406,42 @@ void mainLoop()
 
 
 		AppSingleton::getInstance().swapBuffers();
 		AppSingleton::getInstance().swapBuffers();
 
 
-		HighRezTimer::Scalar a = timer.getElapsedTime();
-		HighRezTimer::Scalar b = AppSingleton::getInstance().getTimerTick();
-		HighRezTimer::Scalar timeToSpendForRsrcPostProcess;
-		if(a < b)
-		{
-			timeToSpendForRsrcPostProcess = b - a;
-		}
-		else
-		{
-			timeToSpendForRsrcPostProcess = 0.001;
-		}
-		ResourceManagerSingleton::getInstance().postProcessFinishedLoadingRequests(timeToSpendForRsrcPostProcess);
 
 
-		if(1)
+		//
+		// Async resource loading
+		//
+		if(ResourceManagerSingleton::getInstance().getAsyncLoadingRequestsNum() > 0)
 		{
 		{
-			//AppSingleton::getInstance().waitForNextFrame();
-
-			timer.stop();
-			if(timer.getElapsedTime() < AppSingleton::getInstance().getTimerTick())
+			HighRezTimer::Scalar a = timer.getElapsedTime();
+			HighRezTimer::Scalar b = AppSingleton::getInstance().getTimerTick();
+			HighRezTimer::Scalar timeToSpendForRsrcPostProcess;
+			if(a < b)
 			{
 			{
-				SDL_Delay(AppSingleton::getInstance().getTimerTick() - timer.getElapsedTime());
+				timeToSpendForRsrcPostProcess = b - a;
 			}
 			}
-		}
-		else
-		{
-			if(MainRendererSingleton::getInstance().getFramesNum() == 100)
+			else
 			{
 			{
-				break;
+				timeToSpendForRsrcPostProcess = 0.001;
 			}
 			}
+			ResourceManagerSingleton::getInstance().postProcessFinishedLoadingRequests(timeToSpendForRsrcPostProcess);
+		}
+
+		//
+		// Sleep
+		//
+		timer.stop();
+		if(timer.getElapsedTime() < AppSingleton::getInstance().getTimerTick())
+		{
+			SDL_Delay((AppSingleton::getInstance().getTimerTick() - timer.getElapsedTime()) * 1000.0);
 		}
 		}
+
+		/*if(MainRendererSingleton::getInstance().getFramesNum() == 100)
+		{
+			break;
+		}*/
 	}
 	}
 
 
-	INFO("Exiting main loop (" << mainLoopTimer.getElapsedTime() << ")");
+	INFO("Exiting main loop (" << mainLoopTimer.getElapsedTime() << " sec)");
 }
 }
 
 
 
 

+ 5 - 3
src/Resources/Core/ResourceManager.h

@@ -42,7 +42,6 @@ class ResourceManager
 		ResourceManager();
 		ResourceManager();
 		~ResourceManager();
 		~ResourceManager();
 
 
-
 		/// Load a resource
 		/// Load a resource
 		/// See if its already loaded, if its not:
 		/// See if its already loaded, if its not:
 		/// - Create an instance
 		/// - Create an instance
@@ -57,7 +56,10 @@ class ResourceManager
 		void unload(const typename Types<Type>::Hook& info);
 		void unload(const typename Types<Type>::Hook& info);
 		
 		
 		/// See RsrcAsyncLoadingReqsHandler::postProcessFinishedRequests
 		/// See RsrcAsyncLoadingReqsHandler::postProcessFinishedRequests
-		void postProcessFinishedLoadingRequests(uint maxTime);
+		void postProcessFinishedLoadingRequests(float maxTime);
+
+		/// Get the number of total pending requests
+		size_t getAsyncLoadingRequestsNum() const {return rsrcAsyncLoadingReqsHandler.getRequestsNum();}
 
 
 	private:
 	private:
 		/// @name Containers
 		/// @name Containers
@@ -111,7 +113,7 @@ class ResourceManager
 };
 };
 
 
 
 
-inline void ResourceManager::postProcessFinishedLoadingRequests(uint maxTime)
+inline void ResourceManager::postProcessFinishedLoadingRequests(float maxTime)
 {
 {
 	rsrcAsyncLoadingReqsHandler.postProcessFinishedRequests(maxTime);
 	rsrcAsyncLoadingReqsHandler.postProcessFinishedRequests(maxTime);
 }
 }

+ 3 - 0
src/Resources/Core/RsrcAsyncLoadingReqsHandler.h

@@ -35,6 +35,9 @@ class RsrcAsyncLoadingReqsHandler
 		/// again.
 		/// again.
 		/// In seconds
 		/// In seconds
 		void postProcessFinishedRequests(float maxTime);
 		void postProcessFinishedRequests(float maxTime);
+
+		/// Get the number of total pending requests
+		size_t getRequestsNum() const {return requests.size();}
 	
 	
 	private:
 	private:
 		AsyncLoader al; ///< Asynchronous loader
 		AsyncLoader al; ///< Asynchronous loader

+ 0 - 1
src/Resources/Core/RsrcLoadingRequests.cpp

@@ -32,6 +32,5 @@ void RsrcTextureLoadingRequest::doPostLoading()
 {
 {
 	Texture* tex = new Texture;
 	Texture* tex = new Texture;
 	tex->load(img);
 	tex->load(img);
-	INFO(tex->getGlId());
 	*pTex = tex;
 	*pTex = tex;
 }
 }

+ 1 - 1
src/Resources/Texture/Texture.cpp

@@ -14,7 +14,7 @@
 //======================================================================================================================
 //======================================================================================================================
 int Texture::textureUnitsNum = -1;
 int Texture::textureUnitsNum = -1;
 bool Texture::mipmappingEnabled = true;
 bool Texture::mipmappingEnabled = true;
-bool Texture::compressionEnabled = false;
+bool Texture::compressionEnabled = true;
 int Texture::anisotropyLevel = 8;
 int Texture::anisotropyLevel = 8;