Przeglądaj źródła

Many changes and Im too bored to write a log.

Panagiotis Christopoulos Charitos 15 lat temu
rodzic
commit
c5e6a41e04

+ 32 - 34
build/debug/Makefile

@@ -1,7 +1,7 @@
 # Generated by gBuildSystem, command: ../../../godlike-projects/gBuildSystem/gbs.py 
 
 CXX = g++
-CFLAGS = -DDEBUG_ENABLED=1 -DPLATFORM_LINUX -DREVISION=\"`svnversion -c ../..`\" -c -pedantic-errors -pedantic -ansi -Wall -Wextra -W -Wno-long-long -Wfatal-errors -pipe -g3 -pg -fsingle-precision-constant
+CFLAGS = -DDEBUG_ENABLED=1 -DPLATFORM_LINUX -DREVISION=\"`svnversion -c ../..`\" -c -pedantic-errors -pedantic -ansi -Wall -Wextra -W -Wno-long-long -pipe -g3 -pg -fsingle-precision-constant
 PHFLAGS = 
 LFLAGS = -rdynamic -pg -L../../extern/lib-x86-64-linux -Wl,-Bstatic -lBulletSoftBody -lBulletDynamics -lBulletCollision -lLinearMath -lGLEW -lGLU -Wl,-Bdynamic -lGL -ljpeg -lSDL -lpng -lpython2.6 -lboost_system -lboost_python -lboost_filesystem -lboost_thread
 EXECUTABLE = anki
@@ -3497,12 +3497,11 @@ Material.o: ../../src/Resources//Material.cpp \
 
 Texture.o: ../../src/Resources//Texture.cpp \
  ../../extern/include/GL/glew.h ../../src/Resources//Texture.h \
- ../../src/Core/Common.h ../../src/Util/StdTypes.h \
- ../../src/Util/Properties.h ../../src/Util/Exception.h \
- ../../src/Resources/Core/Resource.h ../../src/Util/Util.h \
- ../../src/Util/Vec.h ../../src/Util/Exception.h \
- ../../src/Renderer/Renderer.h ../../src/Math/Math.h \
- ../../src/Math/Vec2.h ../../src/Math/MathCommon.h \
+ ../../src/Resources/Core/Resource.h ../../src/Core/Common.h \
+ ../../src/Util/StdTypes.h ../../src/Util/Properties.h \
+ ../../src/Util/Exception.h ../../src/Util/Util.h ../../src/Util/Vec.h \
+ ../../src/Util/Exception.h ../../src/Renderer/Renderer.h \
+ ../../src/Math/Math.h ../../src/Math/Vec2.h ../../src/Math/MathCommon.h \
  ../../src/Math/Vec2.inl.h ../../src/Math/MathCommon.inl.h \
  ../../src/Math/Vec3.h ../../src/Math/Vec3.inl.h ../../src/Math/Vec4.h \
  ../../src/Math/Vec4.inl.h ../../src/Math/Quat.h \
@@ -3522,7 +3521,8 @@ Texture.o: ../../src/Resources//Texture.cpp \
  ../../src/Renderer/Is.h ../../src/Renderer/Sm.h ../../src/Renderer/Smo.h \
  ../../src/Renderer/Pps.h ../../src/Renderer/Hdr.h \
  ../../src/Renderer/Ssao.h ../../src/Renderer/Bs.h \
- ../../src/Renderer/Dbg.h ../../src/Resources/Helpers/Image.h
+ ../../src/Renderer/Dbg.h ../../src/Resources/Helpers/Image.h \
+ ../../src/Misc/GlException.h
 	@echo Compiling ../../src/Resources//Texture.cpp...
 	@$(CXX) $(INCPATH) $(CFLAGS) ../../src/Resources//Texture.cpp -o Texture.o
 
@@ -3548,18 +3548,17 @@ SkelAnim.o: ../../src/Resources//SkelAnim.cpp \
 	@$(CXX) $(INCPATH) $(CFLAGS) ../../src/Resources//SkelAnim.cpp -o SkelAnim.o
 
 Extension.o: ../../src/Resources//Extension.cpp \
- ../../src/Resources//Extension.h ../../src/Core/Common.h \
- ../../src/Util/StdTypes.h ../../src/Util/Properties.h \
- ../../src/Util/Exception.h ../../src/Resources/Core/Resource.h \
+ ../../src/Resources//Extension.h ../../src/Resources/Core/Resource.h \
+ ../../src/Core/Common.h ../../src/Util/StdTypes.h \
+ ../../src/Util/Properties.h ../../src/Util/Exception.h \
  ../../src/Util/Util.h ../../src/Util/Vec.h ../../src/Util/Exception.h
 	@echo Compiling ../../src/Resources//Extension.cpp...
 	@$(CXX) $(INCPATH) $(CFLAGS) ../../src/Resources//Extension.cpp -o Extension.o
 
 Skeleton.o: ../../src/Resources//Skeleton.cpp \
- ../../src/Resources//Skeleton.h ../../src/Core/Common.h \
- ../../src/Util/StdTypes.h ../../src/Util/Properties.h \
- ../../src/Util/Exception.h ../../src/Math/Math.h ../../src/Math/Vec2.h \
- ../../src/Math/MathCommon.h ../../src/Math/Vec2.inl.h \
+ ../../src/Resources//Skeleton.h ../../src/Math/Math.h \
+ ../../src/Math/Vec2.h ../../src/Math/MathCommon.h \
+ ../../src/Util/StdTypes.h ../../src/Math/Vec2.inl.h \
  ../../src/Math/MathCommon.inl.h ../../src/Math/Vec3.h \
  ../../src/Math/Vec3.inl.h ../../src/Math/Vec4.h \
  ../../src/Math/Vec4.inl.h ../../src/Math/Quat.h \
@@ -3569,19 +3568,19 @@ Skeleton.o: ../../src/Resources//Skeleton.cpp \
  ../../src/Math/Mat3.inl.h ../../src/Math/Mat4.h \
  ../../src/Math/Mat4.inl.h ../../src/Math/MathFuncs.h \
  ../../src/Math/MathFuncs.inl.h ../../src/Math/Transform.h \
- ../../src/Math/Transform.inl.h ../../src/Resources/Core/Resource.h \
- ../../src/Util/Util.h ../../src/Util/Vec.h ../../src/Util/Exception.h \
- ../../src/Util/Scanner.h ../../src/Util/StdTypes.h \
- ../../src/Misc/Parser.h ../../src/Misc/Parser.inl.h \
- ../../src/Misc/Parser.h
+ ../../src/Math/Transform.inl.h ../../src/Util/Exception.h \
+ ../../src/Resources/Core/Resource.h ../../src/Core/Common.h \
+ ../../src/Util/Properties.h ../../src/Util/Util.h ../../src/Util/Vec.h \
+ ../../src/Util/Exception.h ../../src/Util/BinaryStream.h \
+ ../../src/Util/StdTypes.h
 	@echo Compiling ../../src/Resources//Skeleton.cpp...
 	@$(CXX) $(INCPATH) $(CFLAGS) ../../src/Resources//Skeleton.cpp -o Skeleton.o
 
 Script.o: ../../src/Resources//Script.cpp ../../src/Resources//Script.h \
- ../../src/Core/Common.h ../../src/Util/StdTypes.h \
- ../../src/Util/Properties.h ../../src/Util/Exception.h \
- ../../src/Resources/Core/Resource.h ../../src/Util/Util.h \
- ../../src/Util/Vec.h ../../src/Util/Exception.h
+ ../../src/Resources/Core/Resource.h ../../src/Core/Common.h \
+ ../../src/Util/StdTypes.h ../../src/Util/Properties.h \
+ ../../src/Util/Exception.h ../../src/Util/Util.h ../../src/Util/Vec.h \
+ ../../src/Util/Exception.h
 	@echo Compiling ../../src/Resources//Script.cpp...
 	@$(CXX) $(INCPATH) $(CFLAGS) ../../src/Resources//Script.cpp -o Script.o
 
@@ -4605,13 +4604,12 @@ ShaderPrePreprocessor.o: \
 	@$(CXX) $(INCPATH) $(CFLAGS) ../../src/Resources/Helpers//ShaderPrePreprocessor.cpp -o ShaderPrePreprocessor.o
 
 RsrcPtr.o: ../../src/Resources/Core//RsrcPtr.cpp \
- ../../src/Resources/Core//RsrcPtr.h ../../src/Core/Common.h \
- ../../src/Util/StdTypes.h ../../src/Util/Properties.h \
- ../../src/Util/Exception.h ../../src/Resources/Core//RsrcContainer.h \
- ../../src/Util/Vec.h ../../src/Util/Exception.h \
- ../../src/Resources/Core//RsrcContainer.inl.h \
+ ../../src/Resources/Core//RsrcPtr.h ../../src/Util/Exception.h \
+ ../../src/Resources/Core//RsrcContainer.h ../../src/Util/Vec.h \
+ ../../src/Util/Exception.h ../../src/Resources/Core//RsrcContainer.inl.h \
  ../../src/Resources/Texture.h ../../src/Resources/Core/Resource.h \
- ../../src/Util/Util.h ../../src/Util/Vec.h \
+ ../../src/Core/Common.h ../../src/Util/StdTypes.h \
+ ../../src/Util/Properties.h ../../src/Util/Util.h ../../src/Util/Vec.h \
  ../../src/Resources/Material.h ../../src/Math/Math.h \
  ../../src/Math/Vec2.h ../../src/Math/MathCommon.h \
  ../../src/Math/Vec2.inl.h ../../src/Math/MathCommon.inl.h \
@@ -4636,11 +4634,11 @@ RsrcPtr.o: ../../src/Resources/Core//RsrcPtr.cpp \
 	@$(CXX) $(INCPATH) $(CFLAGS) ../../src/Resources/Core//RsrcPtr.cpp -o RsrcPtr.o
 
 RsrcContainers.o: ../../src/Resources/Core//RsrcContainers.cpp \
- ../../src/Resources/Core//RsrcContainer.h ../../src/Core/Common.h \
- ../../src/Util/StdTypes.h ../../src/Util/Properties.h \
- ../../src/Util/Exception.h ../../src/Util/Vec.h \
+ ../../src/Resources/Core//RsrcContainer.h ../../src/Util/Vec.h \
  ../../src/Util/Exception.h ../../src/Resources/Core//RsrcContainer.inl.h \
- ../../src/Resources/Texture.h ../../src/Resources/Core/Resource.h \
+ ../../src/Util/Exception.h ../../src/Resources/Texture.h \
+ ../../src/Resources/Core/Resource.h ../../src/Core/Common.h \
+ ../../src/Util/StdTypes.h ../../src/Util/Properties.h \
  ../../src/Util/Util.h ../../src/Util/Vec.h \
  ../../src/Resources/Material.h ../../src/Math/Math.h \
  ../../src/Math/Vec2.h ../../src/Math/MathCommon.h \

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

@@ -9,6 +9,6 @@ executableName = "anki"
 
 compiler = "g++"
 
-compilerFlags = "-DDEBUG_ENABLED=1 -DPLATFORM_LINUX -DREVISION=\\\"`svnversion -c ../..`\\\" -c -pedantic-errors -pedantic -ansi -Wall -Wextra -W -Wno-long-long -Wfatal-errors -pipe -g3 -pg -fsingle-precision-constant"
+compilerFlags = "-DDEBUG_ENABLED=1 -DPLATFORM_LINUX -DREVISION=\\\"`svnversion -c ../..`\\\" -c -pedantic-errors -pedantic -ansi -Wall -Wextra -W -Wno-long-long -pipe -g3 -pg -fsingle-precision-constant"
 
 linkerFlags = "-rdynamic -pg -L../../extern/lib-x86-64-linux -Wl,-Bstatic -lBulletSoftBody -lBulletDynamics -lBulletCollision -lLinearMath -lGLEW -lGLU -Wl,-Bdynamic -lGL -ljpeg -lSDL -lpng -lpython2.6 -lboost_system -lboost_python -lboost_filesystem -lboost_thread"

+ 25 - 0
src/Misc/GlException.h

@@ -0,0 +1,25 @@
+#ifndef GL_EXCEPTION_H
+#define GL_EXCEPTION_H
+
+#include <string>
+#include "Exception.h"
+
+
+/// The function throws an exception if there is an OpenGL error. Use it with the ON_GL_FAIL_THROW_EXCEPTION macro
+inline void glConditionalThrowException(const char* file, int line, const char* func)
+{
+	GLenum errId = glGetError();
+	if(errId == GL_NO_ERROR)
+	{
+		return;
+	}
+
+	const char* glerr = reinterpret_cast<const char*>(gluErrorString(errId));
+	throw Exception(std::string("OpenGL exception: ") + glerr, file, line, func);
+}
+
+
+#define ON_GL_FAIL_THROW_EXCEPTION() glConditionalThrowException(__FILE__, __LINE__, __func__)
+
+
+#endif

+ 1 - 2
src/Misc/skybox.cpp

@@ -39,8 +39,7 @@ bool Skybox::load(const char* filenames[6])
 	}
 
 	noise.loadRsrc("gfx/noise2.tga");
-	noise->setTexParameter(GL_TEXTURE_WRAP_S, GL_REPEAT);
-	noise->setTexParameter(GL_TEXTURE_WRAP_T, GL_REPEAT);
+	noise->setRepeat(true);
 
 	shader.loadRsrc("shaders/ms_mp_skybox.glsl");
 

+ 2 - 3
src/Renderer/Hdr.cpp

@@ -21,8 +21,7 @@ void Hdr::initFbo(Fbo& fbo, Texture& fai)
 
 	// create the texes
 	fai.createEmpty2D(width, height, GL_RGB, GL_RGB, GL_FLOAT);
-	fai.setTexParameter(GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-	fai.setTexParameter(GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+	fai.setFiltering(Texture::TFT_LINEAR);
 
 	// attach
 	glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, fai.getGlId(), 0);
@@ -55,7 +54,7 @@ void Hdr::init(const RendererInitializer& initializer)
 	initFbo(hblurFbo, hblurFai);
 	initFbo(vblurFbo, fai);
 
-	fai.setTexParameter(GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+	fai.setFiltering(Texture::TFT_LINEAR);
 
 
 	// init shaders

+ 7 - 1
src/Renderer/Is.cpp

@@ -77,8 +77,14 @@ void Is::initFbo()
 	fbo.setNumOfColorAttachements(1);
 
 	// create the txtrs
-	if(!fai.createEmpty2D(r.getWidth(), r.getHeight(), GL_RGB, GL_RGB, GL_FLOAT))
+	try
+	{
+		fai.createEmpty2D(r.getWidth(), r.getHeight(), GL_RGB, GL_RGB, GL_FLOAT);
+	}
+	catch(Exception& e)
+	{
 		FATAL("Cannot create deferred shading illumination stage FAI");
+	}
 
 	// attach
 	glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, fai.getGlId(), 0);

+ 8 - 5
src/Renderer/Ms.cpp

@@ -19,11 +19,14 @@ void Ms::init(const RendererInitializer& initializer)
 	fbo.setNumOfColorAttachements(3);
 
 	// create the FAIs
-	if(!normalFai.createEmpty2D(r.getWidth(), r.getHeight(), GL_RG16F, GL_RG, GL_FLOAT) ||
-	   !diffuseFai.createEmpty2D(r.getWidth(), r.getHeight(), GL_RGB16F, GL_RGB, GL_FLOAT) ||
-	   !specularFai.createEmpty2D(r.getWidth(), r.getHeight(), GL_RGBA16F, GL_RGBA, GL_FLOAT) ||
-	   !depthFai.createEmpty2D(r.getWidth(), r.getHeight(), GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8))
-	   //!depthFai.createEmpty2D(r.getWidth(), r.getHeight(), GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_FLOAT, false))
+	try
+	{
+		normalFai.createEmpty2D(r.getWidth(), r.getHeight(), GL_RG16F, GL_RG, GL_FLOAT);
+	  diffuseFai.createEmpty2D(r.getWidth(), r.getHeight(), GL_RGB16F, GL_RGB, GL_FLOAT);
+	  specularFai.createEmpty2D(r.getWidth(), r.getHeight(), GL_RGBA16F, GL_RGBA, GL_FLOAT);
+	  depthFai.createEmpty2D(r.getWidth(), r.getHeight(), GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8);
+	}
+	catch(Exception& e)
 	{
 		FATAL("Failed to create one MS FAI. See prev error");
 	}

+ 4 - 5
src/Renderer/Sm.cpp

@@ -28,17 +28,16 @@ void Sm::init(const RendererInitializer& initializer)
 
 	// texture
 	shadowMap.createEmpty2D(resolution, resolution, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_FLOAT);
-	shadowMap.setTexParameter(GL_TEXTURE_MIN_FILTER, GL_NEAREST);
 	if(bilinearEnabled)
 	{
-		shadowMap.setTexParameter(GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+		shadowMap.setFiltering(Texture::TFT_LINEAR);
 	}
 	else
 	{
-		shadowMap.setTexParameter(GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+		shadowMap.setFiltering(Texture::TFT_NEAREST);
 	}
-	shadowMap.setTexParameter(GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE);
-	shadowMap.setTexParameter(GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE);
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
 	/*
 	 * If you dont want to use the FFP for comparing the shadowmap (the above two lines) then you can make the comparison
 	 * inside the glsl shader. The GL_LEQUAL means that: shadow = (R <= Dt) ? 1.0 : 0.0; . The R is given by:

+ 16 - 29
src/Resources/Core/RsrcContainer.h

@@ -1,7 +1,6 @@
 #ifndef RSRC_CONTAINER_H
 #define RSRC_CONTAINER_H
 
-#include "Common.h"
 #include "Vec.h"
 
 
@@ -9,9 +8,7 @@ template<typename Type>
 class RsrcPtr;
 
 
-/**
- * Resource container template class
- */
+/// Resource container template class
 template<typename Type>
 class RsrcContainer: public Vec<Type*>
 {
@@ -26,39 +23,29 @@ class RsrcContainer: public Vec<Type*>
 		~RsrcContainer();
 
 	private:
-		/**
-		 * load an object and register it. If its already loaded return its pointer
-		 * @param fname The filename that initializes the object
-		 * @return A pointer of a new resource or NULL on fail
-		 */
+		/// load an object and register it. If its already loaded return its pointer
+		/// @param fname The filename that initializes the object
+		/// @return A pointer of a new resource or NULL on fail
 		Type* load(const char* fname);
 
-		/**
-		 * unload item. If nobody else uses it then delete it completely
-		 * @param x Pointer to the instance we want to unload
-		 */
+		/// unload item. If nobody else uses it then delete it completely
+		/// @param x Pointer to the instance we want to unload
 		void unload(Type* x);
 
-		/**
-		 * Search inside the container by name
-		 * @param name The name of the resource
-		 * @return The iterator of the content end of vector if not found
-		 */
+		/// Search inside the container by name
+		/// @param name The name of the resource
+		/// @return The iterator of the content end of vector if not found
 		Iterator findByName(const char* name);
 
-		/**
-		 * Search inside the container by name and path
-		 * @param name The name of the resource
-		 * @param path The path of the resource
-		 * @return The iterator of the content end of vector if not found
-		 */
+		/// Search inside the container by name and path
+		/// @param name The name of the resource
+		/// @param path The path of the resource
+		/// @return The iterator of the content end of vector if not found
 		Iterator findByNameAndPath(const char* name, const char* path);
 
-		/**
-	   * Search inside the container by pointer
-		 * @param name The name of the resource object
-		 * @return The iterator of the content end of vector if not found
-		 */
+	  /// Search inside the container by pointer
+		/// @param name The name of the resource object
+		/// @return The iterator of the content end of vector if not found
 		Iterator findByPtr(Type* ptr);
 };
 

+ 11 - 10
src/Resources/Core/RsrcContainer.inl.h

@@ -1,5 +1,7 @@
 #include <boost/filesystem.hpp>
+#include <boost/lexical_cast.hpp>
 #include "RsrcContainer.h"
+#include "Exception.h"
 
 
 //======================================================================================================================
@@ -8,7 +10,7 @@
 template<typename Type>
 RsrcContainer<Type>::~RsrcContainer()
 {
-	DEBUG_ERR(BaseClass::size() != 0); // this means that somehow a resource is still loaded
+	RASSERT_THROW_EXCEPTION(BaseClass::size() != 0); // this means that somehow a resource is still loaded
 }
 
 
@@ -72,10 +74,10 @@ typename RsrcContainer<Type>::Iterator RsrcContainer<Type>::findByPtr(Type* ptr)
 template<typename Type>
 Type* RsrcContainer<Type>::load(const char* fname)
 {
-	DEBUG_ERR(fname == NULL);
-	filesystem::path fpathname = filesystem::path(fname);
-	string name = fpathname.filename();
-	string path = fpathname.parent_path().string();
+	RASSERT_THROW_EXCEPTION(fname == NULL);
+	boost::filesystem::path fpathname = boost::filesystem::path(fname);
+	std::string name = fpathname.filename();
+	std::string path = fpathname.parent_path().string();
 	Iterator it = findByNameAndPath(name.c_str(), path.c_str());
 
 	// if already loaded then inc the users and return the pointer
@@ -95,11 +97,11 @@ Type* RsrcContainer<Type>::load(const char* fname)
 	{
 		newInstance->load(fname);
 	}
-	catch(exception& e)
+	catch(Exception& e)
 	{
 		delete newInstance;
 		return NULL;
-		THROW_EXCEPTION("Cannot load \"" << fname << '\"');
+		throw EXCEPTION("Cannot load \"" + fname + '\"');
 	}
 
 	BaseClass::push_back(newInstance);
@@ -116,12 +118,11 @@ void RsrcContainer<Type>::unload(Type* x)
 	Iterator it = findByPtr(x);
 	if(it == BaseClass::end())
 	{
-		ERROR("Cannot find resource with pointer 0x" << hex << x);
-		return;
+		throw EXCEPTION("Cannot find resource with pointer " + boost::lexical_cast<std::string>(x));
 	}
 
 	Type* del_ = (*it);
-	DEBUG_ERR(del_->referenceCounter < 1); // WTF?
+	RASSERT_THROW_EXCEPTION(del_->referenceCounter < 1); // WTF?
 
 	--del_->referenceCounter;
 

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

@@ -1,7 +1,11 @@
 #ifndef RSRC_PTR_H
 #define RSRC_PTR_H
 
-#include "Common.h"
+#include "Exception.h"
+
+#ifndef NULL
+	#define NULL 0
+#endif
 
 
 /// This is a special smart pointer that points to Resource derivatives. It looks like auto_ptr but the main difference
@@ -43,7 +47,7 @@ class RsrcPtr
 template<typename Type>
 Type& RsrcPtr<Type>::operator*() const
 {
-	DEBUG_ERR(p == NULL);
+	RASSERT_THROW_EXCEPTION(p == NULL);
 	return *p;
 }
 
@@ -51,7 +55,7 @@ Type& RsrcPtr<Type>::operator*() const
 template<typename Type>
 Type* RsrcPtr<Type>::operator->() const
 {
-	DEBUG_ERR(p == NULL);
+	RASSERT_THROW_EXCEPTION(p == NULL);
 	return p;
 }
 

+ 3 - 3
src/Resources/Extension.cpp

@@ -11,14 +11,14 @@ void Extension::load(const char* filename)
 	libHandle = dlopen(filename, RTLD_LAZY);
 	if(libHandle == NULL)
 	{
-		THROW_EXCEPTION("File \"" + filename + "\": " + dlerror());
+		throw EXCEPTION("File \"" + filename + "\": " + dlerror());
 	}
 	
 	// get FooBar
 	foobarPtr = (int(*)(void*))(dlsym(libHandle, "FooBar"));
 	if(foobarPtr == NULL)
 	{
-		THROW_EXCEPTION("File \"" + filename + "\": \"FooBar\" entry symbol not found: " + dlerror());
+		throw EXCEPTION("File \"" + filename + "\": \"FooBar\" entry symbol not found: " + dlerror());
 	}
 }
 
@@ -28,7 +28,7 @@ void Extension::load(const char* filename)
 //======================================================================================================================
 Extension::~Extension()
 {
-	DEBUG_ERR(libHandle==NULL || foobarPtr==NULL);
+	//DEBUG_ERR(libHandle==NULL || foobarPtr==NULL);
 	dlclose(libHandle);
 	libHandle = NULL;
 	foobarPtr = NULL;

+ 0 - 1
src/Resources/Extension.h

@@ -1,7 +1,6 @@
 #ifndef EXTENSION_H
 #define EXTENSION_H
 
-#include "Common.h"
 #include "Resource.h"
 
 

+ 9 - 13
src/Resources/Helpers/Image.cpp

@@ -6,10 +6,6 @@
 #include "Exception.h"
 
 
-using namespace std;
-using namespace boost;
-
-
 uchar Image::tgaHeaderUncompressed[12] = {0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0};
 uchar Image::tgaHeaderCompressed[12]   = {0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0};
 
@@ -17,7 +13,7 @@ uchar Image::tgaHeaderCompressed[12]   = {0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0};
 //======================================================================================================================
 // loadUncompressedTga                                                                                                 =
 //======================================================================================================================
-void Image::loadUncompressedTga(fstream& fs, uint& bpp)
+void Image::loadUncompressedTga(std::fstream& fs, uint& bpp)
 {
 	// read the info from header
 	uchar header6[6];
@@ -60,7 +56,7 @@ void Image::loadUncompressedTga(fstream& fs, uint& bpp)
 //======================================================================================================================
 // loadCompressedTga                                                                                                   =
 //======================================================================================================================
-void Image::loadCompressedTga(fstream& fs, uint& bpp)
+void Image::loadCompressedTga(std::fstream& fs, uint& bpp)
 {
 	unsigned char header6[6];
 	fs.read((char*)&header6[0], sizeof(header6));
@@ -165,9 +161,9 @@ void Image::loadCompressedTga(fstream& fs, uint& bpp)
 //======================================================================================================================
 void Image::loadTga(const char* filename)
 {
-	fstream fs;
+	std::fstream fs;
 	char myTgaHeader[12];
-	fs.open(filename, ios::in|ios::binary);
+	fs.open(filename, std::ios::in | std::ios::binary);
 	uint bpp;
 
 	if(!fs.good())
@@ -215,7 +211,7 @@ void Image::loadTga(const char* filename)
 //======================================================================================================================
 // loadPng                                                                                                             =
 //======================================================================================================================
-bool Image::loadPng(const char* filename, string& err) throw()
+bool Image::loadPng(const char* filename, std::string& err) throw()
 {
 	//
 	// All locals
@@ -230,7 +226,7 @@ bool Image::loadPng(const char* filename, string& err) throw()
 	uint channels;
 	uint rowbytes;
 	uint colorType;
-	vector<png_bytep> rowPointers;
+	Vec<png_bytep> rowPointers;
 
 	//
 	// Open file
@@ -423,8 +419,8 @@ bool Image::loadPng(const char* filename, string& err) throw()
 void Image::load(const char* filename)
 {
 	// get the extension
-	string ext = filesystem::path(filename).extension();
-	to_lower(ext);
+	std::string ext = boost::filesystem::path(filename).extension();
+	boost::to_lower(ext);
 
 
 	// load from this extension
@@ -436,7 +432,7 @@ void Image::load(const char* filename)
 		}
 		else if(ext == ".png")
 		{
-			string err;
+			std::string err;
 			if(!loadPng(filename, err))
 			{
 				throw EXCEPTION(err);

+ 1 - 1
src/Resources/Helpers/Image.h

@@ -16,7 +16,7 @@ class Image
 		{
 			CT_R, ///< Red only
 			CT_RGB, ///< RGB
-			CT_RGBA /// RGB and alpha
+			CT_RGBA /// RGB plus alpha
 		};
 
 	PROPERTY_R(uint, width, getWidth) ///< Image width

+ 30 - 33
src/Resources/Helpers/ShaderPrePreprocessor.cpp

@@ -8,10 +8,6 @@
 #include "Exception.h"
 
 
-using namespace std;
-using namespace boost;
-
-
 const char* MULTIPLE_DEF_MSG = " already defined in the same place. Check for circular or multiple includance";
 
 
@@ -22,7 +18,7 @@ void ShaderPrePreprocessor::printSourceLines() const
 {
 	for(uint i=0; i<sourceLines.size(); ++i)
 	{
-		cout << setw(3) << i+1 << ": " << sourceLines[i] << endl;
+		std::cout << std::setw(3) << i+1 << ": " << sourceLines[i] << std::endl;
 	}
 }
 
@@ -32,11 +28,11 @@ void ShaderPrePreprocessor::printSourceLines() const
 //======================================================================================================================
 void ShaderPrePreprocessor::printShaderVars() const
 {
-	cout << "TYPE" << setw(20) << "NAME" << setw(4) << "LOC" << endl;
+	std::cout << "TYPE" << std::setw(20) << "NAME" << std::setw(4) << "LOC" << std::endl;
 	for(uint i=0; i<output.attributes.size(); ++i)
 	{
-		cout << setw(4) << "A" << setw(20) << output.attributes[i].name << setw(4) << output.attributes[i].customLoc <<
-		     endl;
+		std::cout << std::setw(4) << "A" << std::setw(20) << output.attributes[i].name << std::setw(4) <<
+		             output.attributes[i].customLoc << std::endl;
 	}
 }
 
@@ -44,8 +40,8 @@ void ShaderPrePreprocessor::printShaderVars() const
 //======================================================================================================================
 // findShaderVar                                                                                                       =
 //======================================================================================================================
-Vec<ShaderPrePreprocessor::ShaderVarPragma>::iterator ShaderPrePreprocessor::findShaderVar(Vec<ShaderVarPragma>& vec,
-                                                                                           const string& name) const
+Vec<ShaderPrePreprocessor::ShaderVarPragma>::iterator ShaderPrePreprocessor::findShaderVar(
+	Vec<ShaderVarPragma>& vec, const std::string& name) const
 {
 	Vec<ShaderVarPragma>::iterator it = vec.begin();
 	while(it != vec.end() && it->name != name)
@@ -59,7 +55,7 @@ Vec<ShaderPrePreprocessor::ShaderVarPragma>::iterator ShaderPrePreprocessor::fin
 //======================================================================================================================
 // parseFileForPragmas                                                                                                 =
 //======================================================================================================================
-void ShaderPrePreprocessor::parseFileForPragmas(const string& filename, int depth)
+void ShaderPrePreprocessor::parseFileForPragmas(const std::string& filename, int depth)
 {
 	// first check the depth
 	if(depth > 99)
@@ -68,7 +64,7 @@ void ShaderPrePreprocessor::parseFileForPragmas(const string& filename, int dept
 	}
 
 	// load file in lines
-	Vec<string> lines = Util::getFileLines(filename.c_str());
+	Vec<std::string> lines = Util::getFileLines(filename.c_str());
 	if(lines.size() < 1)
 	{
 		throw EXCEPTION("File \"" + filename + "\": Cannot open or empty");
@@ -108,7 +104,7 @@ void ShaderPrePreprocessor::parseFileForPragmas(const string& filename, int dept
 						if(vertShaderBegins.definedInLine != -1)
 						{
 							throw PARSER_EXCEPTION("vertShaderBegins already defined at " + vertShaderBegins.definedInFile + ":" +
-																		 lexical_cast<string>(vertShaderBegins.definedInLine));
+																		 boost::lexical_cast<std::string>(vertShaderBegins.definedInLine));
 						}
 
 						// vert shader should be before frag
@@ -116,7 +112,7 @@ void ShaderPrePreprocessor::parseFileForPragmas(const string& filename, int dept
 						{
 							throw PARSER_EXCEPTION("vertShaderBegins must precede fragShaderBegins defined at " +
 																		 fragShaderBegins.definedInFile + ":" +
-																		 lexical_cast<string>(fragShaderBegins.definedInLine));
+																		 boost::lexical_cast<std::string>(fragShaderBegins.definedInLine));
 						}
 
 						// vert shader should be before geom
@@ -124,14 +120,14 @@ void ShaderPrePreprocessor::parseFileForPragmas(const string& filename, int dept
 						{
 							throw PARSER_EXCEPTION("vertShaderBegins must precede geomShaderBegins defined at " +
 																		 geomShaderBegins.definedInFile + ":" +
-																		 lexical_cast<string>(geomShaderBegins.definedInLine));
+																		 boost::lexical_cast<std::string>(geomShaderBegins.definedInLine));
 						}
 
 						vertShaderBegins.definedInFile = filename;
 						vertShaderBegins.definedInLine = scanner.getLineNumber();
 						vertShaderBegins.globalLine = sourceLines.size() + 1;
-						sourceLines.push_back("#line " + lexical_cast<string>(scanner.getLineNumber()) + ' ' +
-																	lexical_cast<string>(depth) + " // " + lines[scanner.getLineNumber()-1]);
+						sourceLines.push_back("#line " + boost::lexical_cast<std::string>(scanner.getLineNumber()) + ' ' +
+																	boost::lexical_cast<std::string>(depth) + " // " + lines[scanner.getLineNumber()-1]);
 						// stop play
 					}
 					//
@@ -152,7 +148,7 @@ void ShaderPrePreprocessor::parseFileForPragmas(const string& filename, int dept
 						if(geomShaderBegins.definedInLine != -1)
 						{
 							throw PARSER_EXCEPTION("geomShaderBegins already defined at " + geomShaderBegins.definedInFile + ":" +
-																		 lexical_cast<string>(geomShaderBegins.definedInLine));
+																		 boost::lexical_cast<std::string>(geomShaderBegins.definedInLine));
 						}
 
 						// vert shader entry point not defined => error
@@ -166,14 +162,14 @@ void ShaderPrePreprocessor::parseFileForPragmas(const string& filename, int dept
 						{
 							throw PARSER_EXCEPTION("geomShaderBegins must precede fragShaderBegins defined at " +
 																		 fragShaderBegins.definedInFile + ":" +
-																		 lexical_cast<string>(fragShaderBegins.definedInLine));
+																		 boost::lexical_cast<std::string>(fragShaderBegins.definedInLine));
 						}
 
 						geomShaderBegins.definedInFile = filename;
 						geomShaderBegins.definedInLine = scanner.getLineNumber();
 						geomShaderBegins.globalLine = sourceLines.size() + 1;
-						sourceLines.push_back("#line " + lexical_cast<string>(scanner.getLineNumber()) + ' ' +
-																	lexical_cast<string>(depth) + " // " + lines[scanner.getLineNumber()-1]);
+						sourceLines.push_back("#line " + boost::lexical_cast<std::string>(scanner.getLineNumber()) + ' ' +
+																	boost::lexical_cast<std::string>(depth) + " // " + lines[scanner.getLineNumber()-1]);
 						// stop play
 					}
 					//
@@ -193,7 +189,7 @@ void ShaderPrePreprocessor::parseFileForPragmas(const string& filename, int dept
 						if(fragShaderBegins.definedInLine != -1) // if already defined elsewhere throw error
 						{
 							throw PARSER_EXCEPTION("fragShaderBegins already defined at " + fragShaderBegins.definedInFile + ":" +
-																		 lexical_cast<string>(fragShaderBegins.definedInLine));
+																		 boost::lexical_cast<std::string>(fragShaderBegins.definedInLine));
 						}
 
 						// vert shader entry point not defined
@@ -205,8 +201,8 @@ void ShaderPrePreprocessor::parseFileForPragmas(const string& filename, int dept
 						fragShaderBegins.definedInFile = filename;
 						fragShaderBegins.definedInLine = scanner.getLineNumber();
 						fragShaderBegins.globalLine = sourceLines.size() + 1;
-						sourceLines.push_back("#line " + lexical_cast<string>(scanner.getLineNumber()) + ' ' +
-																	lexical_cast<string>(depth) + " // " + lines[scanner.getLineNumber()-1]);
+						sourceLines.push_back("#line " + boost::lexical_cast<std::string>(scanner.getLineNumber()) + ' ' +
+																	boost::lexical_cast<std::string>(depth) + " // " + lines[scanner.getLineNumber()-1]);
 						// stop play
 					}
 					//
@@ -219,11 +215,11 @@ void ShaderPrePreprocessor::parseFileForPragmas(const string& filename, int dept
 						{
 							// play
 							//int line = sourceLines.size();
-							sourceLines.push_back("#line 0 " + lexical_cast<string>(depth+1) + " // " +
+							sourceLines.push_back("#line 0 " + boost::lexical_cast<std::string>(depth+1) + " // " +
 																		lines[scanner.getLineNumber()-1]);
 							parseFileForPragmas(token->getValue().getString(), depth+1);
-							sourceLines.push_back("#line " + lexical_cast<string>(scanner.getLineNumber()) + ' ' +
-																		lexical_cast<string>(depth) +  " // end of " + lines[scanner.getLineNumber()-1]);
+							sourceLines.push_back("#line " + boost::lexical_cast<std::string>(scanner.getLineNumber()) + ' ' +
+																		boost::lexical_cast<std::string>(depth) +  " // end of " + lines[scanner.getLineNumber()-1]);
 							// stop play
 						}
 						else
@@ -240,7 +236,7 @@ void ShaderPrePreprocessor::parseFileForPragmas(const string& filename, int dept
 						token = &scanner.getNextToken();
 						if(token->getCode() == Scanner::TC_IDENTIFIER)
 						{
-							string varName = token->getValue().getString();
+							std::string varName = token->getValue().getString();
 							// check if already defined and for circular includance
 							Vec<TrffbVaryingPragma>::const_iterator var = findNamed(output.trffbVaryings, varName);
 							if(var != output.trffbVaryings.end())
@@ -252,7 +248,7 @@ void ShaderPrePreprocessor::parseFileForPragmas(const string& filename, int dept
 								else
 								{
 									throw PARSER_EXCEPTION("Varying \"" + varName + "\" already defined at " + var->definedInFile +
-																				 ":" + lexical_cast<string>(var->definedInLine));
+																				 ":" + boost::lexical_cast<std::string>(var->definedInLine));
 								}
 							}
 
@@ -273,7 +269,7 @@ void ShaderPrePreprocessor::parseFileForPragmas(const string& filename, int dept
 						token = &scanner.getNextToken();
 						if(token->getCode() == Scanner::TC_IDENTIFIER)
 						{
-							string varName = token->getValue().getString();
+							std::string varName = token->getValue().getString();
 							token = &scanner.getNextToken();
 							if(token->getCode() == Scanner::TC_NUMBER && token->getDataType() == Scanner::DT_INT)
 							{
@@ -290,7 +286,8 @@ void ShaderPrePreprocessor::parseFileForPragmas(const string& filename, int dept
 									else
 									{
 										throw PARSER_EXCEPTION("Attribute \"" + varName + "\" already defined at " +
-																					 attrib->definedInFile + ":" + lexical_cast<string>(attrib->definedInLine));
+																					 attrib->definedInFile + ":" +
+																					 boost::lexical_cast<std::string>(attrib->definedInLine));
 									}
 								}
 								// search if another var has the same loc
@@ -299,8 +296,8 @@ void ShaderPrePreprocessor::parseFileForPragmas(const string& filename, int dept
 									if(attrib->customLoc == loc)
 									{
 										throw PARSER_EXCEPTION("The attributes \"" + attrib->name + "\" (" + attrib->definedInFile + ":" +
-																					 lexical_cast<string>(attrib->definedInLine) + ") and \"" + varName +
-																					 "\" share the same location");
+																					 boost::lexical_cast<std::string>(attrib->definedInLine) + ") and \"" +
+																					 varName + "\" share the same location");
 									}
 								}
 

+ 18 - 14
src/Resources/Mesh.cpp

@@ -1,10 +1,11 @@
 #include <fstream>
+#include <boost/lexical_cast.hpp>
 #include "Mesh.h"
 #include "Material.h"
 #include "BinaryStream.h"
 
 
-#define MESH_THROW_EXCEPTION(x) THROW_EXCEPTION("File \"" + filename + "\": " + x)
+#define MESH_EXCEPTION(x) EXCEPTION("Mesh \"" + filename + "\": " + x)
 
 
 //======================================================================================================================
@@ -20,7 +21,7 @@ void Mesh::load(const char* filename)
 
 		if(!file.is_open())
 		{
-			THROW_EXCEPTION("Cannot open file \"" << filename << "\"");
+			throw EXCEPTION("Cannot open file \"" + filename + "\"");
 		}
 
 		BinaryStream bs(file.rdbuf());
@@ -30,8 +31,7 @@ void Mesh::load(const char* filename)
 		bs.read(magic, 8);
 		if(bs.fail() || memcmp(magic, "ANKIMESH", 8))
 		{
-			MESH_ERR("Incorrect magic word");
-			return false;
+			throw MESH_EXCEPTION("Incorrect magic word");
 		}
 
 		// Mesh name
@@ -71,7 +71,9 @@ void Mesh::load(const char* filename)
 				// a sanity check
 				if(tris[i].vertIds[j] >= vertCoords.size())
 				{
-					THROW_EXCEPTION("Vert index out of bounds" + tris[i].vertIds[j] + " (" + i + ", " + j + ")");
+					throw MESH_EXCEPTION("Vert index out of bounds" + boost::lexical_cast<std::string>(tris[i].vertIds[j]) +
+					                     " (" + boost::lexical_cast<std::string>(i) + ", " +
+					                     boost::lexical_cast<std::string>(j) + ")");
 				}
 			}
 		}
@@ -102,13 +104,15 @@ void Mesh::load(const char* filename)
 			// we treat as error if one vert doesnt have a bone
 			if(boneConnections < 1)
 			{
-				THROW_EXCEPTION("Vert " + i + " sould have at least one bone");
+				throw MESH_EXCEPTION("Vert " + boost::lexical_cast<std::string>(i) + " sould have at least one bone");
 			}
 
 			// and here is another possible error
 			if(boneConnections > VertexWeight::MAX_BONES_PER_VERT)
 			{
-				THROW_EXCEPTION("Cannot have more than " + VertexWeight::MAX_BONES_PER_VERT + " bones per vertex");
+				uint tmp = VertexWeight::MAX_BONES_PER_VERT;
+				throw MESH_EXCEPTION("Cannot have more than " +
+				                     boost::lexical_cast<std::string>(tmp) + " bones per vertex");
 			}
 			vertWeights[i].bonesNum = boneConnections;
 
@@ -130,7 +134,7 @@ void Mesh::load(const char* filename)
 	}
 	catch(Exception& e)
 	{
-		MESH_THROW_EXCEPTION(e.what());
+		throw MESH_EXCEPTION(e.what());
 	}
 }
 
@@ -143,15 +147,15 @@ void Mesh::doPostLoad()
 	// Sanity checks
 	if(vertCoords.size()<1 || tris.size()<1)
 	{
-		THROW_EXCEPTION("Vert coords and tris must be filled");
+		throw EXCEPTION("Vert coords and tris must be filled");
 	}
 	if(texCoords.size()!=0 && texCoords.size()!=vertCoords.size())
 	{
-		THROW_EXCEPTION("Tex coords num must be zero or equal to vertex coords num");
+		throw EXCEPTION("Tex coords num must be zero or equal to vertex coords num");
 	}
 	if(vertWeights.size()!=0 && vertWeights.size()!=vertCoords.size())
 	{
-		THROW_EXCEPTION("Vert weights num must be zero or equal to vertex coords num");
+		throw EXCEPTION("Vert weights num must be zero or equal to vertex coords num");
 	}
 
 	if(isRenderable())
@@ -168,14 +172,14 @@ void Mesh::doPostLoad()
 		// Sanity checks continued
 		if(material->stdAttribVars[Material::SAV_TEX_COORDS] != NULL && !vbos.texCoords.isCreated())
 		{
-			THROW_EXCEPTION("The shader program (\"" + material->shaderProg->getRsrcName() +
+			throw EXCEPTION("The shader program (\"" + material->shaderProg->getRsrcName() +
 						          "\") needs texture coord information that the mesh (\"" +
-						          getRsrcName() << "\") doesn't have");
+						          getRsrcName() + "\") doesn't have");
 		}
 
 		if(material->hasHWSkinning() && !vbos.vertWeights.isCreated())
 		{
-			THROW_EXCEPTION("The shader program (\"" + material->shaderProg->getRsrcName() +
+			throw EXCEPTION("The shader program (\"" + material->shaderProg->getRsrcName() +
 						          "\") needs vertex weights that the mesh (\"" +
 						          getRsrcName() + "\") doesn't have");
 		}

+ 3 - 3
src/Resources/Script.cpp

@@ -1,16 +1,16 @@
 #include "Script.h"
 #include "Util.h"
+#include "Exception.h"
 
 
 //======================================================================================================================
 // load                                                                                                                =
 //======================================================================================================================
-bool Script::load(const char* filename)
+void Script::load(const char* filename)
 {
 	source = Util::readFile(filename);
 	if(source.length() < 1)
 	{
-		THROW_EXCEPTION("Cannot load script \"" << filename << "\"");
+		throw EXCEPTION("Cannot load script \"" + filename + "\"");
 	}
-	return true;
 }

+ 2 - 2
src/Resources/Script.h

@@ -1,7 +1,7 @@
 #ifndef SCRIPT_H
 #define SCRIPT_H
 
-#include "Common.h"
+#include <string>
 #include "Resource.h"
 
 
@@ -14,7 +14,7 @@ class Script: public Resource
 		void load(const char* filename);
 
 	private:
-		string source;
+		std::string source;
 };
 
 

+ 1 - 5
src/Resources/SkelAnim.h

@@ -70,7 +70,7 @@ class SkelAnim: public Resource
 		uint framesNum;
 		Vec<BoneAnim> bones;
 
-		SkelAnim();
+		SkelAnim(): Resource(RT_SKEL_ANIM) {}
 		~SkelAnim() {}
 
 		/// Implements Resource::loat
@@ -78,8 +78,4 @@ class SkelAnim: public Resource
 };
 
 
-inline SkelAnim::SkelAnim():
-	Resource(RT_SKEL_ANIM)
-{}
-
 #endif

+ 5 - 5
src/Resources/Skeleton.h

@@ -38,18 +38,18 @@ class Skeleton: public Resource
 		/// rotSkelSpaceInv = rotSkelSpace.getInverted()
 		class Bone
 		{
-			PROPERTY_R(string, name, getName) ///< @ref PROPERTY_R : The name of the bone
+			friend class Skeleton; /// For loading
 
-			friend class Skeleton;
+			PROPERTY_R(std::string, name, getName) ///< The name of the bone
+			PROPERTY_R(Vec3, head, getHead) ///< Starting point of the bone
+			PROPERTY_R(Vec3, tail, getTail) ///< End point of the bone
+			PROPERTY_R(uint, id, getPos) ///< Pos inside the @ref Skeleton::bones vector
 
 			public:
 				static const uint MAX_CHILDS_PER_BONE = 4; ///< Please dont change this
-				ushort id; ///< Pos inside the @ref Skeleton::bones vector
 				Bone*  parent;
 				Bone*  childs[MAX_CHILDS_PER_BONE];
 				ushort childsNum;
-				Vec3   head;
-				Vec3   tail;
 
 				// see the class notes
 				Mat3 rotSkelSpace;

+ 17 - 15
src/Resources/Texture.cpp

@@ -2,6 +2,7 @@
 #include "Texture.h"
 #include "Renderer.h"
 #include "Image.h"
+#include "GlException.h"
 
 
 #define LAST_TEX_UNIT (textureUnitsNum - 1)
@@ -32,7 +33,9 @@ Texture::Texture():
 Texture::~Texture()
 {
 	if(isLoaded())
+	{
 		glDeleteTextures(1, &glId);
+	}
 }
 
 
@@ -46,7 +49,7 @@ void Texture::load(const char* filename)
 		target = GL_TEXTURE_2D;
 		if(isLoaded())
 		{
-			THROW_ERROR("Texture already loaded");
+			throw EXCEPTION("Texture already loaded");
 		}
 
 		Image img(filename);
@@ -95,7 +98,7 @@ void Texture::load(const char* filename)
 				break;
 
 			default:
-				THROW_ERROR("See file");
+				throw EXCEPTION("See file");
 		}
 
 		glTexImage2D(target, 0, internalFormat, img.getWidth(), img.getHeight(), 0, format, type, &img.getData()[0]);
@@ -104,14 +107,11 @@ void Texture::load(const char* filename)
 			glGenerateMipmap(target);
 		}
 
-		if(!GL_OK())
-		{
-			THROW_EXCEPTION("OpenGL failed");
-		}
+		ON_GL_FAIL_THROW_EXCEPTION();
 	}
 	catch(exception& e)
 	{
-		THROW_EXCEPTION("File \"" + filename + "\": " + e.what());
+		throw EXCEPTION("File \"" + filename + "\": " + e.what());
 	}
 }
 
@@ -119,11 +119,11 @@ void Texture::load(const char* filename)
 //======================================================================================================================
 // createEmpty2D                                                                                                       =
 //======================================================================================================================
-bool Texture::createEmpty2D(float width_, float height_, int internalFormat, int format_, uint type_)
+void Texture::createEmpty2D(float width_, float height_, int internalFormat, int format_, uint type_)
 {
 	target = GL_TEXTURE_2D;
-	DEBUG_ERR(internalFormat > 0 && internalFormat <= 4); // deprecated internal format
-	DEBUG_ERR(isLoaded());
+	RASSERT_THROW_EXCEPTION(internalFormat > 0 && internalFormat <= 4); // deprecated internal format
+	RASSERT_THROW_EXCEPTION(isLoaded());
 
 	// GL stuff
 	glGenTextures(1, &glId);
@@ -136,14 +136,14 @@ bool Texture::createEmpty2D(float width_, float height_, int internalFormat, int
 	// allocate to vram
 	glTexImage2D(target, 0, internalFormat, width_, height_, 0, format_, type_, NULL);
 
-	return GL_OK();
+	ON_GL_FAIL_THROW_EXCEPTION();
 }
 
 
 //======================================================================================================================
 // createEmpty2DMSAA                                                                                                   =
 //======================================================================================================================
-bool Texture::createEmpty2DMsaa(int samplesNum, int internalFormat, int width_, int height_, bool mimapping)
+void Texture::createEmpty2DMsaa(int samplesNum, int internalFormat, int width_, int height_, bool mimapping)
 {
 	target = GL_TEXTURE_2D_MULTISAMPLE;
 	DEBUG_ERR(isLoaded());
@@ -155,9 +155,9 @@ bool Texture::createEmpty2DMsaa(int samplesNum, int internalFormat, int width_,
 	glTexImage2DMultisample(target, samplesNum, internalFormat, width_, height_, false);
 
 	if(mimapping)
+	{
 		glGenerateMipmap(target);
-
-	return GL_OK();
+	}
 }
 
 
@@ -167,7 +167,9 @@ bool Texture::createEmpty2DMsaa(int samplesNum, int internalFormat, int width_,
 void Texture::bind(uint unit) const
 {
 	if(unit >= static_cast<uint>(textureUnitsNum))
-		WARNING("Max tex units passed");
+	{
+		throw EXCEPTION("Max tex units passed");
+	}
 
 	glActiveTexture(GL_TEXTURE0 + unit);
 	glBindTexture(target, getGlId());

+ 6 - 5
src/Resources/Texture.h

@@ -2,8 +2,8 @@
 #define TEXTURE_H
 
 #include <limits>
-#include "Common.h"
 #include "Resource.h"
+#include "StdTypes.h"
 
 
 /// Texture resource class
@@ -33,7 +33,7 @@ class Texture: public Resource
 		/// @name Create tex funcs
 		/// @{
 
-		/// Load image
+		/// Implements Resource::load
 		/// @exception Exception
 		void load(const char* filename);
 
@@ -43,14 +43,12 @@ class Texture: public Resource
 
 		/// Create empty texture with MSAA.
 		/// Used by the Renderer
-		bool createEmpty2DMsaa(int samplesNum, int internalFormat, int width_, int height_, bool mimapping);
+		void createEmpty2DMsaa(int samplesNum, int internalFormat, int width_, int height_, bool mimapping);
 		/// @}
 
 		void bind(uint texUnit = 0) const;
 		void setRepeat(bool repeat) const;
 		void setFiltering(TextureFilteringType filterType);
-		void setTexParameter(uint paramName, int value) const;
-		void setTexParameter(uint paramName, float value) const;
 		void setAnisotropy(uint level);
 		void setMipmapLevel(uint level);
 		void genMipmap();
@@ -74,6 +72,9 @@ class Texture: public Resource
 		static int  anisotropyLevel;
 		/// @}
 
+				void setTexParameter(uint paramName, int value) const;
+		void setTexParameter(uint paramName, float value) const;
+
 		bool isLoaded() const;
 };
 

+ 10 - 4
src/Scene/Controllers/SkelAnimCtrl.cpp

@@ -96,8 +96,12 @@ void SkelAnimCtrl::updateBoneTransforms()
 
 	// put the roots
 	for(uint i=0; i<skelNode.skeleton->bones.size(); i++)
+	{
 		if(skelNode.skeleton->bones[i].parent == NULL)
+		{
 			queue[tail++] = i; // queue push
+		}
+	}
 
 	// loop
 	while(head != tail) // while queue not empty
@@ -119,14 +123,16 @@ void SkelAnimCtrl::updateBoneTransforms()
 		if(boned.parent)
 		{
 			// bone.final_final_transform = parent.transf * bone.final_transform
-			combineTransformations(boneTranslations[boned.parent->id], boneRotations[boned.parent->id],
+			combineTransformations(boneTranslations[boned.parent->getPos()], boneRotations[boned.parent->getPos()],
 		                         boneTranslations[boneId], boneRotations[boneId],
 		                         boneTranslations[boneId], boneRotations[boneId]);
 		}
 
 		// now add the bone's childes
 		for(uint i=0; i<boned.childsNum; i++)
-			queue[tail++] = boned.childs[i]->id;
+		{
+			queue[tail++] = boned.childs[i]->getPos();
+		}
 	}
 }
 
@@ -143,8 +149,8 @@ void SkelAnimCtrl::deform()
 		const Mat3& rot = skelNode.boneRotations[i];
 		const Vec3& transl = skelNode.boneTranslations[i];
 
-		skelNode.heads[i] = skeleton.bones[i].head.getTransformed(transl, rot);
-		skelNode.tails[i] = skeleton.bones[i].tail.getTransformed(transl, rot);
+		skelNode.heads[i] = skeleton.bones[i].getHead().getTransformed(transl, rot);
+		skelNode.tails[i] = skeleton.bones[i].getTail().getTransformed(transl, rot);
 	}
 }
 

+ 5 - 5
src/Scene/SkelModelNode.cpp

@@ -17,14 +17,14 @@ void SkelModelNode::init(const char* filename)
 		token = &scanner.getNextToken();
 		if(!(token->getCode() == Scanner::TC_IDENTIFIER && !strcmp(token->getValue().getString(), "SKELETON")))
 		{
-			PARSE_ERR_EXPECTED("identifier SKELETON");
+			throw PARSER_EXCEPTION_EXPECTED("identifier SKELETON");
 			return;
 		}
 		
 		token = &scanner.getNextToken();
 		if(token->getCode() != Scanner::TC_STRING)
 		{
-			PARSE_ERR_EXPECTED("string");
+			throw PARSER_EXCEPTION_EXPECTED("string");
 			return;
 		}
 
@@ -36,14 +36,14 @@ void SkelModelNode::init(const char* filename)
 		token = &scanner.getNextToken();
 		if(!(token->getCode() == Scanner::TC_IDENTIFIER && !strcmp(token->getValue().getString(), "MESHES_NUM")))
 		{
-			PARSE_ERR_EXPECTED("identifier MESHES_NUM");
+			throw PARSER_EXCEPTION_EXPECTED("identifier MESHES_NUM");
 			return;
 		}
 
 		token = &scanner.getNextToken();
 		if(token->getCode() != Scanner::TC_NUMBER || token->getDataType() != Scanner::DT_INT)
 		{
-			PARSE_ERR_EXPECTED("integer");
+			throw PARSER_EXCEPTION_EXPECTED("integer");
 			return;
 		}
 				
@@ -54,7 +54,7 @@ void SkelModelNode::init(const char* filename)
 			token = &scanner.getNextToken();
 			if(token->getCode() != Scanner::TC_STRING)
 			{
-				PARSE_ERR_EXPECTED("string");
+				throw PARSER_EXCEPTION_EXPECTED("string");
 				return;
 			}
 

+ 1 - 1
src/Ui/Ui.cpp

@@ -162,7 +162,7 @@ non static funcs
 void init()
 {
 	fontMap.loadRsrc("gfx/fontmapa.tga");
-	fontMap->setTexParameter(GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+	fontMap->setFiltering(Texture::TFT_LINEAR);
 	//font_map->setTexParameter(GL_TEXTURE_MAG_FILTER, GL_NEAREST);
 	shader.loadRsrc("shaders/txt.glsl");
 	setPos(0.0, 0.0);