Parcourir la source

Changes in the RsrcPtr so we can have vectors of RsrcPtrs

Panagiotis Christopoulos Charitos il y a 15 ans
Parent
commit
6de9d6f497

+ 1 - 1
src/Renderer/MainRenderer.cpp

@@ -102,7 +102,7 @@ void MainRenderer::render(Camera& cam_)
 	glDisable(GL_DEPTH_TEST);
 	glDisable(GL_BLEND);
 	sProg->bind();
-	sProg->findUniVar("rasterImage")->setTexture(ms->getSpecularFai(), 0);
+	sProg->findUniVar("rasterImage")->setTexture(is->getFai(), 0);
 	//sProg->findUniVar("rasterImage")->setTexture(pps.postPassFai, 0);
 	drawQuad();
 }

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

@@ -18,6 +18,9 @@ class Resource
 	template<typename Type>
 	friend class RsrcContainer; ///< Cause it calls Resource::load and Resource::unload
 
+	template<typename Type>
+	friend class RsrcPtr; ///< Cause the RsrcPtr copy constructor increases the referenceCounter
+
 	public:
 		enum ResourceType
 		{

+ 5 - 1
src/Resources/Core/RsrcContainer.inl.h

@@ -2,6 +2,7 @@
 #include <boost/lexical_cast.hpp>
 #include "RsrcContainer.h"
 #include "Exception.h"
+#include "Messaging.h"
 
 
 //======================================================================================================================
@@ -10,7 +11,10 @@
 template<typename Type>
 RsrcContainer<Type>::~RsrcContainer()
 {
-	//RASSERT_THROW_EXCEPTION(BaseClass::size() != 0); // this means that somehow a resource is still loaded
+	if(BaseClass::size() != 0)
+	{
+		ERROR("Resources are still loaded");
+	}
 }
 
 

+ 12 - 3
src/Resources/Core/RsrcPtr.h

@@ -14,8 +14,12 @@ template<typename Type>
 class RsrcPtr
 {
 	public:
+		/// Default constructor
 		RsrcPtr(): p(NULL) {}
 
+		/// Copy constructor
+		RsrcPtr(const RsrcPtr& a);
+
 		/// It unloads the resource or it decreases its reference counter
 		~RsrcPtr() {unload();}
 
@@ -30,9 +34,6 @@ class RsrcPtr
 		Type* get() const {return p;}
 
 	private:
-		/// Non copyable
-		RsrcPtr(const RsrcPtr& a);
-
 		/// Unloads the resource @see loadRsrc
 		void unload();
 
@@ -44,6 +45,14 @@ class RsrcPtr
 // Inlines                                                                                                             =
 //======================================================================================================================
 
+template<typename Type>
+RsrcPtr<Type>::RsrcPtr(const RsrcPtr& a):
+	p(a.p)
+{
+	++p->referenceCounter;
+}
+
+
 template<typename Type>
 Type& RsrcPtr<Type>::operator*() const
 {

+ 3 - 1
src/Resources/Model.h

@@ -8,6 +8,8 @@
 class Mesh;
 class Material;
 class Vao;
+class Skeleton;
+class SkelAnim;
 
 
 /// File format:
@@ -62,7 +64,7 @@ class Model: public Resource
 
 	private:
 		RsrcPtr<Skeleton> skel;
-		//RsrcPtr<SkelAnim> sAnim;
+		Vec<RsrcPtr<SkelAnim> > sAnims;
 };