Просмотр исходного кода

At last, after more that 6 months, making anki to compile

Panagiotis Christopoulos Charitos 13 лет назад
Родитель
Сommit
9950e27d01
86 измененных файлов с 1089 добавлено и 1604 удалено
  1. 6 9
      CMakeLists.txt
  2. 1 0
      include/anki/core/Logger.h
  3. 1 1
      include/anki/gl/BufferObject.h
  4. 1 1
      include/anki/gl/Fbo.h
  5. 12 2
      include/anki/gl/Gl.h
  6. 1 1
      include/anki/gl/GlState.h
  7. 9 0
      include/anki/gl/Ogl.h
  8. 6 10
      include/anki/gl/Query.h
  9. 1 1
      include/anki/gl/ShaderProgram.h
  10. 12 12
      include/anki/gl/Texture.h
  11. 1 1
      include/anki/gl/Vao.h
  12. 3 7
      include/anki/input/Input.h
  13. 1 0
      include/anki/renderer/Bl.h
  14. 88 89
      include/anki/renderer/Hdr.h
  15. 2 6
      include/anki/renderer/Is.h
  16. 84 89
      include/anki/renderer/MainRenderer.h
  17. 41 41
      include/anki/renderer/Ms.h
  18. 62 66
      include/anki/renderer/Pps.h
  19. 91 22
      include/anki/renderer/Renderer.h
  20. 0 91
      include/anki/renderer/RendererInitializer.h
  21. 2 8
      include/anki/renderer/RenderingPass.h
  22. 78 81
      include/anki/renderer/Sm.h
  23. 0 5
      include/anki/renderer/Smo.h
  24. 44 48
      include/anki/renderer/Ssao.h
  25. 1 1
      include/anki/resource/Material.h
  26. 3 0
      include/anki/resource/ShaderProgramResource.h
  27. 3 3
      include/anki/scene/Light.h
  28. 15 3
      include/anki/scene/Scene.h
  29. 0 6
      include/anki/scene/VisibilityTester.h
  30. 4 12
      include/anki/script/Common.h
  31. 27 0
      include/anki/script/MathCommon.h
  32. 75 99
      include/anki/ui/UiFont.h
  33. 4 9
      include/anki/ui/UiFtFontLoader.h
  34. 5 14
      include/anki/ui/UiPainter.h
  35. 3 8
      include/anki/ui/UiPainterDevice.h
  36. 9 18
      shaders/GaussianBlurGeneric.glsl
  37. 0 1
      src/event/MainRendererPpsHdrEvent.cpp
  38. 1 3
      src/event/SceneColorEvent.cpp
  39. 2 2
      src/gl/Query.cpp
  40. 1 1
      src/gl/ShaderProgram.cpp
  41. 38 44
      src/input/Input.cpp
  42. 1 2
      src/renderer/Bl.cpp
  43. 1 2
      src/renderer/Dbg.cpp
  44. 1 3
      src/renderer/Ez.cpp
  45. 33 84
      src/renderer/Hdr.cpp
  46. 2 7
      src/renderer/Is.cpp
  47. 29 70
      src/renderer/MainRenderer.cpp
  48. 22 71
      src/renderer/Ms.cpp
  49. 32 69
      src/renderer/Pps.cpp
  50. 27 32
      src/renderer/Renderer.cpp
  51. 26 63
      src/renderer/Sm.cpp
  52. 0 5
      src/renderer/Smo.cpp
  53. 42 90
      src/renderer/Ssao.cpp
  54. 15 6
      src/resource/ShaderProgramResource.cpp
  55. 0 8
      src/scene/Scene.cpp
  56. 26 33
      src/script/ScriptManager.cpp
  57. 1 2
      src/script/core/App.cpp
  58. 5 6
      src/script/core/Logger.cpp
  59. 1 2
      src/script/event/EventManager.cpp
  60. 1 2
      src/script/event/MainRendererPpsHdrEvent.cpp
  61. 1 2
      src/script/event/SceneColorEvent.cpp
  62. 1 2
      src/script/input/Input.cpp
  63. 4 5
      src/script/math/Vec2.cpp
  64. 5 6
      src/script/math/Vec3.cpp
  65. 6 7
      src/script/math/Vec4.cpp
  66. 1 2
      src/script/renderer/Bl.cpp
  67. 1 2
      src/script/renderer/Dbg.cpp
  68. 1 2
      src/script/renderer/Hdr.cpp
  69. 2 2
      src/script/renderer/MainRenderer.cpp
  70. 1 2
      src/script/renderer/Pps.cpp
  71. 1 2
      src/script/renderer/Renderer.cpp
  72. 1 2
      src/script/renderer/RenderingPass.cpp
  73. 1 2
      src/script/scene/Camera.cpp
  74. 0 31
      src/script/scene/MaterialRuntime.cpp
  75. 0 11
      src/script/scene/ModelNode.cpp
  76. 0 10
      src/script/scene/ModelPatchNode.cpp
  77. 0 12
      src/script/scene/PatchNode.cpp
  78. 3 4
      src/script/scene/Scene.cpp
  79. 3 4
      src/script/scene/SceneNode.cpp
  80. 1 2
      src/script/util/HighRezTimer.cpp
  81. 9 20
      src/ui/UiFont.cpp
  82. 21 45
      src/ui/UiFtFontLoader.cpp
  83. 12 25
      src/ui/UiPainter.cpp
  84. 6 23
      src/ui/UiPainterDevice.cpp
  85. 4 4
      src/util/Filesystem.cpp
  86. 1 3
      testapp/Main.cpp

+ 6 - 9
CMakeLists.txt

@@ -118,21 +118,18 @@ SET(BULLET_LIBRARY_DIR "${ANKI_PROJ_SOURCE_DIR}/extern/lib${ARCH}" CACHE PATH
 ANKI_ADD_LIB(${BULLET_INCLUDE_DIR}/bullet ${BULLET_LIBRARY_DIR} 
 	${BULLET_INCLUDE_DIR}/bullet/btBulletCollisionCommon.h)
 
+# Extern dir
 #
-# GLEW
-#
-SET(GLEW_INCLUDE_DIR "${ANKI_PROJ_SOURCE_DIR}/extern/include" CACHE PATH 
-	"The directory that contains the GL directory with the header files")
-SET(GLEW_LIBRARY_DIR "${ANKI_PROJ_SOURCE_DIR}/extern/lib${ARCH}" CACHE PATH 
-	"The directory that contains the GLEW (static) libraries")
+ADD_SUBDIRECTORY(extern)
 
-ANKI_ADD_LIB(${GLEW_INCLUDE_DIR} ${GLEW_LIBRARY_DIR} 
-	${GLEW_INCLUDE_DIR}/GL/glew.h)
+INCLUDE_DIRECTORIES(extern/GLEW/include)
+INCLUDE_DIRECTORIES(extern/include)
+LINK_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/extern/lib64")
 
 #
 # Defines & flags
 #
-ADD_DEFINITIONS(-DANKI_MATH_INTEL_SIMD -DGLEW_MX 
+ADD_DEFINITIONS(-DANKI_MATH_INTEL_SIMD
 	-Dthread_local=__thread -pedantic-errors -pedantic -ansi -Wall -Winline 
 	-W -Wwrite-strings -Wno-unused -Wfatal-errors -Werror -Wno-long-long 
 	-msse4 -std=c++0x)

+ 1 - 0
include/anki/core/Logger.h

@@ -5,6 +5,7 @@
 #include "anki/util/Singleton.h"
 #include <array>
 #include <mutex>
+#include <sstream> // For the macros
 
 namespace anki {
 

+ 1 - 1
include/anki/gl/BufferObject.h

@@ -1,7 +1,7 @@
 #ifndef ANKI_GL_BUFFER_OBJECT_H
 #define ANKI_GL_BUFFER_OBJECT_H
 
-#include "anki/gl/Gl.h"
+#include "anki/gl/Ogl.h"
 #include "anki/util/Assert.h"
 
 namespace anki {

+ 1 - 1
include/anki/gl/Fbo.h

@@ -3,7 +3,7 @@
 
 #include "anki/util/Assert.h"
 #include "anki/util/Exception.h"
-#include "anki/gl/Gl.h"
+#include "anki/gl/Ogl.h"
 #include <initializer_list>
 
 namespace anki {

+ 12 - 2
include/anki/gl/Gl.h

@@ -1,9 +1,19 @@
 /// @file
-/// This file contains the correct OpenGL headers
+/// This file contains the correct OpenGL headers and all the GL classes
 
 #ifndef ANKI_GL_GL_H
 #define ANKI_GL_GL_H
 
-#include <GL/glew.h>
+#include "anki/gl/BufferObject.h"
+#include "anki/gl/Fbo.h"
+#include "anki/gl/GlException.h"
+#include "anki/gl/GlState.h"
+#include "anki/gl/Query.h"
+#include "anki/gl/ShaderProgram.h"
+#include "anki/gl/Texture.h"
+#include "anki/gl/Vao.h"
+#include "anki/gl/Vbo.h"
+
+#include "anki/gl/Ogl.h"
 
 #endif

+ 1 - 1
include/anki/gl/GlState.h

@@ -2,7 +2,7 @@
 #define ANKI_GL_GL_STATE_H
 
 #include "anki/util/Singleton.h"
-#include "anki/gl/Gl.h"
+#include "anki/gl/Ogl.h"
 #include "anki/util/Assert.h"
 #include <unordered_map>
 #include <mutex>

+ 9 - 0
include/anki/gl/Ogl.h

@@ -0,0 +1,9 @@
+#ifndef ANKI_GL_OGL_H
+#define ANKI_GL_OGL_H
+
+#include <GL/glew.h>
+#if !defined(ANKI_GLEW_H)
+#	error "Wrong GLEW included"
+#endif
+
+#endif

+ 6 - 10
include/anki/gl/Query.h

@@ -1,7 +1,7 @@
 #ifndef ANKI_GL_QUERY_H
 #define ANKI_GL_QUERY_H
 
-#include "anki/gl/Gl.h"
+#include "anki/gl/Ogl.h"
 #include <cstdint>
 
 namespace anki {
@@ -24,20 +24,16 @@ public:
 	/// @}
 
 	/// Start
-	void beginQuery();
+	void begin();
 
 	/// End
-	void endQuery();
+	void end();
 
-	/// Get results
-	///
-	/// Waits for operations to finish
+	/// Get results. Waits for operations to finish
 	uint64_t getResult();
 
-	/// Get results
-	///
-	/// Doesn't Wait for operations to finish. If @a finished is false then 
-	/// the return value is irrelevant
+	/// Get results. Doesn't Wait for operations to finish. If @a finished is
+	/// false then the return value is irrelevant
 	uint64_t getResultNoWait(bool& finished);
 
 private:

+ 1 - 1
include/anki/gl/ShaderProgram.h

@@ -6,7 +6,7 @@
 #include "anki/util/Flags.h"
 #include "anki/math/Forward.h"
 #include "anki/util/NonCopyable.h"
-#include "anki/gl/Gl.h"
+#include "anki/gl/Ogl.h"
 #include <boost/ptr_container/ptr_vector.hpp>
 #include <vector>
 #include <string>

+ 12 - 12
include/anki/gl/Texture.h

@@ -3,7 +3,7 @@
 
 #include "anki/util/Assert.h"
 #include "anki/util/Singleton.h"
-#include "anki/gl/Gl.h"
+#include "anki/gl/Ogl.h"
 #include <cstdlib>
 #include <vector>
 #include <limits>
@@ -148,17 +148,17 @@ public:
 	/// Texture initializer struct
 	struct Initializer
 	{
-		uint32_t width;
-		uint32_t height;
-		GLint internalFormat;
-		GLenum format;
-		GLenum type;
-		const void* data;
-		bool mipmapping;
-		TextureFilteringType filteringType;
-		bool repeat;
-		int anisotropyLevel;
-		size_t dataSize; ///< For compressed textures
+		uint32_t width = 0;
+		uint32_t height = 0;
+		GLint internalFormat = 0;
+		GLenum format = 0;
+		GLenum type = 0;
+		const void* data = nullptr;
+		bool mipmapping = false;
+		TextureFilteringType filteringType = TFT_NEAREST;
+		bool repeat = true;
+		int anisotropyLevel = 0;
+		size_t dataSize = 0; ///< For compressed textures
 	};
 
 	/// @name Constructors/Destructor

+ 1 - 1
include/anki/gl/Vao.h

@@ -3,7 +3,7 @@
 
 #include "anki/util/Assert.h"
 #include "anki/gl/GlException.h"
-#include "anki/gl/Gl.h"
+#include "anki/gl/Ogl.h"
 
 namespace anki {
 

+ 3 - 7
include/anki/input/Input.h

@@ -3,12 +3,10 @@
 
 #include "anki/math/Math.h"
 #include <SDL/SDL_scancode.h>
-#include <boost/array.hpp>
-
+#include <array>
 
 namespace anki {
 
-
 /// Handle the SDL input
 class Input
 {
@@ -63,10 +61,10 @@ private:
 	/// - 0 times: unpressed
 	/// - 1 times: pressed once
 	/// - >1 times: Kept pressed 'n' times continuously
-	boost::array<short, SDL_NUM_SCANCODES> keys;
+	std::array<short, SDL_NUM_SCANCODES> keys;
 
 	/// Mouse btns. Supporting 3 btns & wheel. @see keys
-	boost::array<short, 8> mouseBtns;
+	std::array<short, 8> mouseBtns;
 	/// @}
 
 	bool warpMouseFlag;
@@ -74,8 +72,6 @@ private:
 	void init();
 };
 
-
 } // end namespace
 
-
 #endif

+ 1 - 0
include/anki/renderer/Bl.h

@@ -4,6 +4,7 @@
 #include "anki/renderer/RenderingPass.h"
 #include "anki/resource/TextureResource.h"
 #include "anki/resource/Resource.h"
+#include "anki/resource/ShaderProgramResource.h"
 #include "anki/gl/Fbo.h"
 
 namespace anki {

+ 88 - 89
include/anki/renderer/Hdr.h

@@ -4,106 +4,105 @@
 #include "anki/renderer/RenderingPass.h"
 #include "anki/gl/Fbo.h"
 #include "anki/resource/TextureResource.h"
+#include "anki/resource/ShaderProgramResource.h"
 #include "anki/resource/Resource.h"
 
-
 namespace anki {
 
-
 class ShaderProgram;
 
-
 /// High dynamic range lighting pass
 class Hdr: public SwitchableRenderingPass
 {
-	public:
-		Hdr(Renderer& r_);
-		~Hdr();
-		void init(const RendererInitializer& initializer);
-		void run();
-
-		/// @name Accessors
-		/// @{
-		float getExposure() const
-		{
-			return exposure;
-		}
-		float& getExposure()
-		{
-			return exposure;
-		}
-		void setExposure(const float x)
-		{
-			exposure = x;
-		}
-
-		uint getBlurringIterationsNum() const
-		{
-			return blurringIterationsNum;
-		}
-		uint& getBlurringIterationsNum()
-		{
-			return blurringIterationsNum;
-		}
-		void setBlurringIterationsNum(const uint x)
-		{
-			blurringIterationsNum = x;
-		}
-
-		float getBlurringDistance() const
-		{
-			return blurringDist;
-		}
-		float& getBlurringDistance()
-		{
-			return blurringDist;
-		}
-		void setBlurringDistance(const float x)
-		{
-			blurringDist = x;
-		}
-
-		float getRenderingQuality() const
-		{
-			return renderingQuality;
-		}
-
-		const Texture& getToneFai() const
-		{
-			return toneFai;
-		}
-
-		const Texture& getHblurFai() const
-		{
-			return hblurFai;
-		}
-
-		const Texture& getFai() const
-		{
-			return fai;
-		}
-		/// @}
-
-	private:
-		float exposure; ///< How bright is the HDR
-		uint blurringIterationsNum; ///< The blurring iterations of the tone map
-		float blurringDist; ///< Distance in blurring
-		float renderingQuality;
-		Fbo toneFbo;
-		Fbo hblurFbo;
-		Fbo vblurFbo;
-		ShaderProgramResourcePointer toneSProg;
-		ShaderProgramResourcePointer hblurSProg;
-		ShaderProgramResourcePointer vblurSProg;
-		Texture toneFai; ///< Vertical blur pass FAI
-		Texture hblurFai; ///< pass0Fai with the horizontal blur FAI
-		Texture fai; ///< The final FAI
-
-		void initFbo(Fbo& fbo, Texture& fai);
+public:
+	Hdr(Renderer* r_)
+		: SwitchableRenderingPass(r_)
+	{}
+
+	~Hdr();
+
+	void init(const RendererInitializer& initializer);
+	void run();
+
+	/// @name Accessors
+	/// @{
+	float getExposure() const
+	{
+		return exposure;
+	}
+	void setExposure(const float x)
+	{
+		exposure = x;
+		toneSProg.bind();
+		toneSProg.findUniformVariableByName("exposure")->set(exposure);
+	}
+
+	uint getBlurringIterationsNum() const
+	{
+		return blurringIterationsNum;
+	}
+	void setBlurringIterationsNum(const uint x)
+	{
+		blurringIterationsNum = x;
+	}
+
+	float getBlurringDistance() const
+	{
+		return blurringDist;
+	}
+	void setBlurringDistance(const float x)
+	{
+		blurringDist = x;
+
+		hblurSProg.bind();
+		hblurSProg.findUniformVariableByName("blurringDist")->set(
+			float(blurringDist / width));
+		vblurSProg.bind();
+		vblurSProg.findUniformVariableByName("blurringDist")->set(
+			float(blurringDist / height));
+	}
+
+	float getRenderingQuality() const
+	{
+		return renderingQuality;
+	}
+
+	const Texture& getToneFai() const
+	{
+		return toneFai;
+	}
+
+	const Texture& getHblurFai() const
+	{
+		return hblurFai;
+	}
+
+	const Texture& getFai() const
+	{
+		return fai;
+	}
+	/// @}
+
+private:
+	uint32_t width;
+	uint32_t height;
+	float exposure = 4.0; ///< How bright is the HDR
+	uint32_t blurringIterationsNum = 2; ///< The blurring iterations of the tone map
+	float blurringDist = 1.0; ///< Distance in blurring
+	float renderingQuality = 0.5;
+	Fbo toneFbo;
+	Fbo hblurFbo;
+	Fbo vblurFbo;
+	ShaderProgramResource toneSProg;
+	ShaderProgramResource hblurSProg;
+	ShaderProgramResource vblurSProg;
+	Texture toneFai; ///< Vertical blur pass FAI
+	Texture hblurFai; ///< pass0Fai with the horizontal blur FAI
+	Texture fai; ///< The final FAI
+
+	void initFbo(Fbo& fbo, Texture& fai);
 };
 
-
 } // end namespace
 
-
 #endif

+ 2 - 6
include/anki/renderer/Is.h

@@ -12,19 +12,17 @@
 #include "anki/renderer/Sm.h"
 #include "anki/renderer/Smo.h"
 
-
 namespace anki {
 
-
 class PointLight;
 class SpotLight;
 
-
 /// Illumination stage
 class Is: private RenderingPass
 {
 public:
-	Is(Renderer& r_);
+	Is(Renderer* r);
+
 	void init(const RendererInitializer& initializer);
 	void run();
 
@@ -40,8 +38,6 @@ private:
 	Texture fai;
 };
 
-
 } // end namespace
 
-
 #endif

+ 84 - 89
include/anki/renderer/MainRenderer.h

@@ -2,104 +2,99 @@
 #define ANKI_RENDERER_MAIN_RENDERER_H
 
 #include "anki/renderer/Renderer.h"
-#include <boost/scoped_ptr.hpp>
-#include <GL/glew.h>
-
+#include "anki/renderer/Deformer.h"
+#include "anki/util/Singleton.h"
 
 namespace anki {
 
-
-class Deformer;
-
-
 /// Main onscreen renderer
 class MainRenderer: public Renderer
 {
-	public:
-		MainRenderer();
-
-		~MainRenderer();
-
-		/// @name Setters & getters
-		/// @{
-		int getSceenshotJpegQuality() const
-		{
-			return screenshotJpegQuality;
-		}
-		int& getSceenshotJpegQuality()
-		{
-			return screenshotJpegQuality;
-		}
-		void setSceenshotJpegQuality(const int x)
-		{
-			screenshotJpegQuality = x;
-		}
-
-		float getRenderingQuality() const
-		{
-			return renderingQuality;
-		}
-
-		const Dbg& getDbg() const
-		{
-			return dbg;
-		}
-		Dbg& getDbg()
-		{
-			return dbg;
-		}
-
-		double getDbgTime() const
-		{
-			return dbgTime;
-		}
-		/// @}
-
-		/// The same as Renderer::init but with additional initialization.
-		/// @see Renderer::init
-		void init(const RendererInitializer& initializer);
-
-		/// The same as Renderer::render but in addition it renders the final
-		/// FAI to the framebuffer
-		/// @param cam @see Renderer::render
-		void render(Camera& cam);
-
-		/// Save the color buffer to a tga (lossless & uncompressed & slow)
-		/// or jpeg (lossy & compressed fast)
-		/// @param filename The file to save
-		void takeScreenshot(const char* filename);
-
-	private:
-		/// @name Passes
-		/// @{
-		Dbg dbg; ///< Debugging rendering stage. Only the main renderer has it
-		/// @}
-
-		/// @name Profiling stuff
-		/// @{
-		double dbgTime;
-		boost::scoped_ptr<Query> dbgTq;
-		/// @}
-
-		ShaderProgramResourcePointer sProg; ///< Final pass' shader program
-		int screenshotJpegQuality; ///< The quality of the JPEG screenshots.
-		                           ///< From 0 to 100
-
-		/// The global rendering quality of the raster image. Its a percentage
-		/// of the application's window size. From 0.0(low) to 1.0(high)
-		float renderingQuality;
-
-		boost::scoped_ptr<Deformer> deformer;
-
-		GLEWContext glContext;
-
-		void takeScreenshotTga(const char* filename);
-		void takeScreenshotJpeg(const char* filename);
-		void initGl();
+public:
+	MainRenderer()
+		: dbg(this)
+	{}
+
+	~MainRenderer();
+
+	/// @name Setters & getters
+	/// @{
+	int getSceenshotJpegQuality() const
+	{
+		return screenshotJpegQuality;
+	}
+	int& getSceenshotJpegQuality()
+	{
+		return screenshotJpegQuality;
+	}
+	void setSceenshotJpegQuality(const int x)
+	{
+		screenshotJpegQuality = x;
+	}
+
+	float getRenderingQuality() const
+	{
+		return renderingQuality;
+	}
+
+	const Dbg& getDbg() const
+	{
+		return dbg;
+	}
+	Dbg& getDbg()
+	{
+		return dbg;
+	}
+
+	double getDbgTime() const
+	{
+		return dbgTime;
+	}
+	/// @}
+
+	/// The same as Renderer::init but with additional initialization.
+	/// @see Renderer::init
+	void init(const RendererInitializer& initializer);
+
+	/// The same as Renderer::render but in addition it renders the final
+	/// FAI to the framebuffer
+	/// @param scene @see Renderer::render
+	void render(Scene& scene);
+
+	/// Save the color buffer to a tga (lossless & uncompressed & slow)
+	/// or jpeg (lossy & compressed fast)
+	/// @param filename The file to save
+	void takeScreenshot(const char* filename);
+
+private:
+	/// @name Passes
+	/// @{
+	Dbg dbg; ///< Debugging rendering stage. Only the main renderer has it
+	/// @}
+
+	/// @name Profiling stuff
+	/// @{
+	double dbgTime;
+	std::unique_ptr<Query> dbgTq;
+	/// @}
+
+	ShaderProgramResourcePointer sProg; ///< Final pass' shader program
+	int screenshotJpegQuality = 90; ///< The quality of the JPEG screenshots.
+							        ///< From 0 to 100
+
+	/// The global rendering quality of the raster image. Its a percentage
+	/// of the application's window size. From 0.0(low) to 1.0(high)
+	float renderingQuality;
+
+	std::unique_ptr<Deformer> deformer;
+
+	void takeScreenshotTga(const char* filename);
+	void takeScreenshotJpeg(const char* filename);
+	void initGl();
 };
 
+typedef Singleton<MainRenderer> MainRendererSingleton;
 
 } // end namespace
 
-
 #endif

+ 41 - 41
include/anki/renderer/Ms.h

@@ -2,57 +2,57 @@
 #define ANKI_RENDERER_MS_H
 
 #include "anki/renderer/RenderingPass.h"
-#include "anki/resource/TextureResource.h"
+#include "anki/gl/Texture.h"
 #include "anki/gl/Fbo.h"
 #include "anki/renderer/Ez.h"
 
-
 namespace anki {
 
-
 /// Material stage
 class Ms: public RenderingPass
 {
-	public:
-		Ms(Renderer& r_);
-		~Ms();
-
-		/// @name Accessors
-		/// @{
-		const Texture& getNormalFai() const
-		{
-			return normalFai;
-		}
-
-		const Texture& getDiffuseFai() const
-		{
-			return diffuseFai;
-		}
-
-		const Texture& getSpecularFai() const
-		{
-			return specularFai;
-		}
-
-		const Texture& getDepthFai() const
-		{
-			return depthFai;
-		}
-		/// @}
-
-		void init(const RendererInitializer& initializer);
-		void run();
-
-	private:
-		Ez ez; /// EarlyZ pass
-		Fbo fbo;
-		Texture normalFai; ///< The FAI for normals
-		Texture diffuseFai; ///< The FAI for diffuse color
-		Texture specularFai; ///< The FAI for specular color and shininess
-		Texture depthFai; ///< The FAI for depth
+public:
+	Ms(Renderer* r_)
+		: RenderingPass(r_), ez(r_)
+	{}
+
+	~Ms();
+
+	/// @name Accessors
+	/// @{
+	const Texture& getNormalFai() const
+	{
+		return normalFai;
+	}
+
+	const Texture& getDiffuseFai() const
+	{
+		return diffuseFai;
+	}
+
+	const Texture& getSpecularFai() const
+	{
+		return specularFai;
+	}
+
+	const Texture& getDepthFai() const
+	{
+		return depthFai;
+	}
+	/// @}
+
+	void init(const RendererInitializer& initializer);
+	void run();
+
+private:
+	Ez ez; /// EarlyZ pass
+	Fbo fbo;
+	Texture normalFai; ///< The FAI for normals
+	Texture diffuseFai; ///< The FAI for diffuse color
+	Texture specularFai; ///< The FAI for specular color and shininess
+	Texture depthFai; ///< The FAI for depth
 };
 
-
 } // end namespace
 
 #endif

+ 62 - 66
include/anki/renderer/Pps.h

@@ -9,78 +9,74 @@
 #include "anki/renderer/Ssao.h"
 #include "anki/renderer/Bl.h"
 
-
 namespace anki {
 
-
 class ShaderProgram;
 
-
-/// Post-processing stage.
-///
-/// This stage is divided into 2 two parts. The first happens before blending
-/// stage and the second after.
+/// Post-processing stage.This stage is divided into 2 two parts. The first
+/// happens before blending stage and the second after
 class Pps: private RenderingPass
 {
-	public:
-		Pps(Renderer& r_);
-		~Pps();
-		void init(const RendererInitializer& initializer);
-		void runPrePass();
-		void runPostPass();
-
-		/// @name Accessors
-		/// @{
-		const Hdr& getHdr() const
-		{
-			return hdr;
-		}
-		Hdr& getHdr()
-		{
-			return hdr;
-		}
-
-		const Ssao& getSsao() const
-		{
-			return ssao;
-		}
-
-		const Bl& getBl() const
-		{
-			return bl;
-		}
-		Bl& getBl()
-		{
-			return bl;
-		}
-
-		const Texture& getPrePassFai() const
-		{
-			return prePassFai;
-		}
-
-		const Texture& getPostPassFai() const
-		{
-			return postPassFai;
-		}
-		/// @}
-
-	private:
-		/// @name Passes
-		/// @{
-		Hdr hdr;
-		Ssao ssao;
-		Bl bl;
-		/// @}
-
-		Fbo prePassFbo;
-		Fbo postPassFbo;
-
-		ShaderProgramResourcePointer prePassSProg;
-		ShaderProgramResourcePointer postPassSProg;
-
-		Texture prePassFai; ///< FAI #1
-		Texture postPassFai; ///< FAI #2
+public:
+	Pps(Renderer* r_);
+	~Pps();
+
+	void init(const RendererInitializer& initializer);
+	void runPrePass();
+	void runPostPass();
+
+	/// @name Accessors
+	/// @{
+	const Hdr& getHdr() const
+	{
+		return hdr;
+	}
+	Hdr& getHdr()
+	{
+		return hdr;
+	}
+
+	const Ssao& getSsao() const
+	{
+		return ssao;
+	}
+
+	const Bl& getBl() const
+	{
+		return bl;
+	}
+	Bl& getBl()
+	{
+		return bl;
+	}
+
+	const Texture& getPrePassFai() const
+	{
+		return prePassFai;
+	}
+
+	const Texture& getPostPassFai() const
+	{
+		return postPassFai;
+	}
+	/// @}
+
+private:
+	/// @name Passes
+	/// @{
+	Hdr hdr;
+	Ssao ssao;
+	Bl bl;
+	/// @}
+
+	Fbo prePassFbo;
+	Fbo postPassFbo;
+
+	ShaderProgramResource prePassSProg;
+	ShaderProgramResource postPassSProg;
+
+	Texture prePassFai; ///< FAI #1
+	Texture postPassFai; ///< FAI #2
 };
 
 

+ 91 - 22
include/anki/renderer/Renderer.h

@@ -2,40 +2,110 @@
 #define ANKI_RENDERER_RENDERER_H
 
 #include "anki/math/Math.h"
-#include "anki/gl/Fbo.h"
 #include "anki/resource/TextureResource.h"
 #include "anki/resource/ShaderProgramResource.h"
-#include "anki/gl/Vbo.h"
-#include "anki/gl/Vao.h"
 #include "anki/resource/Resource.h"
+#include "anki/gl/Gl.h"
+
 #include "anki/renderer/Ms.h"
 #include "anki/renderer/Is.h"
 #include "anki/renderer/Pps.h"
 #include "anki/renderer/Bs.h"
 #include "anki/renderer/Dbg.h"
-#include "anki/gl/GlException.h"
-#include "anki/gl/GlState.h"
-#include "anki/gl/Query.h"
 #include "anki/renderer/Drawer.h"
-#include <boost/scoped_ptr.hpp>
-
 
 namespace anki {
 
+/// A struct to initialize the renderer. It contains a few extra params for
+/// the MainRenderer
+struct RendererInitializer
+{
+	// Ms
+	struct Ms
+	{
+		struct Ez
+		{
+			bool enabled = false;
+		} ez;
+	} ms;
+
+	// Is
+	struct Is
+	{
+		// Sm
+		struct Sm
+		{
+			bool enabled = true;
+			bool pcfEnabled = true;
+			bool bilinearEnabled = true;
+			int resolution = 1024;
+			float level0Distance = 3.0;
+		} sm;
+	} is;
+
+	// Pps
+	struct Pps
+	{
+		// Hdr
+		struct Hdr
+		{
+			bool enabled = true;
+			float renderingQuality = 0.25;
+			float blurringDist = 1.0;
+			float blurringIterationsNum = 2;
+			float exposure = 4.0;
+		} hdr;
+
+		// Ssao
+		struct Ssao
+		{
+			bool enabled = true;
+			float renderingQuality = 0.3;
+			uint32_t blurringIterationsNum = 2;
+		} ssao;
+
+		// Bl
+		struct Bl
+		{
+			bool enabled = true;
+			uint blurringIterationsNum = 2;
+			float sideBlurFactor = 1.0;
+		} bl;
+	} pps;
+
+	// Dbg
+	struct Dbg
+	{
+		bool enabled = true;
+	} dbg;
+
+	// the globals
+	int width; ///< Ignored by MainRenderer
+	int height; ///< Ignored by MainRenderer
+	float mainRendererQuality = 1.0; ///< Only for MainRenderer
+	float lodDistance; ///< Distance that used to calculate the LOD
+
+	// funcs
+	RendererInitializer()
+	{}
+
+	RendererInitializer(const RendererInitializer& initializer)
+	{
+		memcpy(this, &initializer, sizeof(RendererInitializer));
+	}
+};
 
 class Camera;
 struct RendererInitializer;
 class ModelNode;
 
-
-/// Renderer namespace
-
-/// Offscreen renderer
-/// It is a class and not a namespace because we may need external renderers
-/// for security cameras for example
+/// Offscreen renderer. It is a class and not a namespace because we may need
+/// external renderers for security cameras for example
 class Renderer
 {
 public:
+	typedef RendererInitializer Initializer;
+
 	/// The types of rendering a ModelNode
 	enum ModelNodeRenderType
 	{
@@ -101,13 +171,13 @@ public:
 		return viewProjectionMat;
 	}
 
-	const Camera& getCamera() const
+	const Scene& getScene() const
 	{
-		return *cam;
+		return *scene;
 	}
-	Camera& getCamera()
+	Scene& getScene()
 	{
-		return *cam;
+		return *scene;
 	}
 
 	const RenderableDrawer& getSceneDrawer() const
@@ -173,8 +243,7 @@ public:
 	void init(const RendererInitializer& initializer);
 
 	/// This function does all the rendering stages and produces a final FAI
-	/// @param cam The camera from where the rendering will be done
-	void render(Camera& cam);
+	void render(Scene& scene);
 
 	/// My version of gluUnproject
 	/// @param windowCoords Window screen coords
@@ -231,7 +300,7 @@ protected:
 	/// @name Profiling stuff
 	/// @{
 	double msTime, isTime, ppsTime, bsTime;
-	boost::scoped_ptr<Query> msTq, isTq, ppsTq, bsTq;
+	std::unique_ptr<Query> msTq, isTq, ppsTq, bsTq, pps2Tq;
 	bool enableStagesProfilingFlag;
 	/// @}
 
@@ -239,7 +308,7 @@ protected:
 	uint width;
 	/// Height of the rendering. Don't confuse with the window width
 	uint height;
-	Camera* cam; ///< Current camera
+	Scene* scene; ///< Current scene
 	/// Max color attachments an FBO can accept
 	static int maxColorAtachments;
 	RenderableDrawer sceneDrawer;

+ 0 - 91
include/anki/renderer/RendererInitializer.h

@@ -1,91 +0,0 @@
-#ifndef ANKI_RENDERER_RENDERER_INITIALIZER_H
-#define ANKI_RENDERER_RENDERER_INITIALIZER_H
-
-#include <cstring>
-
-
-namespace anki {
-
-
-/// A struct to initialize the renderer. It contains a few extra params for
-/// the MainRenderer
-struct RendererInitializer
-{
-	// Ms
-	struct Ms
-	{
-		struct Ez
-		{
-			bool enabled;
-		} ez;
-	} ms;
-
-	// Is
-	struct Is
-	{
-		// Sm
-		struct Sm
-		{
-			bool enabled;
-			bool pcfEnabled;
-			bool bilinearEnabled;
-			int resolution;
-			float level0Distance;
-		} sm;
-	} is;
-
-	// Pps
-	struct Pps
-	{
-		// Hdr
-		struct Hdr
-		{
-			bool enabled;
-			float renderingQuality;
-			float blurringDist;
-			float blurringIterationsNum;
-			float exposure;
-		} hdr;
-
-		// Ssao
-		struct Ssao
-		{
-			bool enabled;
-			float renderingQuality;
-			float blurringIterationsNum;
-		} ssao;
-
-		// Bl
-		struct Bl
-		{
-			bool enabled;
-			uint blurringIterationsNum;
-			float sideBlurFactor;
-		} bl;
-	} pps;
-
-	// Dbg
-	struct Dbg
-	{
-		bool enabled;
-	} dbg;
-
-	// the globals
-	int width; ///< Ignored by MainRenderer
-	int height; ///< Ignored by MainRenderer
-	float mainRendererQuality; ///< Only for MainRenderer
-
-	// funcs
-	RendererInitializer() {}
-
-	RendererInitializer(const RendererInitializer& initializer)
-	{
-		memcpy(this, &initializer, sizeof(RendererInitializer));
-	}
-};
-
-
-} // end namespace
-
-
-#endif

+ 2 - 8
include/anki/renderer/RenderingPass.h

@@ -1,14 +1,11 @@
 #ifndef ANKI_RENDERER_RENDERING_PASS_H
 #define ANKI_RENDERER_RENDERING_PASS_H
 
-
 namespace anki {
 
-
 class Renderer;
 struct RendererInitializer;
 
-
 /// Rendering pass
 class RenderingPass
 {
@@ -27,7 +24,6 @@ protected:
 	Renderer* r; ///< Know your father
 };
 
-
 /// Rendering pass that can be enabled or disabled
 class SwitchableRenderingPass: public RenderingPass
 {
@@ -50,11 +46,9 @@ public:
 	}
 
 protected:
-	bool enabled;
+	bool enabled = false;
 };
 
-
-} // end namespace
-
+} // end namespace anki
 
 #endif

+ 78 - 81
include/anki/renderer/Sm.h

@@ -4,95 +4,92 @@
 #include "anki/renderer/RenderingPass.h"
 #include "anki/gl/Fbo.h"
 #include "anki/resource/TextureResource.h"
-#include "anki/scene/VisibilityTester.h"
-
+#include <array>
 
 namespace anki {
 
-
 class Light;
 
-
 /// Shadowmapping pass
 class Sm: private RenderingPass
 {
-	public:
-		Sm(Renderer* r_)
-			: RenderingPass(r_)
-		{}
-
-		/// @name Accessors
-		/// @{
-		const Texture& getShadowMap() const
-		{
-			return crntLevel->shadowMap;
-		}
-
-		bool getEnabled() const
-		{
-			return enabled;
-		}
-
-		bool isPcfEnabled() const
-		{
-			return pcfEnabled;
-		}
-
-		bool getBilinearEnabled() const
-		{
-			return bilinearEnabled;
-		}
-
-		int getResolution() const
-		{
-			return resolution;
-		}
-		/// @}
-
-		void init(const RendererInitializer& initializer);
-
-		/// Render the scene only with depth and store the result in the
-		/// shadowMap
-		/// @param[in] light The light
-		/// @param[in] distance The distance between the viewers camera and the
-		/// light
-		void run(Light& light, float distance); /// XXX order
-
-	private:
-		/// The shadowmap levels of detail
-		/// It starts from level 0 which is the detailed one and moves to lower
-		/// resolution shadowmaps. When the distance between the viewer's
-		/// camera and the light is getting bigger then a higher level will be
-		/// used
-		struct Level
-		{
-			Fbo fbo; ///< Illumination stage shadowmapping FBO
-			Texture shadowMap; ///< The shadowmap for that level
-			uint resolution; ///< The shadowmap's resolution
-			bool bilinear; ///< Enable bilinar filtering in shadowmap
-			/// The maximum distance that this level applies. The distance is
-			/// between the viewer's camera and the light
-			float distance;
-		};
-
-		std::array<Level, 4> levels; ///< The levels of detail. The 0 is the
-		                               ///< detailed one
-		Level* crntLevel; ///< Current level of detail. Assigned by run
-
-		bool enabled; ///< If false then disable SM at all
-		/// Enable Percentage Closer Filtering for all the levels
-		bool pcfEnabled;
-		/// Shadowmap bilinear filtering for the first level. Better quality
-		bool bilinearEnabled;
-		/// Shadowmap resolution of the first level. The higher the better but
-		/// slower
-		int resolution;
-		/// The distance of the first level. @see Level::distance
-		float level0Distance;
-
-		/// Initialize a level
-		static void initLevel(uint resolution, float maxDistance,
-			bool bilinear, Level& level);
+public:
+	Sm(Renderer* r_)
+		: RenderingPass(r_)
+	{}
+
+	/// @name Accessors
+	/// @{
+	const Texture& getShadowMap() const
+	{
+		return crntLevel->shadowMap;
+	}
+
+	bool getEnabled() const
+	{
+		return enabled;
+	}
+
+	bool getPcfEnabled() const
+	{
+		return pcfEnabled;
+	}
+
+	bool getBilinearEnabled() const
+	{
+		return bilinearEnabled;
+	}
+
+	int getResolution() const
+	{
+		return resolution;
+	}
+	/// @}
+
+	void init(const RendererInitializer& initializer);
+
+	/// Render the scene only with depth and store the result in the
+	/// shadowMap
+	/// @param[in] light The light
+	/// @param[in] distance The distance between the viewer's camera and the
+	///            light
+	void run(Light& light, float distance); /// XXX order
+
+private:
+	/// The shadowmap levels of detail
+	/// It starts from level 0 which is the detailed one and moves to lower
+	/// resolution shadowmaps. When the distance between the viewer's
+	/// camera and the light is getting bigger then a higher level will be
+	/// used
+	struct Level
+	{
+		Fbo fbo; ///< Illumination stage shadowmapping FBO
+		Texture shadowMap; ///< The shadowmap for that level
+		uint32_t resolution; ///< The shadowmap's resolution
+		bool bilinear; ///< Enable bilinar filtering in shadowmap
+		/// The maximum distance that this level applies. The distance is
+		/// between the viewer's camera and the light
+		float distance;
+	};
+
+	std::array<Level, 4> levels; ///< The levels of detail. The 0 is the
+								   ///< detailed one
+	Level* crntLevel; ///< Current level of detail. Assigned by run
+
+	bool enabled; ///< If false then disable SM at all
+	/// Enable Percentage Closer Filtering for all the levels
+	bool pcfEnabled;
+	/// Shadowmap bilinear filtering for the first level. Better quality
+	bool bilinearEnabled;
+	/// Shadowmap resolution of the first level. The higher the better but
+	/// slower
+	int resolution;
+	/// The distance of the first level. @see Level::distance
+	float level0Distance;
+
+	/// Initialize a level
+	static void initLevel(uint resolution, float maxDistance,
+		bool bilinear, Level& level);
 };
 
 

+ 0 - 5
include/anki/renderer/Smo.h

@@ -3,13 +3,10 @@
 
 #include "anki/renderer/RenderingPass.h"
 
-
 namespace anki {
 
-
 class Light;
 
-
 /// Stencil masking optimizations
 class Smo: public RenderingPass
 {
@@ -26,8 +23,6 @@ public:
 private:
 };
 
-
 } // end namespace
 
-
 #endif

+ 44 - 48
include/anki/renderer/Ssao.h

@@ -2,65 +2,61 @@
 #define ANKI_RENDERER_SSAO_H
 
 #include "anki/renderer/RenderingPass.h"
-#include "anki/gl/Fbo.h"
-#include "anki/resource/TextureResource.h"
 #include "anki/resource/ShaderProgramResource.h"
+#include "anki/resource/TextureResource.h"
 #include "anki/resource/Resource.h"
-#include "anki/gl/Vbo.h"
-#include "anki/gl/Vao.h"
-
+#include "anki/gl/Fbo.h"
+#include "anki/gl/Texture.h"
 
 namespace anki {
 
-
 /// Screen space ambient occlusion pass
 ///
 /// Three passes:
-/// 1) Calc ssao factor
-/// 2) Blur vertically
-/// 3) Blur horizontally repeat 2, 3
+/// @li Calc ssao factor
+/// @li Blur vertically
+/// @li Blur horizontally repeat 2, 3
 class Ssao: public SwitchableRenderingPass
 {
-	public:
-		Ssao(Renderer* r_)
-			: SwitchableRenderingPass(r_)
-		{}
-
-		void init(const RendererInitializer& initializer);
-		void run();
-
-		/// @name Accessors
-		/// @{
-		float getRenderingQuality() const
-		{
-			return renderingQuality;
-		}
-
-		const Texture& getFai() const
-		{
-			return fai;
-		}
-		/// @}
-
-	private:
-		Texture ssaoFai; ///< It contains the unblurred SSAO factor
-		Texture hblurFai;
-		Texture fai;  ///< AKA vblurFai The final FAI
-		float renderingQuality;
-		float blurringIterationsNum;
-		Fbo ssaoFbo;
-		Fbo hblurFbo;
-		Fbo vblurFbo;
-		TextureResourcePointer noiseMap;
-		ShaderProgramResourcePointer ssaoSProg;
-		ShaderProgramResourcePointer hblurSProg;
-		ShaderProgramResourcePointer vblurSProg;
-
-		void createFbo(Fbo& fbo, Texture& fai);
+public:
+	Ssao(Renderer* r_)
+		: SwitchableRenderingPass(r_)
+	{}
+
+	void init(const RendererInitializer& initializer);
+	void run();
+
+	/// @name Accessors
+	/// @{
+	float getRenderingQuality() const
+	{
+		return renderingQuality;
+	}
+
+	const Texture& getFai() const
+	{
+		return fai;
+	}
+	/// @}
+
+private:
+	Texture ssaoFai; ///< It contains the unblurred SSAO factor
+	Texture hblurFai;
+	Texture fai;  ///< AKA vblurFai The final FAI
+	float renderingQuality;
+	uint32_t blurringIterationsNum;
+	Fbo ssaoFbo;
+	Fbo hblurFbo;
+	Fbo vblurFbo;
+	TextureResourcePointer noiseMap;
+	ShaderProgramResource ssaoSProg;
+	ShaderProgramResource hblurSProg;
+	ShaderProgramResource vblurSProg;
+	uint32_t width, height;
+
+	void createFbo(Fbo& fbo, Texture& fai);
 };
 
-
-} // end namespace
-
+} // end namespace anki
 
 #endif

+ 1 - 1
include/anki/resource/Material.h

@@ -8,7 +8,7 @@
 #include "anki/math/Math.h"
 #include "anki/util/Visitor.h"
 #include "anki/util/NonCopyable.h"
-#include "anki/gl/Gl.h"
+#include "anki/gl/Ogl.h"
 #include <boost/ptr_container/ptr_vector.hpp>
 #include <boost/property_tree/ptree_fwd.hpp>
 

+ 3 - 0
include/anki/resource/ShaderProgramResource.h

@@ -12,6 +12,9 @@ public:
 	/// Resource load
 	void load(const char* filename);
 
+	/// Load and add extra code on top of the file
+	void load(const char* filename, const char* extraSrc);
+
 	/// Used by @ref Material and @ref Renderer to create custom shaders in
 	/// the cache
 	/// @param sProgFPathName The file pathname of the shader prog

+ 3 - 3
include/anki/scene/Light.h

@@ -81,15 +81,15 @@ public:
 		specColor = x;
 	}
 
-	bool getShadow() const
+	bool getShadowEnabled() const
 	{
 		return shadow;
 	}
-	bool& getShadow()
+	bool& getShadowEnabled()
 	{
 		return shadow;
 	}
-	void setShadow(const bool x)
+	void setShadowEnabled(const bool x)
 	{
 		shadow = x;
 	}

+ 15 - 3
include/anki/scene/Scene.h

@@ -4,13 +4,12 @@
 #include "anki/scene/SceneNode.h"
 #include "anki/scene/VisibilityTester.h"
 #include "anki/math/Math.h"
+#include "anki/util/Singleton.h"
 #include <boost/range/iterator_range.hpp>
 #include <vector>
 
-
 namespace anki {
 
-
 /// The Scene contains all the dynamic entities
 ///
 /// XXX Add physics
@@ -49,6 +48,19 @@ public:
 		ambientCol = x;
 	}
 
+	Camera& getActiveCamera()
+	{
+		return *mainCam;
+	}
+	const Camera& getActiveCamera() const
+	{
+		return *mainCam;
+	}
+	void setActiveCamera(Camera* cam)
+	{
+		mainCam = cam;
+	}
+
 	Types<SceneNode>::ConstRange getAllNodes() const
 	{
 		return Types<SceneNode>::ConstRange(nodes.begin(), nodes.end());
@@ -133,8 +145,8 @@ private:
 	}
 };
 
+typedef Singleton<Scene> SceneSingleton;
 
 } // end namespace
 
-
 #endif

+ 0 - 6
include/anki/scene/VisibilityTester.h

@@ -4,10 +4,8 @@
 #include <vector>
 #include <boost/range/iterator_range.hpp>
 
-
 namespace anki {
 
-
 class Camera;
 class Scene;
 class SceneNode;
@@ -15,7 +13,6 @@ class Frustumable;
 class Renderable;
 class Light;
 
-
 /// Its actually a container for visible entities
 class VisibilityInfo
 {
@@ -42,7 +39,6 @@ private:
 	Lights lights;
 };
 
-
 /// Performs visibility determination tests and fills a few containers with the
 /// visible scene nodes
 class VisibilityTester
@@ -60,8 +56,6 @@ public:
 	static void test(Frustumable& cam, Scene& scene, VisibilityInfo& vinfo);
 };
 
-
 } // end namespace
 
-
 #endif

+ 4 - 12
include/anki/script/Common.h

@@ -6,7 +6,6 @@
 #include <boost/python.hpp>
 #include <boost/python/suite/indexing/vector_indexing_suite.hpp>
 
-
 namespace anki
 {}
 
@@ -14,14 +13,12 @@ using namespace boost;
 using namespace boost::python;
 using namespace anki;
 
-
 /// Wrap a class
-#define WRAP(x) \
+#define ANKI_WRAP(x) \
 	void boostPythonWrap##x()
 
-
 /// Wrap a singleton class
-#define WRAP_SINGLETON(x) \
+#define ANKI_WRAP_SINGLETON(x) \
 	WRAP(x) { \
 		class_<x, noncopyable>(#x, no_init) \
 			.def("get", & x ::get, \
@@ -30,15 +27,12 @@ using namespace anki;
 		; \
 	}
 
-
-#define WRAP_CONTAINER(x) \
+#define ANKI_WRAP_CONTAINER(x) \
 	class_<x >(#x) \
 		.def(vector_indexing_suite<x >()) \
 	;
 
-
-#define CALL_WRAP(x) extern void boostPythonWrap##x(); boostPythonWrap##x()
-
+#define ANKI_CALL_WRAP(x) extern void boostPythonWrap##x(); boostPythonWrap##x()
 
 //==============================================================================
 // Property for simple types                                                   =
@@ -51,7 +45,6 @@ RetType getterSv(const ClassType* t)
 	return (t->*accessor)();
 }
 
-
 template<typename ClassType, typename InType,
 	void (ClassType::* accessor)(const InType&)>
 void setterSv(ClassType* t, InType in)
@@ -65,5 +58,4 @@ void setterSv(ClassType* t, InType in)
 	.add_property(#var__, &getterSv<Class__, Type__, &Class__::getter__>, \
 		&setterSv<Class__, Type__, &Class__::setter__>)
 
-
 #endif

+ 27 - 0
include/anki/script/MathCommon.h

@@ -0,0 +1,27 @@
+#ifndef ANKI_SCRIPT_MATH_COMMON_H
+#define ANKI_SCRIPT_MATH_COMMON_H
+
+#include "anki/script/Common.h"
+
+namespace anki {
+
+template<typename ClassType, typename RetType,
+    RetType (ClassType::*accessor)() const>
+RetType getM(const ClassType* t)
+{
+	return (t->*accessor)();
+}
+
+template<typename ClassType, typename InType, InType& (ClassType::*accessor)()>
+void setM(ClassType* t, InType in)
+{
+	(t->*accessor)() = in;
+}
+
+#define ANKI_BP_PROPERTY_MATH(ClassType__, name__) \
+	.add_property(#name__, &getM<ClassType__, float, &ClassType__::name__>, \
+	&setM<ClassType__, float, &ClassType__::name__>)
+
+} // end namespace
+
+#endif

+ 75 - 99
include/anki/ui/UiFont.h

@@ -1,116 +1,92 @@
 #ifndef ANKI_UI_UI_FONT_H
 #define ANKI_UI_UI_FONT_H
 
-#include <boost/scoped_ptr.hpp>
 #include <boost/ptr_container/ptr_vector.hpp>
-#include "anki/util/StdTypes.h"
 #include "anki/math/Math.h"
 
-
 namespace anki {
 
-
 class Texture;
 
-
 /// The font is device agnostic, all sizes are in actual pixels
 class UiFont
 {
-	public:
-		/// Constructor @see create
-		UiFont(const char* fontFilename, uint nominalWidth, uint nominalHeight);
-
-		/// @name Accessors
-		/// @{
-		const Mat3& getGlyphTextureMatrix(char c) const;
-		uint getGlyphWidth(char c) const;
-		uint getGlyphHeight(char c) const;
-		int getGlyphAdvance(char c) const;
-		int getGlyphBearingX(char c) const;
-		int getGlyphBearingY(char c) const;
-
-		const Texture& getMap() const
-		{
-			return *map;
-		}
-
-		uint getLineHeight() const
-		{
-			return lineHeight;
-		}
-		/// @}
-
-	private:
-		struct Glyph
-		{
-			/// Transforms the default texture coordinates to the glyph's. The
-			/// default are (1, 1), (0, 1), (0, 0), (0, 1)
-			Mat3 textureMat;
-			uint width;
-			uint height;
-			int horizBearingX;
-			int horizBearingY;
-			int horizAdvance;
-		};
-
-		/// The texture map that contains all the glyphs
-		boost::scoped_ptr<Texture> map;
-		/// A set of glyphs from ' ' to ' ' + 128
-		boost::ptr_vector<Glyph> glyphs;
-		uint lineHeight;
-
-		/// @param[in] fontFilename The filename of the font to load
-		/// @param[in] nominalWidth The nominal glyph width in pixels
-		/// @param[in] nominalHeight The nominal glyph height in pixels
-		void create(const char* fontFilename, uint nominalWidth,
-			uint nominalHeight);
+public:
+	/// Constructor @see create
+	UiFont(const char* fontFilename, uint nominalWidth, uint nominalHeight)
+	{
+		create(fontFilename, nominalWidth, nominalHeight);
+	}
+
+	/// @name Accessors
+	/// @{
+	const Mat3& getGlyphTextureMatrix(char c) const
+	{
+		return glyphs[c - ' '].textureMat;
+	}
+
+	uint32_t getGlyphWidth(char c) const
+	{
+		return glyphs[c - ' '].width;
+	}
+
+	uint32_t getGlyphHeight(char c) const
+	{
+		return glyphs[c - ' '].height;
+	}
+
+	int getGlyphAdvance(char c) const
+	{
+		return glyphs[c - ' '].horizAdvance;
+	}
+
+	int getGlyphBearingX(char c) const
+	{
+		return glyphs[c - ' '].horizBearingX;
+	}
+
+	int getGlyphBearingY(char c) const
+	{
+		return glyphs[c - ' '].horizBearingY;
+	}
+
+	const Texture& getMap() const
+	{
+		return *map;
+	}
+
+	uint32_t getLineHeight() const
+	{
+		return lineHeight;
+	}
+	/// @}
+
+private:
+	struct Glyph
+	{
+		/// Transforms the default texture coordinates to the glyph's. The
+		/// default are (1, 1), (0, 1), (0, 0), (0, 1)
+		Mat3 textureMat;
+		uint32_t width;
+		uint32_t height;
+		int horizBearingX;
+		int horizBearingY;
+		int horizAdvance;
+	};
+
+	/// The texture map that contains all the glyphs
+	std::unique_ptr<Texture> map;
+	/// A set of glyphs from ' ' to ' ' + 128
+	boost::ptr_vector<Glyph> glyphs;
+	uint32_t lineHeight;
+
+	/// @param[in] fontFilename The filename of the font to load
+	/// @param[in] nominalWidth The nominal glyph width in pixels
+	/// @param[in] nominalHeight The nominal glyph height in pixels
+	void create(const char* fontFilename, uint32_t nominalWidth,
+		uint32_t nominalHeight);
 };
 
-
-inline UiFont::UiFont(const char* fontFilename, uint nominalWidth,
-	uint nominalHeight)
-{
-	create(fontFilename, nominalWidth, nominalHeight);
-}
-
-
-inline const Mat3& UiFont::getGlyphTextureMatrix(char c) const
-{
-	return glyphs[c - ' '].textureMat;
-}
-
-
-inline uint UiFont::getGlyphWidth(char c) const
-{
-	return glyphs[c - ' '].width;
-}
-
-
-inline uint UiFont::getGlyphHeight(char c) const
-{
-	return glyphs[c - ' '].height;
-}
-
-
-inline int UiFont::getGlyphAdvance(char c) const
-{
-	return glyphs[c - ' '].horizAdvance;
-}
-
-
-inline int UiFont::getGlyphBearingX(char c) const
-{
-	return glyphs[c - ' '].horizBearingX;
-}
-
-
-inline int UiFont::getGlyphBearingY(char c) const
-{
-	return glyphs[c - ' '].horizBearingY;
-}
-
-
-} // end namespace
-
+} // end namespace anki
 
 #endif

+ 4 - 9
include/anki/ui/UiFtFontLoader.h

@@ -1,7 +1,6 @@
 #ifndef ANKI_UI_UI_FT_FONT_LOADER_H
 #define ANKI_UI_UI_FT_FONT_LOADER_H
 
-#include "anki/util/StdTypes.h"
 #include "anki/math/Math.h"
 #include <vector>
 #include <boost/range/iterator_range.hpp>
@@ -9,10 +8,8 @@
 #include FT_FREETYPE_H
 #include FT_GLYPH_H
 
-
 namespace anki {
 
-
 /// A helper class that uses libfreetype to load glyphs from a font file and
 /// gather the metrics for each glyph
 class UiFtFontLoader
@@ -49,7 +46,7 @@ public:
 
 	/// @name Accessors
 	/// @{
-	const uchar* getImage() const
+	const uint8_t* getImage() const
 	{
 		return &img[0];
 	}
@@ -86,16 +83,16 @@ private:
 	FT_Library library;
 	FT_Face face;
 	std::vector<Glyph> glyphs;
-	std::vector<uchar> img;
+	std::vector<uint8_t> img;
 	FT_Vector imgSize;
-	uint lineHeight; ///< Calculated as the max height among all glyphs
+	uint32_t lineHeight; ///< Calculated as the max height among all glyphs
 	/// @}
 
 	/// Reads the face and extracts the glyphs
 	void getAllGlyphs();
 
 	/// Copy one bitmap to img
-	void copyBitmap(const uchar* srcImg, const FT_Vector& srcSize,
+	void copyBitmap(const uint8_t* srcImg, const FT_Vector& srcSize,
 		const FT_Vector& pos);
 
 	/// Compute image size (imgSize) using the glyphs set
@@ -105,8 +102,6 @@ private:
 	void createImage(const char* filename, const FT_Vector& fontSize);
 };
 
-
 } // end namespace
 
-
 #endif

+ 5 - 14
include/anki/ui/UiPainter.h

@@ -5,16 +5,13 @@
 #include "anki/math/Math.h"
 #include "anki/gl/Vbo.h"
 #include "anki/gl/Vao.h"
-#include <boost/scoped_ptr.hpp>
-
+#include "anki/resource/ShaderProgramResource.h"
 
 namespace anki {
 
-
 class UiFont;
 
-
-/// @todo
+/// XXX
 class UiPainter
 {
 public:
@@ -26,10 +23,6 @@ public:
 	{
 		return pos;
 	}
-	Vec2& getPosition()
-	{
-		return pos;
-	}
 	void setPosition(const Vec2& x)
 	{
 		pos = x;
@@ -39,13 +32,11 @@ public:
 	{
 		return col;
 	}
-	Vec4& getColor()
-	{
-		return col;
-	}
 	void setColor(const Vec4& x)
 	{
 		col = x;
+		sProg->bind();
+		sProg->findUniformVariableByName("color")->set(col);
 	}
 
 	void setFont(const char* fontFilename, uint nominalWidth,
@@ -67,7 +58,7 @@ public:
 private:
 	/// @name Data
 	/// @{
-	boost::scoped_ptr<UiFont> font;
+	std::unique_ptr<UiFont> font;
 	ShaderProgramResourcePointer sProg;
 
 	Vec2 pos;

+ 3 - 8
include/anki/ui/UiPainterDevice.h

@@ -4,19 +4,16 @@
 #include "anki/gl/Fbo.h"
 #include "anki/math/Math.h"
 
-
 namespace anki {
 
-
 class Texture;
 
-
 /// This actually and FBO but with size info
 class UiPainterDevice: public Fbo
 {
 public:
 	/// Constructor
-	UiPainterDevice(Texture& colorFai);
+	UiPainterDevice(Texture* colorFai);
 
 	/// @name Accessors
 	/// @{
@@ -24,13 +21,11 @@ public:
 	/// @}
 
 private:
-	Texture& colorFai;
+	Texture* colorFai;
 
 	void create();
 };
 
-
-} // end namespace
-
+} // end namespace anki
 
 #endif

+ 9 - 18
shaders/GaussianBlurGeneric.glsl

@@ -4,6 +4,7 @@
 /// http://rastergrid.com/blog/2010/09/efficient-gaussian-blur-with-linear-sampling/
 ///
 /// Switches: VPASS or HPASS, COL_RGBA or COL_RGB or COL_R
+/// Also must define IMG_DIMENSION
 ///
 /// This is an optimized version. See the clean one at r213
 
@@ -11,29 +12,19 @@
 
 layout(location = 0) in vec2 position;
 
-uniform float imgDimension = 0.0; ///< The img width for hspass or the img 
-                                  ///< height for vpass
-
 out vec2 vTexCoords;
-out vec2 vOffsets; ///< For side pixels. Its actually a 2D array
 
 /// The offset of side pixels. Its actually a 2D array
 const vec2 BLURRING_OFFSET = vec2(1.3846153846, 3.2307692308); 
 
-
 void main()
 {
 	vTexCoords = position;
-
-	vOffsets = BLURRING_OFFSET / imgDimension;
-
 	gl_Position = vec4(position * 2.0 - 1.0, 0.0, 1.0);
 }
 
-
 #pragma anki start fragmentShader
 
-
 // Preprocessor switches sanity checks
 #if !defined(VPASS) && !defined(HPASS)
 #	error "See file"
@@ -43,14 +34,12 @@ void main()
 #	error "See file"
 #endif
 
-
 uniform sampler2D img; ///< Input FAI
 uniform float blurringDist = 0.0;
 
 in vec2 vTexCoords;
 in vec2 vOffsets;
 
-
 // Determine color type
 #if defined(COL_RGBA)
 #	define COL_TYPE vec4
@@ -69,14 +58,14 @@ in vec2 vOffsets;
 #	define TEX_FETCH r
 #endif
 
+const float BLURRING_OFFSET[2] = float[](1.3846153846 / IMG_DIMENSION, 
+	3.2307692308 / IMG_DIMENSION); 
 
 layout(location = 0) out COL_TYPE fFragColor;
 
-
 const float FIRST_WEIGHT = 0.2255859375;
 const float WEIGHTS[2] = float[](0.314208984375, 0.06982421875);
 
-
 void main()
 {
 	// the center (0,0) pixel
@@ -86,16 +75,18 @@ void main()
 	for(int i = 0; i < 2; i++)
 	{
 #if defined(HPASS)
-		vec2 tc = vec2(vTexCoords.x + blurringDist + vOffsets[i], vTexCoords.y);
+		vec2 tc = vec2(vTexCoords.x + blurringDist + BLURRING_OFFSET[i], 
+			vTexCoords.y);
 		col += texture2D(img, tc).TEX_FETCH * WEIGHTS[i];
 
-		tc.x = vTexCoords.x - blurringDist - vOffsets[i];
+		tc.x = vTexCoords.x - blurringDist - BLURRING_OFFSET[i];
 		col += texture2D(img, tc).TEX_FETCH * WEIGHTS[i];
 #elif defined(VPASS)
-		vec2 tc = vec2(vTexCoords.x, vTexCoords.y + blurringDist + vOffsets[i]);
+		vec2 tc = vec2(vTexCoords.x, 
+			vTexCoords.y + blurringDist + BLURRING_OFFSET[i]);
 		col += texture2D(img, tc).TEX_FETCH * WEIGHTS[i];
 
-		tc.y = vTexCoords.y - blurringDist - vOffsets[i];
+		tc.y = vTexCoords.y - blurringDist - BLURRING_OFFSET[i];
 		col += texture2D(img, tc).TEX_FETCH * WEIGHTS[i];
 #endif
 	}

+ 0 - 1
src/event/MainRendererPpsHdrEvent.cpp

@@ -1,6 +1,5 @@
 #include "anki/event/MainRendererPpsHdrEvent.h"
 #include "anki/renderer/MainRenderer.h"
-#include "anki/core/Globals.h"
 
 namespace anki {
 

+ 1 - 3
src/event/SceneColorEvent.cpp

@@ -1,6 +1,5 @@
 #include "anki/event/SceneColorEvent.h"
 #include "anki/scene/Scene.h"
-#include "anki/core/Globals.h"
 #include "anki/core/Logger.h"
 
 namespace anki {
@@ -39,5 +38,4 @@ void SceneColorEvent::updateSp(float /*prevUpdateTime*/, float crntTime)
 		interpolate(originalColor, finalColor, dp));
 }
 
-
-} // end namespace
+} // end namespace anki

+ 2 - 2
src/gl/Query.cpp

@@ -24,13 +24,13 @@ Query::~Query()
 }
 
 //==============================================================================
-void Query::beginQuery()
+void Query::begin()
 {
 	glBeginQuery(question, glId);
 }
 
 //==============================================================================
-void Query::endQuery()
+void Query::end()
 {
 	glEndQuery(question);
 }

+ 1 - 1
src/gl/ShaderProgram.cpp

@@ -194,7 +194,7 @@ void ShaderProgram::create(const char* vertSource, const char* tcSource,
 	glId = glCreateProgram();
 	if(glId == 0)
 	{
-		throw ANKI_EXCEPTION("glCreateProgram failed");
+		throw ANKI_EXCEPTION("glCreateProgram() failed");
 	}
 	glAttachShader(glId, vertShaderGlId);
 	glAttachShader(glId, fragShaderGlId);

+ 38 - 44
src/input/Input.cpp

@@ -1,13 +1,10 @@
 #include "anki/core/App.h"
 #include "anki/core/Logger.h"
-#include "anki/core/Globals.h"
 #include "anki/input/Input.h"
 #include <SDL/SDL.h>
 
-
 namespace anki {
 
-
 //==============================================================================
 void Input::init()
 {
@@ -18,7 +15,6 @@ void Input::init()
 	ANKI_LOGI("Input initialized");
 }
 
-
 //==============================================================================
 void Input::reset(void)
 {
@@ -28,7 +24,6 @@ void Input::reset(void)
 	mouseVelocity = Vec2(0.0);
 }
 
-
 //==============================================================================
 void Input::handleEvents()
 {
@@ -59,59 +54,58 @@ void Input::handleEvents()
 	{
 		switch(event_.type)
 		{
-			case SDL_KEYDOWN:
-				keys[event_.key.keysym.scancode] = 1;
-				break;
+		case SDL_KEYDOWN:
+			keys[event_.key.keysym.scancode] = 1;
+			break;
 
-			case SDL_KEYUP:
-				keys[event_.key.keysym.scancode] = 0;
-				break;
+		case SDL_KEYUP:
+			keys[event_.key.keysym.scancode] = 0;
+			break;
 
-			case SDL_MOUSEBUTTONDOWN:
-				mouseBtns[event_.button.button] = 1;
-				break;
+		case SDL_MOUSEBUTTONDOWN:
+			mouseBtns[event_.button.button] = 1;
+			break;
 
-			case SDL_MOUSEBUTTONUP:
-				mouseBtns[event_.button.button] = 0;
-				break;
+		case SDL_MOUSEBUTTONUP:
+			mouseBtns[event_.button.button] = 0;
+			break;
 
-			case SDL_MOUSEMOTION:
-			{
-				Vec2 prevMousePosNdc(mousePosNdc);
+		case SDL_MOUSEMOTION:
+		{
+			Vec2 prevMousePosNdc(mousePosNdc);
 
-				mousePos.x() = event_.button.x;
-				mousePos.y() = event_.button.y;
+			mousePos.x() = event_.button.x;
+			mousePos.y() = event_.button.y;
 
-				mousePosNdc.x() = (2.0 * mousePos.x()) /
-					(float)AppSingleton::get().getWindowWidth() - 1.0;
-				mousePosNdc.y() = 1.0 - (2.0 * mousePos.y()) /
-					(float)AppSingleton::get().getWindowHeight();
+			mousePosNdc.x() = (2.0 * mousePos.x()) /
+				(float)AppSingleton::get().getWindowWidth() - 1.0;
+			mousePosNdc.y() = 1.0 - (2.0 * mousePos.y()) /
+				(float)AppSingleton::get().getWindowHeight();
 
-				if(warpMouseFlag)
+			if(warpMouseFlag)
+			{
+				// the SDL_WarpMouse pushes an event in the event queue.
+				// This check is so we wont process the event of the
+				// SDL_WarpMouse function
+				if(mousePosNdc == Vec2(0.0))
 				{
-					// the SDL_WarpMouse pushes an event in the event queue.
-					// This check is so we wont process the event of the
-					// SDL_WarpMouse function
-					if(mousePosNdc == Vec2(0.0))
-					{
-						break;
-					}
-
-					uint w = AppSingleton::get().getWindowWidth();
-					uint h = AppSingleton::get().getWindowHeight();
-					SDL_WarpMouse(w / 2, h / 2);
+					break;
 				}
 
-				mouseVelocity = mousePosNdc - prevMousePosNdc;
-				break;
+				uint w = AppSingleton::get().getWindowWidth();
+				uint h = AppSingleton::get().getWindowHeight();
+				SDL_WarpMouse(w / 2, h / 2);
 			}
 
-			case SDL_QUIT:
-				AppSingleton::get().quit(1);
-				break;
+			mouseVelocity = mousePosNdc - prevMousePosNdc;
+			break;
+		}
+
+		case SDL_QUIT:
+			AppSingleton::get().quit(1);
+			break;
 		}
 	}
 }
 
-
 } // end namespace

+ 1 - 2
src/renderer/Bl.cpp

@@ -1,12 +1,11 @@
 #include "anki/renderer/Bl.h"
-#include "anki/renderer/RendererInitializer.h"
 #include "anki/renderer/Renderer.h"
 #include "anki/resource/ShaderProgramResource.h"
 
 namespace anki {
 
 //==============================================================================
-void Bl::init(const RendererInitializer& initializer)
+void Bl::init(const Renderer::Initializer& initializer)
 {
 	enabled = initializer.pps.bl.enabled;
 	blurringIterationsNum = initializer.pps.bl.blurringIterationsNum;

+ 1 - 2
src/renderer/Dbg.cpp

@@ -1,11 +1,10 @@
 #include "anki/renderer/Dbg.h"
 #include "anki/renderer/Renderer.h"
-#include "anki/renderer/RendererInitializer.h"
 
 namespace anki {
 
 //==============================================================================
-void Dbg::init(const RendererInitializer& initializer)
+void Dbg::init(const Renderer::Initializer& initializer)
 {
 	enabled = initializer.dbg.enabled;
 

+ 1 - 3
src/renderer/Ez.cpp

@@ -2,7 +2,6 @@
 #include "anki/renderer/Renderer.h"
 #include "anki/core/App.h"
 #include "anki/scene/Scene.h"
-#include "anki/renderer/RendererInitializer.h"
 
 namespace anki {
 
@@ -20,8 +19,7 @@ void Ez::init(const RendererInitializer& initializer)
 	try
 	{
 		fbo.create();
-		fbo.setOtherAttachment(GL_DEPTH_ATTACHMENT, 
-			GL_TEXTURE_2D, r->getMs().getDepthFai().getGlId());
+		fbo.setOtherAttachment(GL_DEPTH_ATTACHMENT, r->getMs().getDepthFai());
 	}
 	catch(std::exception& e)
 	{

+ 33 - 84
src/renderer/Hdr.cpp

@@ -1,56 +1,23 @@
 #include <boost/lexical_cast.hpp>
 #include "anki/renderer/Hdr.h"
 #include "anki/renderer/Renderer.h"
-#include "anki/renderer/RendererInitializer.h"
-
 
 namespace anki {
 
-
-//==============================================================================
-// Constructor                                                                 =
-//==============================================================================
-Hdr::Hdr(Renderer& r_)
-:	SwitchableRenderingPass(r_)
-{}
-
-
-//==============================================================================
-// Destructor                                                                  =
 //==============================================================================
 Hdr::~Hdr()
 {}
 
-
-//==============================================================================
-// initFbo                                                                    =
 //==============================================================================
 void Hdr::initFbo(Fbo& fbo, Texture& fai)
 {
 	try
 	{
-		int width = renderingQuality * r.getWidth();
-		int height = renderingQuality * r.getHeight();
+		Renderer::createFai(width, height, GL_RGB8, GL_RGB, GL_FLOAT, fai);
 
 		// create FBO
 		fbo.create();
-		fbo.bind();
-
-		// inform in what buffers we draw
-		fbo.setNumOfColorAttachements(1);
-
-		// create the FAI
-		Renderer::createFai(width, height, GL_RGB, GL_RGB, GL_FLOAT, fai);
-
-		// attach
-		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
-			GL_TEXTURE_2D, fai.getGlId(), 0);
-
-		// test if success
-		fbo.checkIfGood();
-
-		// unbind
-		fbo.unbind();
+		fbo.setColorAttachments({&fai});
 	}
 	catch(std::exception& e)
 	{
@@ -59,11 +26,8 @@ void Hdr::initFbo(Fbo& fbo, Texture& fai)
 	}
 }
 
-
-//==============================================================================
-// init                                                                        =
 //==============================================================================
-void Hdr::init(const RendererInitializer& initializer)
+void Hdr::init(const Renderer::Initializer& initializer)
 {
 	enabled = initializer.pps.hdr.enabled;
 
@@ -73,9 +37,9 @@ void Hdr::init(const RendererInitializer& initializer)
 	}
 
 	renderingQuality = initializer.pps.hdr.renderingQuality;
-	blurringDist = initializer.pps.hdr.blurringDist;
-	blurringIterationsNum = initializer.pps.hdr.blurringIterationsNum;
-	exposure = initializer.pps.hdr.exposure;
+
+	width = renderingQuality * r->getWidth();
+	height = renderingQuality * r->getHeight();
 
 	initFbo(toneFbo, toneFai);
 	initFbo(hblurFbo, hblurFai);
@@ -83,24 +47,25 @@ void Hdr::init(const RendererInitializer& initializer)
 
 	fai.setFiltering(Texture::TFT_LINEAR);
 
-
 	// init shaders
 	toneSProg.load("shaders/PpsHdr.glsl");
 
 	const char* SHADER_FILENAME = "shaders/GaussianBlurGeneric.glsl";
 
-	std::string pps = "#define HPASS\n#define COL_RGB\n";
-	hblurSProg.load(ShaderProgram::createSrcCodeToCache(SHADER_FILENAME,
-		pps.c_str()).c_str());
+	std::string pps = "#define HPASS\n#define COL_RGB\n#define IMG_DIMENTION "
+		+ std::to_string(width) + ".0\n";
+	hblurSProg.load(SHADER_FILENAME, pps.c_str());
 
-	pps = "#define VPASS\n#define COL_RGB\n";
-	vblurSProg.load(ShaderProgram::createSrcCodeToCache(SHADER_FILENAME,
-		pps.c_str()).c_str());
-}
+	pps = "#define VPASS\n#define COL_RGB\n#define IMG_DIMENTION "
+		+ std::to_string(height) + ".0\n";
+	vblurSProg.load(SHADER_FILENAME, pps.c_str());
 
+	// Set the uniforms
+	setBlurringDistance(initializer.pps.hdr.blurringDist);
+	blurringIterationsNum = initializer.pps.hdr.blurringIterationsNum;
+	setExposure(initializer.pps.hdr.exposure);
+}
 
-//==============================================================================
-// runPass                                                                     =
 //==============================================================================
 void Hdr::run()
 {
@@ -109,56 +74,40 @@ void Hdr::run()
 		return;
 	}*/
 
-	int w = renderingQuality * r.getWidth();
-	int h = renderingQuality * r.getHeight();
-	GlStateMachineSingleton::get().setViewport(0, 0, w, h);
+	GlStateSingleton::get().setViewport(0, 0, width, height);
 
-	GlStateMachineSingleton::get().enable(GL_BLEND, false);
-	GlStateMachineSingleton::get().enable(GL_DEPTH_TEST, false);
+	GlStateSingleton::get().disable(GL_BLEND);
+	GlStateSingleton::get().disable(GL_DEPTH_TEST);
 
 	// pass 0
 	toneFbo.bind();
-	toneSProg->bind();
-	toneSProg->findUniformVariableByName("exposure").set(exposure);
-	toneSProg->findUniformVariableByName("fai").set(
-		r.getPps().getPrePassFai(), 0);
-	r.drawQuad();
+	toneSProg.bind();
+	toneSProg.findUniformVariableByName("fai")->set(
+		r->getPps().getPrePassFai());
+	r->drawQuad();
 
 	// blurring passes
-	hblurFai.setRepeat(false);
-	fai.setRepeat(false);
-	for(uint i=0; i<blurringIterationsNum; i++)
+	for(uint32_t i = 0; i < blurringIterationsNum; i++)
 	{
 		// hpass
 		hblurFbo.bind();
-		hblurSProg->bind();
+		hblurSProg.bind();
 		if(i == 0)
 		{
-			hblurSProg->findUniformVariableByName("img").set(toneFai, 0);
+			hblurSProg.findUniformVariableByName("img")->set(toneFai);
 		}
-		else
+		else if(i == 1)
 		{
-			hblurSProg->findUniformVariableByName("img").set(fai, 0);
+			hblurSProg.findUniformVariableByName("img")->set(fai);
 		}
-		//float tmp = float(w);
-		hblurSProg->findUniformVariableByName("imgDimension").set(float(w));
-		hblurSProg->findUniformVariableByName("blurringDist").set(
-			float(blurringDist / w));
-		r.drawQuad();
+		r->drawQuad();
 
 		// vpass
 		vblurFbo.bind();
-		vblurSProg->bind();
-		vblurSProg->findUniformVariableByName("img").set(hblurFai, 0);
-		vblurSProg->findUniformVariableByName("imgDimension").set(float(h));
-		vblurSProg->findUniformVariableByName("blurringDist").set(
-			float(blurringDist / h));
-		r.drawQuad();
+		vblurSProg.bind();
+		vblurSProg.findUniformVariableByName("img")->set(hblurFai);
+		r->drawQuad();
 	}
-
-	// end
-	glBindFramebuffer(GL_FRAMEBUFFER, 0); // Bind the window framebuffer
 }
 
-
 } // end namespace

+ 2 - 7
src/renderer/Is.cpp

@@ -1,24 +1,19 @@
 #include "anki/renderer/Is.h"
 #include "anki/renderer/Renderer.h"
 
-
 #define BLEND_ENABLE true
 
-
 namespace anki {
 
-
 //==============================================================================
-Is::Is(Renderer& r_)
-	: RenderingPass(r_), sm(r_), smo(r_)
+Is::Is(Renderer* r_)
+	: RenderingPass(r_)
 {}
 
-
 //==============================================================================
 void Is::run()
 {
 	/// TODO
 }
 
-
 } // end namespace

+ 29 - 70
src/renderer/MainRenderer.cpp

@@ -1,51 +1,31 @@
-#include <cstdlib>
-#include <cstdio>
-#include <jpeglib.h>
-#include <fstream>
-#include <boost/filesystem.hpp>
-#include <boost/algorithm/string.hpp>
-#include "anki/gl/GlException.h"
 #include "anki/renderer/MainRenderer.h"
 #include "anki/core/App.h"
-#include "anki/renderer/RendererInitializer.h"
-#include "anki/renderer/Ssao.h"
 #include "anki/core/Logger.h"
-#include "anki/gl/TimeQuery.h"
 #include "anki/renderer/Deformer.h"
-
+#include "anki/util/Filesystem.h"
+#include <cstdlib>
+#include <cstdio>
+#include <jpeglib.h>
+#include <fstream>
 
 #define glewGetContext() (&glContext)
 
-
 namespace anki {
 
-
-//==============================================================================
-// Constructors & destructor                                                   =
 //==============================================================================
-MainRenderer::MainRenderer():
-	dbg(*this),
-	screenshotJpegQuality(90)
-{}
-
-
 MainRenderer::~MainRenderer()
 {}
 
-
-//==============================================================================
-// init                                                                        =
 //==============================================================================
-void MainRenderer::init(const RendererInitializer& initializer_)
+void MainRenderer::init(const Renderer::Initializer& initializer_)
 {
 	ANKI_LOGI("Initializing main renderer...");
 	initGl();
 
 	sProg.load("shaders/Final.glsl");
 
-	dbgTq.reset(new TimeQuery);
+	dbgTq.reset(new Query(GL_TIME_ELAPSED));
 
-	//
 	// init the offscreen Renderer
 	//
 	RendererInitializer initializer = initializer_;
@@ -56,51 +36,45 @@ void MainRenderer::init(const RendererInitializer& initializer_)
 		renderingQuality;
 	Renderer::init(initializer);
 	dbg.init(initializer);
-	deformer.reset(new Deformer(*this));
+	deformer.reset(new Deformer);
 	ANKI_LOGI("Main renderer initialized");
 }
 
-
-//==============================================================================
-// initGl                                                                      =
 //==============================================================================
 void MainRenderer::initGl()
 {
 	glewExperimental = GL_TRUE;
-	GLenum err = glewInit();
-	if(err != GLEW_OK)
+	if(glewInit() != GLEW_OK)
 	{
 		throw ANKI_EXCEPTION("GLEW initialization failed");
 	}
 
-	// Ignore re first error
+	// Ignore the first error
 	glGetError();
 
 	// print GL info
-	ANKI_LOGI("OpenGL info: OGL " <<
-		reinterpret_cast<const char*>(glGetString(GL_VERSION)) <<
-		", GLSL " << reinterpret_cast<const char*>(
-			glGetString(GL_SHADING_LANGUAGE_VERSION)));
+	ANKI_LOGI("OpenGL info: OGL "
+		<< reinterpret_cast<const char*>(glGetString(GL_VERSION))
+		<< ", GLSL " << reinterpret_cast<const char*>(
+		glGetString(GL_SHADING_LANGUAGE_VERSION)));
 
 	// get max texture units
 	//glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &maxColorAtachments);
-	int& tun = Texture::getTextureUnitsNum();
-	glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &tun);
 	glClearColor(0.1, 0.1, 0.0, 1.0);
 	glClearDepth(1.0);
 	glClearStencil(0);
 	glDepthFunc(GL_LEQUAL);
 	// CullFace is always on
 	glCullFace(GL_BACK);
-	GlStateMachineSingleton::get().enable(GL_CULL_FACE);
+	GlStateSingleton::get().enable(GL_CULL_FACE);
 
 	// defaults
 	//glDisable(GL_LIGHTING);
 	//glDisable(GL_TEXTURE_2D);
-	GlStateMachineSingleton::get().enable(GL_BLEND, false);
-	GlStateMachineSingleton::get().disable(GL_STENCIL_TEST);
+	GlStateSingleton::get().disable(GL_BLEND);
+	GlStateSingleton::get().disable(GL_STENCIL_TEST);
 	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
-	glDepthMask(true);
+	glDepthMask(GL_TRUE);
 	glDepthFunc(GL_LESS);
 
 	try
@@ -113,46 +87,39 @@ void MainRenderer::initGl()
 	}
 }
 
-
 //==============================================================================
-// render                                                                      =
-//==============================================================================
-void MainRenderer::render(Camera& cam_)
+void MainRenderer::render(Scene& scene)
 {
-	Renderer::render(cam_);
+	Renderer::render(scene);
 
 	if(getStagesProfilingEnabled())
 	{
 		dbgTq->begin();
 		dbg.run();
-		dbgTime = dbgTq->end();
+		dbgTq->end();
 	}
 	else
 	{
 		dbg.run();
 	}
 
-	//
 	// Render the PPS FAI to the framebuffer
 	//
 	glBindFramebuffer(GL_FRAMEBUFFER, 0); // Bind the window framebuffer
 
-	GlStateMachineSingleton::get().setViewport(
+	GlStateSingleton::get().setViewport(
 		0, 0, AppSingleton::get().getWindowWidth(),
 		AppSingleton::get().getWindowHeight());
-	GlStateMachineSingleton::get().enable(GL_DEPTH_TEST, false);
-	GlStateMachineSingleton::get().enable(GL_BLEND, false);
+	GlStateSingleton::get().disable(GL_DEPTH_TEST);
+	GlStateSingleton::get().disable(GL_BLEND);
 	sProg->bind();
 	//sProg->findUniformVariableByName("rasterImage").set(ms.getDiffuseFai(), 0);
 	//sProg->findUniformVariableByName("rasterImage").
 	//	set(is.getFai(), 0);
-	sProg->findUniformVariableByName("rasterImage").set(pps.getPostPassFai(), 0);
+	sProg->findUniformVariableByName("rasterImage")->set(pps.getPostPassFai());
 	drawQuad();
 }
 
-
-//==============================================================================
-// takeScreenshotTga                                                           =
 //==============================================================================
 void MainRenderer::takeScreenshotTga(const char* filename)
 {
@@ -161,7 +128,8 @@ void MainRenderer::takeScreenshotTga(const char* filename)
 	fs.open(filename, std::ios::out | std::ios::binary);
 	if(!fs.is_open())
 	{
-		throw ANKI_EXCEPTION("Cannot create screenshot. File \"" + filename + "\"");
+		throw ANKI_EXCEPTION("Cannot create screenshot. File \""
+			+ filename + "\"");
 	}
 
 	// write headers
@@ -191,9 +159,6 @@ void MainRenderer::takeScreenshotTga(const char* filename)
 	free(buffer);
 }
 
-
-//==============================================================================
-// takeScreenshotJpeg                                                          =
 //==============================================================================
 void MainRenderer::takeScreenshotJpeg(const char* filename)
 {
@@ -243,14 +208,10 @@ void MainRenderer::takeScreenshotJpeg(const char* filename)
 	fclose(outfile);
 }
 
-
-//==============================================================================
-// takeScreenshot                                                              =
 //==============================================================================
 void MainRenderer::takeScreenshot(const char* filename)
 {
-	std::string ext = boost::filesystem::path(filename).extension().string();
-	boost::to_lower(ext);
+	std::string ext = getFileExtension(filename);
 
 	// exec from this extension
 	if(ext == ".tga")
@@ -263,11 +224,9 @@ void MainRenderer::takeScreenshot(const char* filename)
 	}
 	else
 	{
-		throw ANKI_EXCEPTION("File \"" + filename +
-			"\": Unsupported extension");
+		throw ANKI_EXCEPTION("Unsupported file extension: " + filename);
 	}
 	//ANKI_LOGI("Screenshot \"" << filename << "\" saved");
 }
 
-
 } // end namespace

+ 22 - 71
src/renderer/Ms.cpp

@@ -1,76 +1,34 @@
-#include <boost/foreach.hpp>
 #include "anki/renderer/Ms.h"
-#include "anki/renderer/Renderer.h"
-#include "anki/scene/Camera.h"
 #include "anki/renderer/Ez.h"
-#include "anki/scene/RenderableNode.h"
+#include "anki/renderer/Renderer.h"
 
+#include "anki/scene/Camera.h"
+#include "anki/scene/Scene.h"
 
 namespace anki {
 
-
-//==============================================================================
-// Constructor                                                                 =
-//==============================================================================
-Ms::Ms(Renderer& r_)
-:	RenderingPass(r_),
-	ez(r_)
-{}
-
-
-//==============================================================================
-// Destructor                                                                  =
 //==============================================================================
 Ms::~Ms()
 {}
 
-
-//==============================================================================
-// init                                                                        =
 //==============================================================================
 void Ms::init(const RendererInitializer& initializer)
 {
 	try
 	{
-		// create FBO
-		fbo.create();
-		fbo.bind();
-
-		// inform in what buffers we draw
-		fbo.setNumOfColorAttachements(3);
-
-		// create the FAIs
-
-		Renderer::createFai(r.getWidth(), r.getHeight(), GL_RGB16F,
+		Renderer::createFai(r->getWidth(), r->getHeight(), GL_RGB16F,
 			GL_RGB, GL_FLOAT, normalFai);
-		Renderer::createFai(r.getWidth(), r.getHeight(), GL_RGB8,
+		Renderer::createFai(r->getWidth(), r->getHeight(), GL_RGB8,
 			GL_RGB, GL_FLOAT, diffuseFai);
-		Renderer::createFai(r.getWidth(), r.getHeight(), GL_RGBA8,
+		Renderer::createFai(r->getWidth(), r->getHeight(), GL_RGBA8,
 			GL_RGBA, GL_FLOAT, specularFai);
-		Renderer::createFai(r.getWidth(), r.getHeight(),
+		Renderer::createFai(r->getWidth(), r->getHeight(),
 			GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL,
 			GL_UNSIGNED_INT_24_8, depthFai);
 
-		// attach the buffers to the FBO
-		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
-			GL_TEXTURE_2D, normalFai.getGlId(), 0);
-		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1,
-			GL_TEXTURE_2D, diffuseFai.getGlId(), 0);
-		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2,
-			GL_TEXTURE_2D, specularFai.getGlId(), 0);
-
-		//glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
-		//	GL_TEXTURE_2D, depthFai.getGlId(), 0);
-		//glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
-		//	GL_TEXTURE_2D, depthFai.getGlId(), 0);
-		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT,
-			GL_TEXTURE_2D, depthFai.getGlId(), 0);
-
-		// test if success
-		fbo.checkIfGood();
-
-		// unbind
-		fbo.unbind();
+		fbo.create();
+		fbo.setColorAttachments({&normalFai, &diffuseFai, &specularFai});
+		fbo.setOtherAttachment(GL_DEPTH_STENCIL_ATTACHMENT, depthFai);
 	}
 	catch(std::exception& e)
 	{
@@ -81,58 +39,51 @@ void Ms::init(const RendererInitializer& initializer)
 	ez.init(initializer);
 }
 
-
-//==============================================================================
-// run                                                                         =
 //==============================================================================
 void Ms::run()
 {
-	if(ez.getEnabled())
+	/*if(ez.getEnabled())
 	{
 		ez.run();
-	}
+	}*/
 
 	fbo.bind();
 
-	if(!ez.getEnabled())
+	/*if(!ez.getEnabled())
 	{
 		glClear(GL_DEPTH_BUFFER_BIT);
-	}
+	}*/
 
-	GlStateMachineSingleton::get().setViewport(0, 0,
-		r.getWidth(), r.getHeight());
+	GlStateSingleton::get().setViewport(0, 0, r->getWidth(), r->getHeight());
 
 	//GlStateMachineSingleton::get().enable(GL_DEPTH_TEST, true);
 	//app->getScene().skybox.Render(cam.getViewMatrix().getRotationPart());
 	//glDepthFunc(GL_LEQUAL);
 
 	// if ez then change the default depth test and disable depth writing
-	if(ez.getEnabled())
+	/*if(ez.getEnabled())
 	{
 		glDepthMask(false);
 		glDepthFunc(GL_EQUAL);
-	}
+	}*/
 
 	glClear(GL_COLOR_BUFFER_BIT);
 
 	// render all
-	BOOST_FOREACH(RenderableNode* node,
-		r.getCamera().getVisibleMsRenderableNodes())
+	for(Renderable* node :
+		r->getScene().getVisibilityInfo().getRenderables())
 	{
-		r.getSceneDrawer().renderRenderableNode(r.getCamera(),
+		r->getSceneDrawer().render(r->getScene().getActiveCamera(),
 			0, *node);
 	}
 
 	// restore depth
-	if(ez.getEnabled())
+	/*if(ez.getEnabled())
 	{
 		glDepthMask(true);
 		glDepthFunc(GL_LESS);
-	}
-
-	fbo.unbind();
+	}*/
 	ANKI_CHECK_GL_ERROR();
 }
 
-
 } // end namespace

+ 32 - 69
src/renderer/Pps.cpp

@@ -2,54 +2,36 @@
 #include "anki/renderer/Renderer.h"
 #include "anki/renderer/Hdr.h"
 #include "anki/renderer/Ssao.h"
-#include "anki/renderer/RendererInitializer.h"
-
 
 namespace anki {
 
-
 //==============================================================================
-// Constructor                                                                 =
-//==============================================================================
-Pps::Pps(Renderer& r_)
-:	RenderingPass(r_),
-	hdr(r_),
-	ssao(r_),
-	bl(r_)
+Pps::Pps(Renderer* r_)
+	: RenderingPass(r_), hdr(r_), ssao(r_), bl(r_)
 {}
 
-
-//==============================================================================
-// Destructor                                                                  =
 //==============================================================================
 Pps::~Pps()
 {}
 
-
-//==============================================================================
-// init                                                                        =
 //==============================================================================
-void Pps::init(const RendererInitializer& initializer)
+void Pps::init(const Renderer::Initializer& initializer)
 {
 	ssao.init(initializer);
 	hdr.init(initializer);
 
-	//
 	// Init pre pass
 	//
 
 	// FBO
 	try
 	{
-		prePassFbo.create();
-		prePassFbo.bind();
-		prePassFbo.setNumOfColorAttachements(1);
-		Renderer::createFai(r.getWidth(), r.getHeight(), GL_RGB, GL_RGB,
+		Renderer::createFai(r->getWidth(), r->getHeight(), GL_RGB, GL_RGB,
 			GL_FLOAT, prePassFai);
-		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
-			GL_TEXTURE_2D, prePassFai.getGlId(), 0);
-		prePassFbo.checkIfGood();
-		prePassFbo.unbind();
+
+		prePassFbo.create();
+		prePassFbo.setColorAttachments({&prePassFai});
+		ANKI_ASSERT(prePassFbo.isComplete());
 	}
 	catch(std::exception& e)
 	{
@@ -64,25 +46,20 @@ void Pps::init(const RendererInitializer& initializer)
 		pps += "#define SSAO_ENABLED\n";
 	}
 
-	prePassSProg.load(ShaderProgram::createSrcCodeToCache(
-		"shaders/PpsPrePass.glsl", pps.c_str()).c_str());
+	prePassSProg.load("shaders/PpsPrePass.glsl", pps.c_str());
 
-	//
 	// Init post pass
 	//
 
 	// FBO
 	try
 	{
-		postPassFbo.create();
-		postPassFbo.bind();
-		postPassFbo.setNumOfColorAttachements(1);
-		Renderer::createFai(r.getWidth(), r.getHeight(), GL_RGB, GL_RGB,
+		Renderer::createFai(r->getWidth(), r->getHeight(), GL_RGB, GL_RGB,
 			GL_FLOAT, postPassFai);
-		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
-			GL_TEXTURE_2D, postPassFai.getGlId(), 0);
-		postPassFbo.checkIfGood();
-		postPassFbo.unbind();
+
+		postPassFbo.create();
+		postPassFbo.setColorAttachments({&postPassFai});
+		ANKI_ASSERT(prePassFbo.isComplete());
 	}
 	catch(std::exception& e)
 	{
@@ -92,24 +69,18 @@ void Pps::init(const RendererInitializer& initializer)
 
 	// SProg
 	pps = "";
-
 	if(hdr.getEnabled())
 	{
 		pps += "#define HDR_ENABLED\n";
 	}
 
-	postPassSProg.load(ShaderProgram::createSrcCodeToCache(
-		"shaders/PpsPostPass.glsl", pps.c_str()).c_str());
+	postPassSProg.load("shaders/PpsPostPass.glsl", pps.c_str());
 
-	//
 	// Init Bl after
 	//
 	bl.init(initializer);
 }
 
-
-//==============================================================================
-// runPrePass                                                                  =
 //==============================================================================
 void Pps::runPrePass()
 {
@@ -120,30 +91,26 @@ void Pps::runPrePass()
 
 	prePassFbo.bind();
 
-	GlStateMachineSingleton::get().enable(GL_DEPTH_TEST, false);
-	GlStateMachineSingleton::get().enable(GL_BLEND, false);
-	GlStateMachineSingleton::get().setViewport(0, 0,
-		r.getWidth(), r.getHeight());
+	GlStateSingleton::get().enable(GL_DEPTH_TEST, false);
+	GlStateSingleton::get().enable(GL_BLEND, false);
+	GlStateSingleton::get().setViewport(0, 0,
+		r->getWidth(), r->getHeight());
 
-	prePassSProg->bind();
-	prePassSProg->findUniformVariableByName("isFai").set(r.getIs().getFai(), 0);
+	prePassSProg.bind();
+	prePassSProg.findUniformVariableByName("isFai")->set(r->getIs().getFai());
 
 	if(ssao.getEnabled())
 	{
-		prePassSProg->findUniformVariableByName("ppsSsaoFai").set(
-			ssao.getFai(), 1);
+		prePassSProg.findUniformVariableByName("ppsSsaoFai")->set(
+			ssao.getFai());
 	}
 
-	r.drawQuad();
+	r->drawQuad();
 }
 
-
-//==============================================================================
-// runPostPass                                                                 =
 //==============================================================================
 void Pps::runPostPass()
 {
-	//
 	// The actual pass
 	//
 	if(hdr.getEnabled())
@@ -153,27 +120,23 @@ void Pps::runPostPass()
 
 	postPassFbo.bind();
 
-	GlStateMachineSingleton::get().enable(GL_DEPTH_TEST, false);
-	GlStateMachineSingleton::get().enable(GL_BLEND, false);
-	GlStateMachineSingleton::get().setViewport(0, 0,
-		r.getWidth(), r.getHeight());
+	GlStateSingleton::get().enable(GL_DEPTH_TEST, false);
+	GlStateSingleton::get().enable(GL_BLEND, false);
+	GlStateSingleton::get().setViewport(0, 0, r->getWidth(), r->getHeight());
+
+	postPassSProg.bind();
+	postPassSProg.findUniformVariableByName("ppsPrePassFai")->set(prePassFai);
 
-	postPassSProg->bind();
-	postPassSProg->findUniformVariableByName("ppsPrePassFai").set(
-		prePassFai, 0);
 	if(hdr.getEnabled())
 	{
-		postPassSProg->findUniformVariableByName("ppsHdrFai").set(
-			hdr.getFai(), 1);
+		postPassSProg.findUniformVariableByName("ppsHdrFai")->set(hdr.getFai());
 	}
 
-	r.drawQuad();
+	r->drawQuad();
 
-	//
 	// Blurring
 	//
 	bl.run();
 }
 
-
 } // end namespace

+ 27 - 32
src/renderer/Renderer.cpp

@@ -1,33 +1,29 @@
 #include "anki/renderer/Renderer.h"
-#include "anki/renderer/RendererInitializer.h"
 #include "anki/util/Exception.h"
 #include "anki/scene/Camera.h"
-
+#include "anki/scene/Scene.h"
 
 namespace anki {
 
-
 //==============================================================================
 Renderer::Renderer()
-	: ms(*this), is(*this), pps(*this), bs(*this), width(640), height(480),
+	: ms(this), is(this), pps(this), bs(this), width(640), height(480),
 		sceneDrawer(this)
 {
 	enableStagesProfilingFlag = false;
-	lodDistance = 10.0;
 }
 
-
 //==============================================================================
 Renderer::~Renderer()
 {}
 
-
 //==============================================================================
 void Renderer::init(const RendererInitializer& initializer)
 {
 	// set from the initializer
 	width = initializer.width;
 	height = initializer.height;
+	lodDistance = initializer.lodDistance;
 	framesNum = 0;
 
 	// a few sanity checks
@@ -44,7 +40,7 @@ void Renderer::init(const RendererInitializer& initializer)
 
 	// quad VBOs and VAO
 	float quadVertCoords[][2] = {{1.0, 1.0}, {0.0, 1.0}, {0.0, 0.0},
-		{1.0, 0.0}};
+		{1.0, 0.0}}; /// XXX change them to NDC
 	quadPositionsVbo.create(GL_ARRAY_BUFFER, sizeof(quadVertCoords),
 		quadVertCoords, GL_STATIC_DRAW);
 
@@ -58,51 +54,56 @@ void Renderer::init(const RendererInitializer& initializer)
 	quadVao.attachElementArrayBufferVbo(quadVertIndecesVbo);
 
 	// Other
-	msTq.reset(new TimeQuery);
-	isTq.reset(new TimeQuery);
-	ppsTq.reset(new TimeQuery);
-	bsTq.reset(new TimeQuery);
+	msTq.reset(new Query(GL_TIME_ELAPSED));
+	isTq.reset(new Query(GL_TIME_ELAPSED));
+	ppsTq.reset(new Query(GL_TIME_ELAPSED));
+	bsTq.reset(new Query(GL_TIME_ELAPSED));
 }
 
-
 //==============================================================================
-void Renderer::render(Camera& cam_)
+void Renderer::render(Scene& scene_)
 {
-	cam = &cam_;
+	scene = &scene_;
+	const Camera& cam = scene->getActiveCamera();
 
-	//
 	// Calc a few vars
 	//
-	calcPlanes(Vec2(cam->getNear(), cam->getFar()), planes);
+	calcPlanes(Vec2(cam.getNear(), cam.getFar()), planes);
 
-	ANKI_ASSERT(cam->getCameraType() == Camera::CT_PERSPECTIVE);
-	const PerspectiveCamera& pcam = static_cast<const PerspectiveCamera&>(*cam);
+	ANKI_ASSERT(cam.getCameraType() == Camera::CT_PERSPECTIVE);
+	const PerspectiveCamera& pcam = static_cast<const PerspectiveCamera&>(cam);
 	calcLimitsOfNearPlane(pcam, limitsOfNearPlane);
 	limitsOfNearPlane2 = limitsOfNearPlane * 2.0;
 
-	viewProjectionMat = cam->getProjectionMatrix() * cam->getViewMatrix();
+	viewProjectionMat = cam.getProjectionMatrix() * cam.getViewMatrix();
 
 	if(enableStagesProfilingFlag)
 	{
 		msTq->begin();
 		ms.run();
-		msTime = msTq->end();
+		msTq->end();
 
 		isTq->begin();
 		is.run();
-		isTime = isTq->end();
+		isTq->end();
 
 		ppsTq->begin();
 		pps.runPrePass();
-		ppsTime = ppsTq->end();
+		ppsTq->end();
 
 		bsTq->begin();
 		bs.run();
-		bsTime = bsTq->end();
+		bsTq->end();
 
-		ppsTq->begin();
+		pps2Tq->begin();
 		pps.runPostPass();
-		ppsTime += ppsTq->end();
+		pps2Tq->end();
+
+		// Now wait
+		msTime = msTq->getResult();
+		isTime = isTq->getResult();
+		bsTime = bsTq->getResult();
+		ppsTime = ppsTq->getResult() + ppsTq->getResult();
 	}
 	else
 	{
@@ -116,7 +117,6 @@ void Renderer::render(Camera& cam_)
 	++framesNum;
 }
 
-
 //==============================================================================
 void Renderer::drawQuad()
 {
@@ -124,7 +124,6 @@ void Renderer::drawQuad()
 	glDrawElements(GL_TRIANGLES, 2 * 3, GL_UNSIGNED_SHORT, 0);
 }
 
-
 //==============================================================================
 Vec3 Renderer::unproject(const Vec3& windowCoords, const Mat4& modelViewMat,
 	const Mat4& projectionMat, const int view[4])
@@ -144,7 +143,6 @@ Vec3 Renderer::unproject(const Vec3& windowCoords, const Mat4& modelViewMat,
 	return Vec3(final);
 }
 
-
 //==============================================================================
 void Renderer::createFai(uint width, uint height, int internalFormat,
 	int format, int type, Texture& fai)
@@ -164,7 +162,6 @@ void Renderer::createFai(uint width, uint height, int internalFormat,
 	fai.create(init);
 }
 
-
 //==============================================================================
 void Renderer::calcPlanes(const Vec2& cameraRange, Vec2& planes)
 {
@@ -175,7 +172,6 @@ void Renderer::calcPlanes(const Vec2& cameraRange, Vec2& planes)
 	planes.y() = (zFar * zNear) / (zNear -zFar);
 }
 
-
 //==============================================================================
 void Renderer::calcLimitsOfNearPlane(const PerspectiveCamera& pcam,
 	Vec2& limitsOfNearPlane)
@@ -185,5 +181,4 @@ void Renderer::calcLimitsOfNearPlane(const PerspectiveCamera& pcam,
 		* (pcam.getFovX() / pcam.getFovY());
 }
 
-
 } // end namespace

+ 26 - 63
src/renderer/Sm.cpp

@@ -1,20 +1,13 @@
-#include <boost/foreach.hpp>
 #include "anki/renderer/Sm.h"
 #include "anki/renderer/Renderer.h"
 #include "anki/core/App.h"
-#include "anki/scene/Scene.h"
 #include "anki/resource/LightRsrc.h"
+#include "anki/scene/Scene.h"
 #include "anki/scene/Camera.h"
 #include "anki/scene/Light.h"
-#include "anki/scene/SpotLight.h"
-#include "anki/renderer/RendererInitializer.h"
-
 
 namespace anki {
 
-
-//==============================================================================
-// init                                                                        =
 //==============================================================================
 void Sm::init(const RendererInitializer& initializer)
 {
@@ -32,7 +25,7 @@ void Sm::init(const RendererInitializer& initializer)
 
 	// Init the levels
 	initLevel(resolution, level0Distance, bilinearEnabled, levels[0]);
-	for(uint i = 1; i < levels.size(); i++)
+	for(uint32_t i = 1; i < levels.size(); i++)
 	{
 		initLevel(levels[i - 1].resolution / 2,
 			levels[i - 1].distance * 2.0,
@@ -41,11 +34,9 @@ void Sm::init(const RendererInitializer& initializer)
 	}
 }
 
-
-//==============================================================================
-// initLevel                                                                   =
 //==============================================================================
-void Sm::initLevel(uint resolution, float distance, bool bilinear, Level& level)
+void Sm::initLevel(uint32_t resolution, float distance, bool bilinear,
+	Level& level)
 {
 	level.resolution = resolution;
 	level.distance = distance;
@@ -53,13 +44,10 @@ void Sm::initLevel(uint resolution, float distance, bool bilinear, Level& level)
 
 	try
 	{
-		// create FBO
-		level.fbo.create();
-		level.fbo.bind();
-
-		// texture
+		// Init texture
 		Renderer::createFai(level.resolution, level.resolution,
 			GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_FLOAT, level.shadowMap);
+
 		if(level.bilinear)
 		{
 			level.shadowMap.setFiltering(Texture::TFT_LINEAR);
@@ -79,43 +67,28 @@ void Sm::initLevel(uint resolution, float distance, bool bilinear, Level& level)
 		Dt = shadow2D(shadow_depth_map, _shadow_uv).r (see lp_generic.frag).
 		Hardware filters like GL_LINEAR cannot be applied.*/
 
-		// inform the we wont write to color buffers
-		level.fbo.setNumOfColorAttachements(0);
-
-		// attach the texture
-		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
-			GL_TEXTURE_2D, level.shadowMap.getGlId(), 0);
-
-		// test if success
-		level.fbo.checkIfGood();
-
-		// unbind
-		level.fbo.unbind();
+		// create FBO
+		level.fbo.create();
+		level.fbo.setOtherAttachment(GL_DEPTH_ATTACHMENT, level.shadowMap);
 	}
 	catch(std::exception& e)
 	{
-		throw ANKI_EXCEPTION("Cannot create shadowmapping "
-			"FBO") << e;
+		throw ANKI_EXCEPTION("Cannot create shadowmapping FBO") << e;
 	}
 }
 
-
-//==============================================================================
-// run                                                                         =
 //==============================================================================
 void Sm::run(Light& light, float distance)
 {
-	if(!enabled)
+	if(!enabled || !light.getShadowEnabled()
+		|| light.getLightType() == Light::LT_POINT)
 	{
 		return;
 	}
 
-	ANKI_ASSERT(light.getVisibleMsRenderableNodes().size() > 0);
-
-	//
 	// Determine the level
 	//
-	BOOST_FOREACH(Level& level, levels)
+	for(Level& level : levels)
 	{
 		crntLevel = &level;
 		if(distance < level.distance)
@@ -124,7 +97,6 @@ void Sm::run(Light& light, float distance)
 		}
 	}
 
-	//
 	// Render
 	//
 
@@ -132,43 +104,34 @@ void Sm::run(Light& light, float distance)
 	crntLevel->fbo.bind();
 
 	// set GL
-	GlStateMachineSingleton::get().setViewport(0, 0,
+	GlStateSingleton::get().setViewport(0, 0,
 		crntLevel->resolution, crntLevel->resolution);
 	glClear(GL_DEPTH_BUFFER_BIT);
 
 	// disable color & blend & enable depth test
 	glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
-	GlStateMachineSingleton::get().enable(GL_DEPTH_TEST, true);
-	GlStateMachineSingleton::get().enable(GL_BLEND, false);
+	GlStateSingleton::get().enable(GL_DEPTH_TEST);
+	GlStateSingleton::get().disable(GL_BLEND);
 
 	// for artifacts
 	glPolygonOffset(2.0, 2.0); // keep the values as low as possible!!!!
-	GlStateMachineSingleton::get().enable(GL_POLYGON_OFFSET_FILL);
+	GlStateSingleton::get().enable(GL_POLYGON_OFFSET_FILL);
+
+	// Visibility tests
+	SpotLight& slight = static_cast<SpotLight&>(light);
+	VisibilityInfo vi;
+	VisibilityTester vt;
+	vt.test(slight, r->getScene(), vi);
 
 	// render all
-	BOOST_FOREACH(RenderableNode* node, light.getVisibleMsRenderableNodes())
+	for(Renderable* node : vi.getRenderables())
 	{
-		switch(light.getLightType())
-		{
-			case Light::LT_SPOT:
-			{
-				const SpotLight& sl = static_cast<const SpotLight&>(light);
-				r.getSceneDrawer().renderRenderableNode(sl.getCamera(),
-					1, *node);
-				break;
-			}
-
-			default:
-				ANKI_ASSERT(0);
-		}
+		r->getSceneDrawer().render(r->getScene().getActiveCamera(), 1, *node);
 	}
 
 	// restore GL
-	GlStateMachineSingleton::get().disable(GL_POLYGON_OFFSET_FILL);
+	GlStateSingleton::get().disable(GL_POLYGON_OFFSET_FILL);
 	glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
-
-	// FBO
-	crntLevel->fbo.unbind();
 }
 
 

+ 0 - 5
src/renderer/Smo.cpp

@@ -2,25 +2,20 @@
 #include "anki/renderer/Renderer.h"
 #include "anki/scene/Light.h"
 
-
 namespace anki {
 
-
 //==============================================================================
 Smo::~Smo()
 {}
 
-
 //==============================================================================
 void Smo::init(const RendererInitializer& /*initializer*/)
 {
 }
 
-
 //==============================================================================
 void Smo::run(const Light& light) 
 {
 }
 
-
 } // end namespace

+ 42 - 90
src/renderer/Ssao.cpp

@@ -2,42 +2,19 @@
 #include "anki/renderer/Ssao.h"
 #include "anki/renderer/Renderer.h"
 #include "anki/scene/Camera.h"
-#include "anki/renderer/RendererInitializer.h"
-#include "anki/scene/PerspectiveCamera.h"
-
+#include "anki/scene/Scene.h"
 
 namespace anki {
 
-
-//==============================================================================
-// createFbo                                                                   =
 //==============================================================================
 void Ssao::createFbo(Fbo& fbo, Texture& fai)
 {
 	try
 	{
-		int width = renderingQuality * r.getWidth();
-		int height = renderingQuality * r.getHeight();
-
-		// create
-		fbo.create();
-		fbo.bind();
-
-		// inform in what buffers we draw
-		fbo.setNumOfColorAttachements(1);
-
-		// create the texes
 		Renderer::createFai(width, height, GL_RED, GL_RED, GL_FLOAT, fai);
 
-		// attach
-		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
-			GL_TEXTURE_2D, fai.getGlId(), 0);
-
-		// test if success
-		fbo.checkIfGood();
-
-		// unbind
-		fbo.unbind();
+		fbo.create();
+		fbo.setColorAttachments({&fai});
 	}
 	catch(std::exception& e)
 	{
@@ -46,9 +23,6 @@ void Ssao::createFbo(Fbo& fbo, Texture& fai)
 	}
 }
 
-
-//==============================================================================
-// init                                                                        =
 //==============================================================================
 void Ssao::init(const RendererInitializer& initializer)
 {
@@ -62,12 +36,14 @@ void Ssao::init(const RendererInitializer& initializer)
 	renderingQuality = initializer.pps.ssao.renderingQuality;
 	blurringIterationsNum = initializer.pps.ssao.blurringIterationsNum;
 
+	width = renderingQuality * r->getWidth();
+	height = renderingQuality * r->getHeight();
+
 	// create FBOs
 	createFbo(ssaoFbo, ssaoFai);
 	createFbo(hblurFbo, hblurFai);
 	createFbo(vblurFbo, fai);
 
-	//
 	// Shaders
 	//
 
@@ -77,27 +53,19 @@ void Ssao::init(const RendererInitializer& initializer)
 	// blurring progs
 	const char* SHADER_FILENAME = "shaders/GaussianBlurGeneric.glsl";
 
-	std::string pps = "#define HPASS\n#define COL_R\n";
-	hblurSProg.load(
-		ShaderProgram::createSrcCodeToCache(SHADER_FILENAME, 
-		pps.c_str()).c_str());
+	std::string pps = "#define HPASS\n#define COL_R\n#define IMG_DIMENSION "
+		+ std::to_string(width) + ".0\n";
+	hblurSProg.load(SHADER_FILENAME, pps.c_str());
 
-	pps = "#define VPASS\n#define COL_R\n";
-	vblurSProg.load(
-		ShaderProgram::createSrcCodeToCache(SHADER_FILENAME, 
-		pps.c_str()).c_str());
+	pps = "#define VPASS\n#define COL_R\n#define IMG_DIMENSION "
+		+ std::to_string(width) + ".0 \n";
+	vblurSProg.load(SHADER_FILENAME, pps.c_str());
 
-	//
 	// noise map
 	//
-
 	noiseMap.load("engine-rsrc/noise.png");
-	noiseMap->setRepeat(true);
 }
 
-
-//==============================================================================
-// run                                                                         =
 //==============================================================================
 void Ssao::run()
 {
@@ -106,94 +74,78 @@ void Ssao::run()
 		return;
 	}
 
-	int width = renderingQuality * r.getWidth();
-	int height = renderingQuality * r.getHeight();
-	const Camera& cam = r.getCamera();
+	const Camera& cam = r->getScene().getActiveCamera();
 
-	GlStateMachineSingleton::get().enable(GL_BLEND, false);
-	GlStateMachineSingleton::get().enable(GL_DEPTH_TEST, false);
+	GlStateSingleton::get().disable(GL_BLEND);
+	GlStateSingleton::get().disable(GL_DEPTH_TEST);
+	GlStateSingleton::get().setViewport(0, 0, width, height);
 
-
-	GlStateMachineSingleton::get().setViewport(0, 0, width, height);
-
-	//
 	// 1st pass
 	//
 	
 	ssaoFbo.bind();
-	ssaoSProg->bind();
+	ssaoSProg.bind();
 	
 	// planes
-	ssaoSProg->findUniformVariableByName("planes").set(r.getPlanes());
+	ssaoSProg.findUniformVariableByName("planes")->set(r->getPlanes());
 
 	// limitsOfNearPlane
-	ssaoSProg->findUniformVariableByName("limitsOfNearPlane").set(
-		r.getLimitsOfNearPlane());
+	ssaoSProg.findUniformVariableByName("limitsOfNearPlane")->set(
+		r->getLimitsOfNearPlane());
 
 	// limitsOfNearPlane2
-	ssaoSProg->findUniformVariableByName("limitsOfNearPlane2").set(
-		r.getLimitsOfNearPlane2());
+	ssaoSProg.findUniformVariableByName("limitsOfNearPlane2")->set(
+		r->getLimitsOfNearPlane2());
 
 	// zNear
-	float zNear = cam.getZNear();
-	ssaoSProg->findUniformVariableByName("zNear").set(zNear);
+	ssaoSProg.findUniformVariableByName("zNear")->set(cam.getNear());
 
 	// msDepthFai
-	ssaoSProg->findUniformVariableByName("msDepthFai").set(
-		r.getMs().getDepthFai(), 0);
+	ssaoSProg.findUniformVariableByName("msDepthFai")->set(
+		r->getMs().getDepthFai());
 
 	// noiseMap
-	ssaoSProg->findUniformVariableByName("noiseMap").set(*noiseMap, 1);
+	ssaoSProg.findUniformVariableByName("noiseMap")->set(*noiseMap);
 
 	// noiseMapSize
-	float noiseMapSize = noiseMap->getWidth();
-	ssaoSProg->findUniformVariableByName("noiseMapSize").set(noiseMapSize);
+	ssaoSProg.findUniformVariableByName("noiseMapSize")->set(
+		noiseMap->getWidth());
 
 	// screenSize
 	Vec2 screenSize(width * 2, height * 2);
-	ssaoSProg->findUniformVariableByName("screenSize").set(screenSize);
+	ssaoSProg.findUniformVariableByName("screenSize")->set(screenSize);
 
 	// msNormalFai
-	ssaoSProg->findUniformVariableByName("msNormalFai").set(
-		r.getMs().getNormalFai(), 2);
+	ssaoSProg.findUniformVariableByName("msNormalFai")->set(
+		r->getMs().getNormalFai());
 
-	r.drawQuad();
+	r->drawQuad();
 
+	vblurSProg.bind();
+	vblurSProg.findUniformVariableByName("img")->set(hblurFai);
 
-	//
 	// Blurring passes
 	//
-	hblurFai.setRepeat(false);
-	fai.setRepeat(false);
-	for(uint i = 0; i < blurringIterationsNum; i++)
+	for(uint32_t i = 0; i < blurringIterationsNum; i++)
 	{
 		// hpass
 		hblurFbo.bind();
-		hblurSProg->bind();
+		hblurSProg.bind();
 		if(i == 0)
 		{
-			hblurSProg->findUniformVariableByName("img").set(ssaoFai, 0);
+			hblurSProg.findUniformVariableByName("img")->set(ssaoFai);
 		}
-		else
+		else if(i == 1)
 		{
-			hblurSProg->findUniformVariableByName("img").set(fai, 0);
+			hblurSProg.findUniformVariableByName("img")->set(fai);
 		}
-		float tmp = width;
-		hblurSProg->findUniformVariableByName("imgDimension").set(tmp);
-		r.drawQuad();
+		r->drawQuad();
 
 		// vpass
 		vblurFbo.bind();
-		vblurSProg->bind();
-		vblurSProg->findUniformVariableByName("img").set(hblurFai, 0);
-		tmp = height;
-		vblurSProg->findUniformVariableByName("imgDimension").set(tmp);
-		r.drawQuad();
+		vblurSProg.bind();
+		r->drawQuad();
 	}
-
-	// end
-	glBindFramebuffer(GL_FRAMEBUFFER, 0); // Bind the window framebuffer
 }
 
-
 } // end namespace

+ 15 - 6
src/resource/ShaderProgramResource.cpp

@@ -11,13 +11,19 @@ namespace anki {
 
 //==============================================================================
 void ShaderProgramResource::load(const char* filename)
+{
+	load(filename, "");
+}
+
+//==============================================================================
+void ShaderProgramResource::load(const char* filename, const char* extraSrc)
 {
 	ShaderProgramPrePreprocessor pars(filename);
 
 	std::array<const char*, 128> trfVarsArr = {{nullptr}};
 	if(pars.getTranformFeedbackVaryings().size() > 0)
 	{
-		uint i;
+		uint32_t i;
 		for(i = 0; i < pars.getTranformFeedbackVaryings().size(); i++)
 		{
 			trfVarsArr[i] = pars.getTranformFeedbackVaryings()[i].c_str();
@@ -25,11 +31,14 @@ void ShaderProgramResource::load(const char* filename)
 		trfVarsArr[i] = nullptr;
 	}
 
-	create(pars.getShaderSource(ST_VERTEX).c_str(), 
-		nullptr, 
-		nullptr, 
-		nullptr, 
-		pars.getShaderSource(ST_FRAGMENT).c_str(),
+	std::string vertSrc = extraSrc + pars.getShaderSource(ST_VERTEX);
+	std::string fragSrc = extraSrc + pars.getShaderSource(ST_FRAGMENT);
+
+	create(vertSrc.c_str(),
+		nullptr,
+		nullptr,
+		nullptr,
+		fragSrc.c_str(),
 		&trfVarsArr[0]);
 }
 

+ 0 - 8
src/scene/Scene.cpp

@@ -3,22 +3,18 @@
 #include "anki/util/Exception.h"
 #include "anki/scene/VisibilityTester.h"
 
-
 namespace anki {
 
-
 //==============================================================================
 Scene::Scene()
 {
 	ambientCol = Vec3(0.1, 0.05, 0.05) * 4;
 }
 
-
 //==============================================================================
 Scene::~Scene()
 {}
 
-
 //==============================================================================
 void Scene::registerNode(SceneNode* node)
 {
@@ -26,7 +22,6 @@ void Scene::registerNode(SceneNode* node)
 	addDict(nameToNode, node);
 }
 
-
 //==============================================================================
 void Scene::unregisterNode(SceneNode* node)
 {
@@ -34,7 +29,6 @@ void Scene::unregisterNode(SceneNode* node)
 	removeDict(nameToNode, node);
 }
 
-
 //==============================================================================
 void Scene::update(float prevUpdateTime, float crntTime, int frame)
 {
@@ -44,7 +38,6 @@ void Scene::update(float prevUpdateTime, float crntTime, int frame)
 	}
 }
 
-
 //==============================================================================
 void Scene::doVisibilityTests(Camera& cam)
 {
@@ -52,5 +45,4 @@ void Scene::doVisibilityTests(Camera& cam)
 	vtester.test(f, *this, vinfo);
 }
 
-
 } // end namespace

+ 26 - 33
src/script/ScriptManager.cpp

@@ -1,58 +1,53 @@
 #include "anki/script/ScriptManager.h"
 #include "anki/util/Exception.h"
 #include "anki/core/Logger.h"
-#include "anki/core/Globals.h"
 #include "anki/script/Common.h"
 #include <Python.h>
 
-
 using namespace boost;
 using namespace boost::python;
 
-
 /// Define the classes
 BOOST_PYTHON_MODULE(anki)
 {
-	CALL_WRAP(HighRezTimer);
+	ANKI_CALL_WRAP(HighRezTimer);
 
-	CALL_WRAP(Vec2);
-	CALL_WRAP(Vec3);
-	CALL_WRAP(Vec4);
+	ANKI_CALL_WRAP(Vec2);
+	ANKI_CALL_WRAP(Vec3);
+	ANKI_CALL_WRAP(Vec4);
 
-	CALL_WRAP(Logger);
+	ANKI_CALL_WRAP(Logger);
 
-	CALL_WRAP(SceneNode);
-	CALL_WRAP(Camera);
-	CALL_WRAP(MaterialRuntimeVariable);
-	CALL_WRAP(MaterialRuntime);
-	CALL_WRAP(PatchNode);
-	CALL_WRAP(ModelPatchNode);
-	CALL_WRAP(ModelNode);
-	CALL_WRAP(Scene);
+	ANKI_CALL_WRAP(SceneNode);
+	ANKI_CALL_WRAP(Camera);
+	ANKI_CALL_WRAP(MaterialRuntimeVariable);
+	ANKI_CALL_WRAP(MaterialRuntime);
+	ANKI_CALL_WRAP(PatchNode);
+	ANKI_CALL_WRAP(ModelPatchNode);
+	ANKI_CALL_WRAP(ModelNode);
+	ANKI_CALL_WRAP(Scene);
 
-	CALL_WRAP(SwitchableRenderingPass);
-	CALL_WRAP(Hdr);
-	CALL_WRAP(Bl);
-	CALL_WRAP(Pps);
-	CALL_WRAP(Renderer);
-	CALL_WRAP(Dbg);
-	CALL_WRAP(MainRenderer);
+	ANKI_CALL_WRAP(SwitchableRenderingPass);
+	ANKI_CALL_WRAP(Hdr);
+	ANKI_CALL_WRAP(Bl);
+	ANKI_CALL_WRAP(Pps);
+	ANKI_CALL_WRAP(Renderer);
+	ANKI_CALL_WRAP(Dbg);
+	ANKI_CALL_WRAP(MainRenderer);
 
-	CALL_WRAP(SceneColorEvent);
-	CALL_WRAP(MainRendererPpsHdrEvent);
-	CALL_WRAP(EventManager);
+	ANKI_CALL_WRAP(SceneColorEvent);
+	ANKI_CALL_WRAP(MainRendererPpsHdrEvent);
+	ANKI_CALL_WRAP(EventManager);
 
-	CALL_WRAP(App);
+	ANKI_CALL_WRAP(App);
 
-	CALL_WRAP(Input);
+	ANKI_CALL_WRAP(Input);
 
-	CALL_WRAP(AllGlobals);
+	ANKI_CALL_WRAP(AllGlobals);
 }
 
-
 namespace anki {
 
-
 //==============================================================================
 void ScriptManager::init()
 {
@@ -67,7 +62,6 @@ void ScriptManager::init()
 	ANKI_LOGI("Scripting engine initialized");
 }
 
-
 //==============================================================================
 void ScriptManager::execScript(const char* script, const char* scriptName)
 {
@@ -83,5 +77,4 @@ void ScriptManager::execScript(const char* script, const char* scriptName)
 	}
 }
 
-
 } // end namespace

+ 1 - 2
src/script/core/App.cpp

@@ -1,8 +1,7 @@
 #include "anki/script/Common.h"
 #include "anki/core/App.h"
 
-
-WRAP(App)
+ANKI_WRAP(App)
 {
 	class_<App, noncopyable>("App", no_init)
 		.def("quit", &App::quit)

+ 5 - 6
src/script/core/Logger.cpp

@@ -1,17 +1,16 @@
 #include "anki/script/Common.h"
 #include "anki/core/Logger.h"
 
-
-WRAP(Logger)
+ANKI_WRAP(Logger)
 {
 	scope loggerScope(
 	class_<Logger, noncopyable>("Logger", no_init)
 		.def("write", &Logger::write)
 	);
 
-	enum_<Logger::MessageType>("MessageType")
-		.value("MT_NORMAL", Logger::MT_NORMAL)
-		.value("MT_ERROR", Logger::MT_ERROR)
-		.value("MT_WARNING", Logger::MT_WARNING)
+	enum_<Logger::LoggerMessageType>("LoggerMessageType")
+		.value("LMT_NORMAL", Logger::LMT_NORMAL)
+		.value("LMT_ERROR", Logger::LMT_ERROR)
+		.value("LMT_WARNING", Logger::LMT_WARNING)
 	;
 }

+ 1 - 2
src/script/event/EventManager.cpp

@@ -4,8 +4,7 @@
 #include "anki/event/SceneColorEvent.h"
 #include "anki/event/MainRendererPpsHdrEvent.h"
 
-
-WRAP(EventManager)
+ANKI_WRAP(EventManager)
 {
 	class_<EventManager, noncopyable>("EventManager", no_init)
 		.def("createEvent", &EventManager::createEvent<SceneColorEvent>,

+ 1 - 2
src/script/event/MainRendererPpsHdrEvent.cpp

@@ -1,8 +1,7 @@
 #include "anki/script/Common.h"
 #include "anki/event/MainRendererPpsHdrEvent.h"
 
-
-WRAP(MainRendererPpsHdrEvent)
+ANKI_WRAP(MainRendererPpsHdrEvent)
 {
 	class_<MainRendererPpsHdrEvent>("MainRendererPpsHdrEvent", no_init)
 		.def(init<float, float, float, uint, float>())

+ 1 - 2
src/script/event/SceneColorEvent.cpp

@@ -1,8 +1,7 @@
 #include "anki/script/Common.h"
 #include "anki/event/SceneColorEvent.h"
 
-
-WRAP(SceneColorEvent)
+ANKI_WRAP(SceneColorEvent)
 {
 	class_<SceneColorEvent>("SceneColorEvent", no_init)
 		.def(init<float, float, const Vec3&>())

+ 1 - 2
src/script/input/Input.cpp

@@ -1,8 +1,7 @@
 #include "anki/script/Common.h"
 #include "anki/input/Input.h"
 
-
-WRAP(Input)
+ANKI_WRAP(Input)
 {
 	class_<Input, noncopyable>("Input", no_init)
 		.def("getWarpMouse", (bool (Input::*)() const)(&Input::getWarpMouse))

+ 4 - 5
src/script/math/Vec2.cpp

@@ -1,8 +1,7 @@
-#include "anki/script/math/Common.h"
+#include "anki/script/MathCommon.h"
 #include "anki/math/Math.h"
 
-
-WRAP(Vec2)
+ANKI_WRAP(Vec2)
 {
 	class_<Vec2>("Vec2")
 		// constructors
@@ -13,8 +12,8 @@ WRAP(Vec2)
 		.def(init<const Vec3&>())
 		.def(init<const Vec4&>())
 		// Accessors
-		BP_PROPERTY_MATH(Vec2, x)
-		BP_PROPERTY_MATH(Vec2, y)
+		ANKI_BP_PROPERTY_MATH(Vec2, x)
+		ANKI_BP_PROPERTY_MATH(Vec2, y)
 		// ops with same type
 		.def(self + self)
 		.def(self += self)

+ 5 - 6
src/script/math/Vec3.cpp

@@ -1,8 +1,7 @@
-#include "anki/script/math/Common.h"
+#include "anki/script/MathCommon.h"
 #include "anki/math/Math.h"
 
-
-WRAP(Vec3)
+ANKI_WRAP(Vec3)
 {
 	class_<Vec3>("Vec3")
 		// Constructors
@@ -14,9 +13,9 @@ WRAP(Vec3)
 		.def(init<const Vec4&>())
 		.def(init<const Quat&>())
 		// Accessors
-		BP_PROPERTY_MATH(Vec3, x)
-		BP_PROPERTY_MATH(Vec3, y)
-		BP_PROPERTY_MATH(Vec3, z)
+		ANKI_BP_PROPERTY_MATH(Vec3, x)
+		ANKI_BP_PROPERTY_MATH(Vec3, y)
+		ANKI_BP_PROPERTY_MATH(Vec3, z)
 		// ops with self
 		.def(self + self) // +
 		.def(self += self) // +=

+ 6 - 7
src/script/math/Vec4.cpp

@@ -1,8 +1,7 @@
-#include "anki/script/math/Common.h"
+#include "anki/script/MathCommon.h"
 #include "anki/math/Math.h"
 
-
-WRAP(Vec4)
+ANKI_WRAP(Vec4)
 {
 	class_<Vec4>("Vec4")
 		// constructors
@@ -14,10 +13,10 @@ WRAP(Vec4)
 		.def(init<const Vec4&>())
 		.def(init<const Quat&>())
 		// Accessors
-		BP_PROPERTY_MATH(Vec4, x)
-		BP_PROPERTY_MATH(Vec4, y)
-		BP_PROPERTY_MATH(Vec4, z)
-		BP_PROPERTY_MATH(Vec4, w)
+		ANKI_BP_PROPERTY_MATH(Vec4, x)
+		ANKI_BP_PROPERTY_MATH(Vec4, y)
+		ANKI_BP_PROPERTY_MATH(Vec4, z)
+		ANKI_BP_PROPERTY_MATH(Vec4, w)
 		// ops with self
 		.def(self + self) // +
 		.def(self += self) // +=

+ 1 - 2
src/script/renderer/Bl.cpp

@@ -1,8 +1,7 @@
 #include "anki/script/Common.h"
 #include "anki/renderer/Bl.h"
 
-
-WRAP(Bl)
+ANKI_WRAP(Bl)
 {
 	class_<Bl, noncopyable>("Bl", no_init)
 		.def("getEnabled", (bool (Bl::*)() const)(&Bl::getEnabled))

+ 1 - 2
src/script/renderer/Dbg.cpp

@@ -1,8 +1,7 @@
 #include "anki/script/Common.h"
 #include "anki/renderer/Dbg.h"
 
-
-WRAP(Dbg)
+ANKI_WRAP(Dbg)
 {
 	class_<Dbg, bases<SwitchableRenderingPass>, noncopyable>("Dbg", no_init)
 	;

+ 1 - 2
src/script/renderer/Hdr.cpp

@@ -1,8 +1,7 @@
 #include "anki/script/Common.h"
 #include "anki/renderer/Hdr.h"
 
-
-WRAP(Hdr)
+ANKI_WRAP(Hdr)
 {
 	class_<Hdr, noncopyable>("Hdr", no_init)
 		.def("getBlurringIterationsNum", (uint (Hdr::*)() const)(

+ 2 - 2
src/script/renderer/MainRenderer.cpp

@@ -1,9 +1,9 @@
 #include "anki/script/Common.h"
 #include "anki/renderer/MainRenderer.h"
 #include "anki/renderer/Dbg.h"
+#include "anki/renderer/Deformer.h"
 
-
-WRAP(MainRenderer)
+ANKI_WRAP(MainRenderer)
 {
 	class_<MainRenderer, bases<Renderer>, noncopyable>("MainRenderer",
 		no_init)

+ 1 - 2
src/script/renderer/Pps.cpp

@@ -3,8 +3,7 @@
 #include "anki/renderer/Hdr.h"
 #include "anki/renderer/Bl.h"
 
-
-WRAP(Pps)
+ANKI_WRAP(Pps)
 {
 	class_<Pps, noncopyable>("Pps", no_init)
 		.def("getHdr", (Hdr& (Pps::*)())(&Pps::getHdr),

+ 1 - 2
src/script/renderer/Renderer.cpp

@@ -1,8 +1,7 @@
 #include "anki/script/Common.h"
 #include "anki/renderer/Renderer.h"
 
-
-WRAP(Renderer)
+ANKI_WRAP(Renderer)
 {
 	typedef Pps& (Renderer::* getPpsAccessor)();
 

+ 1 - 2
src/script/renderer/RenderingPass.cpp

@@ -1,8 +1,7 @@
 #include "anki/script/Common.h"
 #include "anki/renderer/RenderingPass.h"
 
-
-WRAP(SwitchableRenderingPass)
+ANKI_WRAP(SwitchableRenderingPass)
 {
 	class_<SwitchableRenderingPass, noncopyable>("SwitchableRenderingPass",
 		no_init)

+ 1 - 2
src/script/scene/Camera.cpp

@@ -1,8 +1,7 @@
 #include "anki/script/Common.h"
 #include "anki/scene/Camera.h"
 
-
-WRAP(Camera)
+ANKI_WRAP(Camera)
 {
 	class_<Camera, bases<SceneNode>, noncopyable>("Camera", no_init)
 		/*.def("setFovX", &Camera::setFovX)

+ 0 - 31
src/script/scene/MaterialRuntime.cpp

@@ -1,31 +0,0 @@
-#include "anki/script/Common.h"
-#include "anki/scene/MaterialRuntime.h"
-
-
-WRAP(MaterialRuntimeVariable)
-{
-	class_<MaterialRuntimeVariable, noncopyable>("MaterialRuntimeVariable",
-		no_init)
-		/*.def("setValue", (void (MaterialRuntimeVariable::*)(const float&))
-			(&MaterialRuntimeVariable::setValue))
-		.def("setValue", (void (MaterialRuntimeVariable::*)(const Vec2&))
-			(&MaterialRuntimeVariable::setValue))
-		.def("setValue", (void (MaterialRuntimeVariable::*)(const Vec3&))
-			(&MaterialRuntimeVariable::setValue))*/
-	;
-}
-
-
-WRAP(MaterialRuntime)
-{
-	class_<MaterialRuntime, noncopyable>("MaterialRuntime", no_init)
-		/*.def("getVariables",
-			(MaterialRuntime::VariablesContainer&
-			(MaterialRuntime::*)())(&MaterialRuntime::getVariables),
-			return_value_policy<reference_existing_object>())
-
-		.def("getWireframe", (bool (MaterialRuntime::*)() const)(
-			&MaterialRuntime::getWireframe))
-		.def("setWireframe", &MaterialRuntime::setWireframe)*/
-	;
-}

+ 0 - 11
src/script/scene/ModelNode.cpp

@@ -1,11 +0,0 @@
-#include "anki/script/Common.h"
-#include "anki/scene/ModelNode.h"
-
-
-WRAP(ModelNode)
-{
-	WRAP_CONTAINER(std::vector<ModelPatchNode*>)
-
-	class_<ModelNode, bases<SceneNode>, noncopyable>("ModelNode", no_init)
-	;
-}

+ 0 - 10
src/script/scene/ModelPatchNode.cpp

@@ -1,10 +0,0 @@
-#include "anki/script/Common.h"
-#include "anki/scene/ModelPatchNode.h"
-
-
-WRAP(ModelPatchNode)
-{
-	class_<ModelPatchNode, bases<PatchNode>, noncopyable>("ModelPatchNode",
-		no_init)
-	;
-}

+ 0 - 12
src/script/scene/PatchNode.cpp

@@ -1,12 +0,0 @@
-#include "anki/script/Common.h"
-#include "anki/scene/PatchNode.h"
-
-
-WRAP(PatchNode)
-{
-	class_<PatchNode, noncopyable>("PatchNode", no_init)
-		.def("getMaterialRuntime", (MaterialRuntime& (PatchNode::*)())(
-			&PatchNode::getMaterialRuntime),
-			return_value_policy<reference_existing_object>())
-	;
-}

+ 3 - 4
src/script/scene/Scene.cpp

@@ -3,11 +3,10 @@
 #include "anki/scene/Camera.h"
 #include "anki/scene/ModelNode.h"
 
-
-WRAP(Scene)
+ANKI_WRAP(Scene)
 {
-	WRAP_CONTAINER(Scene::Types<Camera>::Container)
-	WRAP_CONTAINER(Scene::Types<ModelNode>::Container)
+	ANKI_WRAP_CONTAINER(Scene::Types<Camera>::Container)
+	ANKI_WRAP_CONTAINER(Scene::Types<ModelNode>::Container)
 
 	class_<Scene, noncopyable>("Scene", no_init)
 		.def("setAmbientColor", &Scene::setAmbientColor)

+ 3 - 4
src/script/scene/SceneNode.cpp

@@ -1,11 +1,10 @@
 #include "anki/script/Common.h"
 #include "anki/scene/SceneNode.h"
 
-
-WRAP(SceneNode)
+ANKI_WRAP(SceneNode)
 {
 	class_<SceneNode, noncopyable>("SceneNode", no_init)
-		.def("getSceneNodeName", &SceneNode::getSceneNodeName,
-			return_value_policy<copy_const_reference>())
+		/*.def("getSceneNodeName", &SceneNode::getSceneNodeName,
+			return_value_policy<copy_const_reference>())*/
 	;
 }

+ 1 - 2
src/script/util/HighRezTimer.cpp

@@ -1,8 +1,7 @@
 #include "anki/script/Common.h"
 #include "anki/util/HighRezTimer.h"
 
-
-WRAP(HighRezTimer)
+ANKI_WRAP(HighRezTimer)
 {
 	class_<HighRezTimer>("HighRezTimer")
 		.def("getCurrentTime", &HighRezTimer::getCurrentTime)

+ 9 - 20
src/ui/UiFont.cpp

@@ -1,20 +1,14 @@
 #include "anki/ui/UiFont.h"
-#include "anki/resource/Texture.h"
+#include "anki/resource/TextureResource.h"
 #include "anki/util/Exception.h"
 #include "anki/util/Assert.h"
 #include "anki/ui/UiFtFontLoader.h"
-#include <GL/glew.h>
-#include <boost/foreach.hpp>
-
 
 namespace anki {
 
-
-//==============================================================================
-// create                                                                      =
 //==============================================================================
-void UiFont::create(const char* fontFilename, uint nominalWidth,
-	uint NominalHeight)
+void UiFont::create(const char* fontFilename, uint32_t nominalWidth,
+	uint32_t NominalHeight)
 {
 	FT_Vector ftSize = {nominalWidth, NominalHeight};
 	UiFtFontLoader ft(fontFilename, ftSize);
@@ -25,7 +19,7 @@ void UiFont::create(const char* fontFilename, uint nominalWidth,
 
 	// - Create glyphs
 	// - Get metrics
-	BOOST_FOREACH(const UiFtFontLoader::Glyph& ftGlyph, ft.getGlyphs())
+	for(const UiFtFontLoader::Glyph& ftGlyph : ft.getGlyphs())
 	{
 		// Create
 		glyphs.push_back(new Glyph);
@@ -42,17 +36,16 @@ void UiFont::create(const char* fontFilename, uint nominalWidth,
 			ftGlyph.getMetrics().horiAdvance);
 	}
 
-	//
 	// Calc texture matrices
 	//
 	int posX = 0;
 	int posY = 0;
 
 	// For all rows
-	for(uint i = 0; i < UiFtFontLoader::GLYPH_ROWS; i++)
+	for(uint32_t i = 0; i < UiFtFontLoader::GLYPH_ROWS; i++)
 	{
 		// For all columns
-		for(uint j = 0; j < UiFtFontLoader::GLYPH_COLUMNS; j++)
+		for(uint32_t j = 0; j < UiFtFontLoader::GLYPH_COLUMNS; j++)
 		{
 			Glyph& glyph = glyphs[i * UiFtFontLoader::GLYPH_COLUMNS + j];
 
@@ -80,7 +73,6 @@ void UiFont::create(const char* fontFilename, uint nominalWidth,
 		posY += ft.getLineHeight();
 	}
 
-	//
 	// Create the texture
 	//
 	Texture::Initializer tinit;
@@ -93,12 +85,9 @@ void UiFont::create(const char* fontFilename, uint nominalWidth,
 	tinit.mipmapping = false;
 	tinit.filteringType = Texture::TFT_NEAREST;
 	tinit.anisotropyLevel = 0;
-	tinit.dataCompression = Texture::DC_NONE;
+	tinit.repeat = false;
 
-	map.reset(new Texture());
-	map->create(tinit);
-	map->setRepeat(false);
+	map.reset(new Texture(tinit));
 }
 
-
-} // end namespace
+} // end namespace anki

+ 21 - 45
src/ui/UiFtFontLoader.cpp

@@ -1,21 +1,15 @@
 #include "anki/ui/UiFtFontLoader.h"
 #include "anki/util/Exception.h"
 #include "anki/core/Logger.h"
-#include "anki/core/Globals.h"
-#include <boost/foreach.hpp>
-
 
 namespace anki {
 
-
-//==============================================================================
-// getAllGlyphs                                                                =
 //==============================================================================
 void UiFtFontLoader::getAllGlyphs()
 {
 	glyphs.resize(GLYPHS_NUM);
 
-	for(uint n = 0; n < GLYPHS_NUM; n++)
+	for(uint32_t n = 0; n < GLYPHS_NUM; n++)
 	{
 		char c = ' ' + n;
 
@@ -39,12 +33,9 @@ void UiFtFontLoader::getAllGlyphs()
 	glyphs[0].metrics = glyphs['_' - ' '].metrics;
 }
 
-
 //==============================================================================
-// copyBitmap                                                                  =
-//==============================================================================
-void UiFtFontLoader::copyBitmap(const uchar* srcImg, const FT_Vector& srcSize,
-	const FT_Vector& pos)
+void UiFtFontLoader::copyBitmap(const uint8_t* srcImg,
+	const FT_Vector& srcSize, const FT_Vector& pos)
 {
 	for(int i = 0; i < srcSize.y; i++)
 	{
@@ -57,9 +48,6 @@ void UiFtFontLoader::copyBitmap(const uchar* srcImg, const FT_Vector& srcSize,
 	}
 }
 
-
-//==============================================================================
-// computeImageSize                                                            =
 //==============================================================================
 void UiFtFontLoader::computeImageSize()
 {
@@ -67,10 +55,9 @@ void UiFtFontLoader::computeImageSize()
 	imgSize.y = 0;
 	lineHeight = 0;
 
-	//
 	// Get img height
 	//
-	BOOST_FOREACH(const Glyph& glyph, glyphs)
+	for(const Glyph& glyph : glyphs)
 	{
 		if(toPixels(glyph.metrics.height) > int(lineHeight))
 		{
@@ -81,19 +68,17 @@ void UiFtFontLoader::computeImageSize()
 	float exp = ceil(log2(GLYPH_ROWS * lineHeight));
 	imgSize.y = pow(2, exp);
 
-	//
 	// Get img width
 	//
 
-
 	// For all rows
-	for(uint i = 0; i < GLYPH_ROWS; i++)
+	for(uint32_t i = 0; i < GLYPH_ROWS; i++)
 	{
-		uint rowSize = 0;
+		uint32_t rowSize = 0;
 		// For all columns
-		for(uint j = 0; j < GLYPH_COLUMNS; j++)
+		for(uint32_t j = 0; j < GLYPH_COLUMNS; j++)
 		{
-			uint pos = i * GLYPH_COLUMNS + j;
+			uint32_t pos = i * GLYPH_COLUMNS + j;
 			rowSize += toPixels(glyphs[pos].metrics.width);
 		}
 
@@ -107,10 +92,6 @@ void UiFtFontLoader::computeImageSize()
 	imgSize.x = pow(2, exp);
 }
 
-
-
-//==============================================================================
-// createImage                                                                 =
 //==============================================================================
 void UiFtFontLoader::createImage(const char* filename,
 	const FT_Vector& fontSize)
@@ -128,14 +109,13 @@ void UiFtFontLoader::createImage(const char* filename,
 	error = FT_New_Face(library, filename, 0, &face);
 	if(error)
 	{
-		throw ANKI_EXCEPTION("FT_New_Face failed with filename \"" + filename +
-			"\"");
+		throw ANKI_EXCEPTION("FT_New_Face() failed with filename: " + filename);
 	}
 
 	error = FT_Set_Pixel_Sizes(face, fontSize.x, fontSize.y);
 	if(error)
 	{
-		throw ANKI_EXCEPTION("FT_Set_Pixel_Sizes failed");
+		throw ANKI_EXCEPTION("FT_Set_Pixel_Sizes() failed");
 	}
 
 	// Get all glyphs
@@ -144,16 +124,16 @@ void UiFtFontLoader::createImage(const char* filename,
 	// Get final image size and create image buffer
 	computeImageSize();
 
-	size_t size = imgSize.x * imgSize.y * 1 * sizeof(uchar);
+	size_t size = imgSize.x * imgSize.y * 1 * sizeof(uint8_t);
 	img.resize(size, 128);
 
 	// Draw all glyphs to the image
 	FT_Vector pos = {0, 0}; // the (0,0) is the top left
 	// For all rows
-	for(uint i = 0; i < GLYPH_ROWS; i++)
+	for(uint32_t i = 0; i < GLYPH_ROWS; i++)
 	{
 		// For all columns
-		for(uint j = 0; j < GLYPH_COLUMNS; j++)
+		for(uint32_t j = 0; j < GLYPH_COLUMNS; j++)
 		{
 			Glyph& glyph = glyphs[i * GLYPH_COLUMNS + j];
 
@@ -181,14 +161,14 @@ void UiFtFontLoader::createImage(const char* filename,
 	{
 		for(int j = 0; j < imgSize.x; j++)
 		{
-			uchar tmp = img[i * imgSize.x + j];
+			uint8_t tmp = img[i * imgSize.x + j];
 			img[i * imgSize.x + j] = img[(imgSize.y - i - 1) * imgSize.x + j];
 			img[(imgSize.y - i - 1) * imgSize.x + j] = tmp;
 		}
 	}
 
 	// Clean
-	BOOST_FOREACH(Glyph& glyph, glyphs)
+	for(Glyph& glyph : glyphs)
 	{
 		FT_Done_Glyph(glyph.glyph);
 	}
@@ -197,19 +177,16 @@ void UiFtFontLoader::createImage(const char* filename,
 	FT_Done_FreeType(library);
 }
 
-
-//==============================================================================
-// saveImage                                                                   =
 //==============================================================================
 void UiFtFontLoader::saveImage(const char* filename) const
 {
-	char tgaHeader[12] = {0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+	uint8_t tgaHeader[12] = {0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0};
 
 	FILE* fp = fopen(filename, "wb");
 
 	fwrite(tgaHeader, 1, sizeof(tgaHeader), fp);
 
-	uchar header6[6];
+	uint8_t header6[6];
 
 	header6[0] = imgSize.x % 256;
 	header6[1] = imgSize.x / 256;
@@ -224,14 +201,13 @@ void UiFtFontLoader::saveImage(const char* filename) const
 	{
 		for(int j = 0; j < imgSize.x; j++)
 		{
-			fwrite(&img[i * imgSize.x + j], 1, sizeof(uchar), fp);
-			fwrite(&img[i * imgSize.x + j], 1, sizeof(uchar), fp);
-			fwrite(&img[i * imgSize.x + j], 1, sizeof(uchar), fp);
+			fwrite(&img[i * imgSize.x + j], 1, sizeof(uint8_t), fp);
+			fwrite(&img[i * imgSize.x + j], 1, sizeof(uint8_t), fp);
+			fwrite(&img[i * imgSize.x + j], 1, sizeof(uint8_t), fp);
 		}
 	}
 
 	fclose(fp);
 }
 
-
-} // end namespace
+} // end namespace anki

+ 12 - 25
src/ui/UiPainter.cpp

@@ -1,28 +1,20 @@
 #include "anki/ui/UiPainter.h"
-#include "anki/gl/GlStateMachine.h"
-#include "anki/resource/Texture.h"
-#include "anki/resource/ShaderProgram.h"
+#include "anki/gl/GlState.h"
+#include "anki/resource/TextureResource.h"
 #include "anki/core/Logger.h"
 #include "anki/ui/UiFont.h"
 #include <cstdarg>
 #include <cstdio>
 
-
 namespace anki {
 
-
-//==============================================================================
-// Constructor                                                                 =
 //==============================================================================
 UiPainter::UiPainter(const Vec2& deviceSize_)
-:	deviceSize(deviceSize_)
+	: deviceSize(deviceSize_)
 {
 	init();
 }
 
-
-//==============================================================================
-// setFont                                                                     =
 //==============================================================================
 void UiPainter::setFont(const char* fontFilename, uint nominalWidth,
 	uint nominalHeight)
@@ -30,22 +22,22 @@ void UiPainter::setFont(const char* fontFilename, uint nominalWidth,
 	font.reset(new UiFont(fontFilename, nominalWidth, nominalHeight));
 }
 
-
-//==============================================================================
-// init                                                                        =
 //==============================================================================
 void UiPainter::init()
 {
 	// Default font
 	float dfltFontWidth = 0.2 * deviceSize.x();
 	font.reset(new UiFont("engine-rsrc/ConsolaMono.ttf", dfltFontWidth,
-	                    deviceSize.x() / deviceSize.y() * dfltFontWidth));
+		deviceSize.x() / deviceSize.y() * dfltFontWidth));
 
 	// Misc
 	tabSize = 4;
 
 	// SProg
 	sProg.load("shaders/UiText.glsl");
+	sProg->bind();
+	sProg->findUniformVariableByName("texture")->set(font->getMap());
+	sProg->findUniformVariableByName("color")->set(col);
 
 	// Geom
 	float quadVertCoords[][2] = {{1.0, 1.0}, {0.0, 1.0}, {0.0, 0.0},
@@ -62,23 +54,18 @@ void UiPainter::init()
 	qVao.attachElementArrayBufferVbo(qIndecesVbo);
 }
 
-
-//==============================================================================
-// drawText                                                                    =
 //==============================================================================
 void UiPainter::drawText(const char* text)
 {
 	// Set GL
-	GlStateMachineSingleton::get().enable(GL_BLEND);
+	GlStateSingleton::get().enable(GL_BLEND);
 	//GlStateMachineSingleton::get().disable(GL_BLEND);
 	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-	GlStateMachineSingleton::get().disable(GL_DEPTH_TEST);
+	GlStateSingleton::get().disable(GL_DEPTH_TEST);
 
 	// SProg (some)
 	sProg->bind();
-
-	sProg->findUniformVariableByName("texture").set(font->getMap(), 0);
-	sProg->findUniformVariableByName("color").set(col);
+	sProg->findUniformVariableByName("texture")->set(font->getMap());
 
 	// Vao
 	qVao.bind();
@@ -118,8 +105,8 @@ void UiPainter::drawText(const char* text)
 			trfM(1, 2) = p.y() + 2.0 * (font->getGlyphBearingY(cc) -
 				int(font->getGlyphHeight(cc))) / deviceSize.y();
 
-			sProg->findUniformVariableByName("transformation").set(trfM);
-			sProg->findUniformVariableByName("textureTranformation").set(
+			sProg->findUniformVariableByName("transformation")->set(trfM);
+			sProg->findUniformVariableByName("textureTranformation")->set(
 				font->getGlyphTextureMatrix(cc));
 
 			// Render

+ 6 - 23
src/ui/UiPainterDevice.cpp

@@ -1,41 +1,24 @@
 #include "anki/ui/UiPainterDevice.h"
-#include "anki/resource/Texture.h"
-
+#include "anki/gl/Texture.h"
 
 namespace anki {
 
-
-//==============================================================================
-// Constructor                                                                 =
 //==============================================================================
-UiPainterDevice::UiPainterDevice(Texture& colorFai_)
-:	colorFai(colorFai_)
+UiPainterDevice::UiPainterDevice(Texture* colorFai_)
+	: colorFai(colorFai_)
 {}
 
-
-//==============================================================================
-// getSize                                                                     =
 //==============================================================================
 Vec2 UiPainterDevice::getSize() const
 {
-	return Vec2(colorFai.getWidth(), colorFai.getHeight());
+	return Vec2(colorFai->getWidth(), colorFai->getHeight());
 }
 
-
-//==============================================================================
-// create                                                                      =
 //==============================================================================
 void UiPainterDevice::create()
 {
 	Fbo::create();
-	bind();
-
-	setNumOfColorAttachements(1);
-	glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
-		colorFai.getGlId(), 0);
-
-	unbind();
+	Fbo::setColorAttachments({colorFai});
 }
 
-
-} // end namespace
+} // end namespace anki

+ 4 - 4
src/util/Filesystem.cpp

@@ -81,7 +81,7 @@ static int rmDir(const char* fpath, const struct stat* sb, int typeflag,
 
 	if(rv)
 	{
-		throw ANKI_EXCEPTION(strerror(errno) + ": " + filename);
+		throw ANKI_EXCEPTION(strerror(errno) + ": " + fpath);
 	}
 
 	return rv;
@@ -89,7 +89,7 @@ static int rmDir(const char* fpath, const struct stat* sb, int typeflag,
 
 void removeDirectory(const char* dir)
 {
-	nftw(path, rmDir, 64, FTW_DEPTH | FTW_PHYS);
+	nftw(dir, rmDir, 64, FTW_DEPTH | FTW_PHYS);
 }
 
 //==============================================================================
@@ -100,9 +100,9 @@ void createDirectory(const char* dir)
 		return;
 	}
 
-	if(mkdir(path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH))
+	if(mkdir(dir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH))
 	{
-		throw ANKI_EXCEPTION(strerror(errno) + ": " + filename);
+		throw ANKI_EXCEPTION(strerror(errno) + ": " + dir);
 	}
 }
 

+ 1 - 3
testapp/Main.cpp

@@ -18,7 +18,6 @@
 #include "anki/scene/ParticleEmitterNode.h"
 #include "anki/physics/Character.h"
 #include "anki/renderer/Renderer.h"
-#include "anki/renderer/RendererInitializer.h"
 #include "anki/renderer/MainRenderer.h"
 #include "anki/physics/Character.h"
 #include "anki/physics/RigidBody.h"
@@ -39,7 +38,6 @@
 #include "anki/resource/ShaderProgramPrePreprocessor.h"
 #include "anki/resource/Material.h"
 #include "anki/core/ParallelManager.h"
-#include <boost/algorithm/string.hpp>
 
 
 using namespace anki;
@@ -51,7 +49,7 @@ SkinNode* imp;
 //SkelModelNode* imp;
 PointLight* point_lights[10];
 SpotLight* spot_lights[2];
-ParticleEmitterNode* partEmitter;
+//ParticleEmitter* partEmitter;
 Character* character;
 
 UiPainter* painter;