Browse Source

- Material
- Refactoring

Panagiotis Christopoulos Charitos 14 năm trước cách đây
mục cha
commit
3483f7f8b5
52 tập tin đã thay đổi với 427 bổ sung510 xóa
  1. 2 0
      find-big-lines
  2. 1 1
      src/GfxApi/BufferObjects/Vao.cpp
  3. 2 2
      src/GfxApi/BufferObjects/Vao.h
  4. 3 3
      src/Renderer/Bl.cpp
  5. 4 4
      src/Renderer/Bl.h
  6. 1 1
      src/Renderer/Bs.cpp
  7. 2 2
      src/Renderer/Bs.h
  8. 2 2
      src/Renderer/Dbg.h
  9. 2 2
      src/Renderer/Hdr.cpp
  10. 4 4
      src/Renderer/Hdr.h
  11. 5 5
      src/Renderer/Is.cpp
  12. 5 5
      src/Renderer/Is.h
  13. 1 1
      src/Renderer/MainRenderer.h
  14. 2 2
      src/Renderer/Pps.cpp
  15. 3 3
      src/Renderer/Pps.h
  16. 1 1
      src/Renderer/Renderer.h
  17. 2 2
      src/Renderer/SkinsDeformer.cpp
  18. 3 3
      src/Renderer/SkinsDeformer.h
  19. 2 2
      src/Renderer/Smo.h
  20. 2 2
      src/Renderer/Ssao.cpp
  21. 4 4
      src/Renderer/Ssao.h
  22. 24 0
      src/Resources/AttributeShaderProgramVariable.h
  23. 2 1
      src/Resources/BuildinMaterialVariable.cpp
  24. 2 2
      src/Resources/BuildinMaterialVariable.h
  25. 5 5
      src/Resources/Material.cpp
  26. 16 12
      src/Resources/Material.h
  27. 118 19
      src/Resources/Material2.cpp
  28. 9 9
      src/Resources/Material2.h
  29. 7 7
      src/Resources/MaterialShaderProgramCreator.cpp
  30. 3 7
      src/Resources/MaterialShaderProgramCreator.h
  31. 8 5
      src/Resources/MaterialVariable.cpp
  32. 9 7
      src/Resources/MaterialVariable.h
  33. 6 6
      src/Resources/MtlUserDefinedVar.cpp
  34. 4 4
      src/Resources/MtlUserDefinedVar.h
  35. 2 2
      src/Resources/ResourceManager.cpp
  36. 2 2
      src/Resources/ResourceManager.h
  37. 0 22
      src/Resources/SProgAttribVar.h
  38. 0 164
      src/Resources/SProgLoader.cpp
  39. 0 53
      src/Resources/SProgLoader.h
  40. 0 37
      src/Resources/SProgUniVar.h
  41. 23 19
      src/Resources/ShaderProgram.cpp
  42. 23 19
      src/Resources/ShaderProgram.h
  43. 1 1
      src/Resources/ShaderProgramPrePreprocessor.cpp
  44. 12 10
      src/Resources/ShaderProgramVariable.h
  45. 9 9
      src/Resources/UniformShaderProgramVariable.cpp
  46. 39 0
      src/Resources/UniformShaderProgramVariable.h
  47. 26 16
      src/Resources/UserMaterialVariable.cpp
  48. 11 11
      src/Resources/UserMaterialVariable.h
  49. 6 5
      src/Scene/MaterialRuntime.h
  50. 1 1
      src/Scene/MaterialRuntimeUserDefinedVar.h
  51. 1 1
      src/Ui/Painter.h
  52. 5 3
      src/Util/Assert.h

+ 2 - 0
find-big-lines

@@ -0,0 +1,2 @@
+#!/bin/bash
+find . -name '*.h' -or -name '*.cpp' -or -name '*.glsl' | while read file; do expand -t4 $file | cut -c81- | grep -qv '^$' && echo $file ; done

+ 1 - 1
src/GfxApi/BufferObjects/Vao.cpp

@@ -45,7 +45,7 @@ void Vao::attachArrayBufferVbo(const Vbo& vbo, uint attribVarLocation,
 //==============================================================================
 // attachArrayBufferVbo                                                        =
 //==============================================================================
-void Vao::attachArrayBufferVbo(const Vbo& vbo, const SProgAttribVar& attribVar,
+void Vao::attachArrayBufferVbo(const Vbo& vbo, const AttributeShaderProgramVariable& attribVar,
 	GLint size, GLenum type, GLboolean normalized, GLsizei stride,
 	const GLvoid* pointer)
 {

+ 2 - 2
src/GfxApi/BufferObjects/Vao.h

@@ -3,7 +3,7 @@
 
 #include <GL/glew.h>
 #include "Util/StdTypes.h"
-#include "Resources/ShaderProg.h"
+#include "Resources/ShaderProgram.h"
 #include "Core/Object.h"
 #include "GfxApi/GlException.h"
 
@@ -45,7 +45,7 @@ class Vao
 		/// @param pointer Specifies a offset of the first component of the
 		/// first generic vertex attribute in the array
 		void attachArrayBufferVbo(const Vbo& vbo,
-			const SProgAttribVar& attribVar, GLint size, GLenum type,
+			const AttributeShaderProgramVariable& attribVar, GLint size, GLenum type,
 			GLboolean normalized, GLsizei stride, const GLvoid* pointer);
 
 		/// Attach an array buffer VBO. See @link

+ 3 - 3
src/Renderer/Bl.cpp

@@ -1,7 +1,7 @@
 #include "Bl.h"
 #include "RendererInitializer.h"
 #include "Renderer.h"
-#include "Resources/ShaderProg.h"
+#include "Resources/ShaderProgram.h"
 
 
 namespace R {
@@ -47,7 +47,7 @@ void Bl::init(const RendererInitializer& initializer)
 			"FBO: " + e.what());
 	}
 
-	hBlurSProg.loadRsrc(ShaderProg::createSrcCodeToCache(
+	hBlurSProg.loadRsrc(ShaderProgram::createSrcCodeToCache(
 		"shaders/PpsBlurGeneric.glsl", "#define HPASS\n").c_str());
 
 	// Vertical
@@ -65,7 +65,7 @@ void Bl::init(const RendererInitializer& initializer)
 			"FBO: " + e.what());
 	}
 
-	vBlurSProg.loadRsrc(ShaderProg::createSrcCodeToCache(
+	vBlurSProg.loadRsrc(ShaderProgram::createSrcCodeToCache(
 		"shaders/PpsBlurGeneric.glsl", "#define VPASS\n").c_str());
 
 	// Side blur

+ 4 - 4
src/Renderer/Bl.h

@@ -8,7 +8,7 @@
 #include "GfxApi/BufferObjects/Fbo.h"
 
 
-class ShaderProg;
+class ShaderProgram;
 
 
 namespace R {
@@ -35,9 +35,9 @@ class Bl: private RenderingPass
 		Fbo vBlurFbo; ///< Fbo that writes to postPassSProg
 		Fbo sideBlurFbo;
 
-		RsrcPtr<ShaderProg> hBlurSProg;
-		RsrcPtr<ShaderProg> vBlurSProg;
-		RsrcPtr<ShaderProg> sideBlurSProg;
+		RsrcPtr<ShaderProgram> hBlurSProg;
+		RsrcPtr<ShaderProgram> vBlurSProg;
+		RsrcPtr<ShaderProgram> sideBlurSProg;
 
 		Texture blurFai; ///< Temp FAI for blurring
 		RsrcPtr<Texture> sideBlurMap;

+ 1 - 1
src/Renderer/Bs.cpp

@@ -2,7 +2,7 @@
 #include "Bs.h"
 #include "Renderer.h"
 #include "Scene/Scene.h"
-#include "Resources/ShaderProg.h"
+#include "Resources/ShaderProgram.h"
 #include "Resources/Model.h"
 #include "Scene/ModelNode.h"
 #include "Resources/Material.h"

+ 2 - 2
src/Renderer/Bs.h

@@ -7,7 +7,7 @@
 #include "Resources/Texture.h"
 
 
-class ShaderProg;
+class ShaderProgram;
 
 
 namespace R {
@@ -27,7 +27,7 @@ class Bs: public RenderingPass
 	private:
 		Fbo fbo; ///< Writes to Pps::prePassFai
 		Fbo refractFbo; ///< Writes to refractFai
-		RsrcPtr<ShaderProg> refractSProg;
+		RsrcPtr<ShaderProgram> refractSProg;
 		Texture refractFai;
 
 		void createFbo();

+ 2 - 2
src/Renderer/Dbg.h

@@ -5,7 +5,7 @@
 #include <map>
 #include "RenderingPass.h"
 #include "GfxApi/BufferObjects/Fbo.h"
-#include "Resources/ShaderProg.h"
+#include "Resources/ShaderProgram.h"
 #include "Resources/RsrcPtr.h"
 #include "Math/Math.h"
 #include "GfxApi/BufferObjects/Vbo.h"
@@ -59,7 +59,7 @@ class Dbg: public RenderingPass
 		bool showCamerasEnabled;
 		bool showVisibilityBoundingShapesFlag;
 		Fbo fbo;
-		RsrcPtr<ShaderProg> sProg;
+		RsrcPtr<ShaderProgram> sProg;
 		static const uint MAX_POINTS_PER_DRAW = 256;
 		boost::array<Vec3, MAX_POINTS_PER_DRAW> positions;
 		boost::array<Vec3, MAX_POINTS_PER_DRAW> colors;

+ 2 - 2
src/Renderer/Hdr.cpp

@@ -75,11 +75,11 @@ void Hdr::init(const RendererInitializer& initializer)
 	const char* SHADER_FILENAME = "shaders/GaussianBlurGeneric.glsl";
 
 	std::string pps = "#define HPASS\n#define COL_RGB\n";
-	hblurSProg.loadRsrc(ShaderProg::createSrcCodeToCache(SHADER_FILENAME,
+	hblurSProg.loadRsrc(ShaderProgram::createSrcCodeToCache(SHADER_FILENAME,
 		pps.c_str()).c_str());
 
 	pps = "#define VPASS\n#define COL_RGB\n";
-	vblurSProg.loadRsrc(ShaderProg::createSrcCodeToCache(SHADER_FILENAME,
+	vblurSProg.loadRsrc(ShaderProgram::createSrcCodeToCache(SHADER_FILENAME,
 		pps.c_str()).c_str());
 }
 

+ 4 - 4
src/Renderer/Hdr.h

@@ -8,7 +8,7 @@
 #include "Util/Accessors.h"
 
 
-class ShaderProg;
+class ShaderProgram;
 
 
 namespace R {
@@ -46,9 +46,9 @@ class Hdr: private RenderingPass
 		Fbo toneFbo;
 		Fbo hblurFbo;
 		Fbo vblurFbo;
-		RsrcPtr<ShaderProg> toneSProg;
-		RsrcPtr<ShaderProg> hblurSProg;
-		RsrcPtr<ShaderProg> vblurSProg;
+		RsrcPtr<ShaderProgram> toneSProg;
+		RsrcPtr<ShaderProgram> hblurSProg;
+		RsrcPtr<ShaderProgram> vblurSProg;
 		Texture toneFai; ///< Vertical blur pass FAI
 		Texture hblurFai; ///< pass0Fai with the horizontal blur FAI
 		Texture fai; ///< The final FAI

+ 5 - 5
src/Renderer/Is.cpp

@@ -114,11 +114,11 @@ void Is::init(const RendererInitializer& initializer)
 	ambientPassSProg.loadRsrc("shaders/IsAp.glsl");
 
 	// point light
-	pointLightSProg.loadRsrc(ShaderProg::createSrcCodeToCache(
+	pointLightSProg.loadRsrc(ShaderProgram::createSrcCodeToCache(
 		"shaders/IsLpGeneric.glsl", "#define POINT_LIGHT_ENABLED\n").c_str());
 
 	// spot light no shadow
-	spotLightNoShadowSProg.loadRsrc(ShaderProg::createSrcCodeToCache(
+	spotLightNoShadowSProg.loadRsrc(ShaderProgram::createSrcCodeToCache(
 		"shaders/IsLpGeneric.glsl", "#define SPOT_LIGHT_ENABLED\n").c_str());
 
 	// spot light w/t shadow
@@ -128,7 +128,7 @@ void Is::init(const RendererInitializer& initializer)
 	{
 		pps += "#define PCF_ENABLED\n";
 	}
-	spotLightShadowSProg.loadRsrc(ShaderProg::createSrcCodeToCache(
+	spotLightShadowSProg.loadRsrc(ShaderProgram::createSrcCodeToCache(
 		"shaders/IsLpGeneric.glsl", pps.c_str()).c_str());
 
 	// init the rest
@@ -169,7 +169,7 @@ void Is::pointLightPass(const PointLight& light)
 	GlStateMachineSingleton::getInstance().enable(GL_DEPTH_TEST, false);
 
 	// shader prog
-	const ShaderProg& shader = *pointLightSProg; // ensure the const-ness
+	const ShaderProgram& shader = *pointLightSProg; // ensure the const-ness
 	shader.bind();
 
 	shader.getUniformVariable("msNormalFai").set(
@@ -237,7 +237,7 @@ void Is::spotLightPass(const SpotLight& light)
 	//light.getTexture().setRepeat(false);
 
 	// shader prog
-	const ShaderProg* shdr;
+	const ShaderProgram* shdr;
 
 	if(light.castsShadow() && sm.isEnabled())
 	{

+ 5 - 5
src/Renderer/Is.h

@@ -5,7 +5,7 @@
 #include "GfxApi/BufferObjects/Fbo.h"
 #include "Resources/Texture.h"
 #include "Resources/RsrcPtr.h"
-#include "Resources/ShaderProg.h"
+#include "Resources/ShaderProgram.h"
 #include "Math/Math.h"
 #include "GfxApi/BufferObjects/Vbo.h"
 #include "GfxApi/BufferObjects/Vao.h"
@@ -43,13 +43,13 @@ class Is: private RenderingPass
 		Fbo readFbo;
 		Fbo writeFbo;
 		/// Illumination stage ambient pass shader program
-		RsrcPtr<ShaderProg> ambientPassSProg;
+		RsrcPtr<ShaderProgram> ambientPassSProg;
 		/// Illumination stage point light shader program
-		RsrcPtr<ShaderProg> pointLightSProg;
+		RsrcPtr<ShaderProgram> pointLightSProg;
 		/// Illumination stage spot light w/o shadow shader program
-		RsrcPtr<ShaderProg> spotLightNoShadowSProg;
+		RsrcPtr<ShaderProgram> spotLightNoShadowSProg;
 		/// Illumination stage spot light w/ shadow shader program
-		RsrcPtr<ShaderProg> spotLightShadowSProg;
+		RsrcPtr<ShaderProgram> spotLightShadowSProg;
 
 		/// The ambient pass
 		void ambientPass(const Vec3& color);

+ 1 - 1
src/Renderer/MainRenderer.h

@@ -51,7 +51,7 @@ class MainRenderer: public Renderer
 		boost::scoped_ptr<TimeQuery> dbgTq;
 		/// @}
 
-		RsrcPtr<ShaderProg> sProg; ///< Final pass' shader program
+		RsrcPtr<ShaderProgram> sProg; ///< Final pass' shader program
 		int screenshotJpegQuality; ///< The quality of the JPEG screenshots.
 		                           ///< From 0 to 100
 

+ 2 - 2
src/Renderer/Pps.cpp

@@ -64,7 +64,7 @@ void Pps::init(const RendererInitializer& initializer)
 		pps += "#define SSAO_ENABLED\n";
 	}
 
-	prePassSProg.loadRsrc(ShaderProg::createSrcCodeToCache(
+	prePassSProg.loadRsrc(ShaderProgram::createSrcCodeToCache(
 		"shaders/PpsPrePass.glsl", pps.c_str()).c_str());
 
 	//
@@ -98,7 +98,7 @@ void Pps::init(const RendererInitializer& initializer)
 		pps += "#define HDR_ENABLED\n";
 	}
 
-	postPassSProg.loadRsrc(ShaderProg::createSrcCodeToCache(
+	postPassSProg.loadRsrc(ShaderProgram::createSrcCodeToCache(
 		"shaders/PpsPostPass.glsl", pps.c_str()).c_str());
 
 	//

+ 3 - 3
src/Renderer/Pps.h

@@ -10,7 +10,7 @@
 #include "Bl.h"
 
 
-class ShaderProg;
+class ShaderProgram;
 
 
 namespace R {
@@ -49,8 +49,8 @@ class Pps: private RenderingPass
 		Fbo prePassFbo;
 		Fbo postPassFbo;
 
-		RsrcPtr<ShaderProg> prePassSProg;
-		RsrcPtr<ShaderProg> postPassSProg;
+		RsrcPtr<ShaderProgram> prePassSProg;
+		RsrcPtr<ShaderProgram> postPassSProg;
 
 		Texture prePassFai; ///< FAI #1
 		Texture postPassFai; ///< FAI #2

+ 1 - 1
src/Renderer/Renderer.h

@@ -4,7 +4,7 @@
 #include "Math/Math.h"
 #include "GfxApi/BufferObjects/Fbo.h"
 #include "Resources/Texture.h"
-#include "Resources/ShaderProg.h"
+#include "Resources/ShaderProgram.h"
 #include "GfxApi/BufferObjects/Vbo.h"
 #include "GfxApi/BufferObjects/Vao.h"
 #include "Resources/RsrcPtr.h"

+ 2 - 2
src/Renderer/SkinsDeformer.cpp

@@ -1,5 +1,5 @@
 #include "SkinsDeformer.h"
-#include "Resources/ShaderProg.h"
+#include "Resources/ShaderProgram.h"
 #include "Scene/SkinPatchNode.h"
 #include "Scene/SkinNode.h"
 
@@ -34,7 +34,7 @@ void SkinsDeformer::deform(SkinPatchNode& node)
 	GlStateMachineSingleton::getInstance().enable(GL_RASTERIZER_DISCARD);
 
 	// Chose sProg
-	const ShaderProg* sProg;
+	const ShaderProgram* sProg;
 
 	if(node.getModelPatchRsrc().supportsNormals() &&
 	   node.getModelPatchRsrc().supportsTangents())

+ 3 - 3
src/Renderer/SkinsDeformer.h

@@ -4,7 +4,7 @@
 #include "Resources/RsrcPtr.h"
 
 
-class ShaderProg;
+class ShaderProgram;
 class SkinPatchNode;
 
 
@@ -29,8 +29,8 @@ class SkinsDeformer
 		void deform(SkinPatchNode& node);
 
 	private:
-		RsrcPtr<ShaderProg> tfHwSkinningAllSProg;
-		RsrcPtr<ShaderProg> tfHwSkinningPosSProg;
+		RsrcPtr<ShaderProgram> tfHwSkinningAllSProg;
+		RsrcPtr<ShaderProgram> tfHwSkinningPosSProg;
 };
 
 

+ 2 - 2
src/Renderer/Smo.h

@@ -3,7 +3,7 @@
 
 #include "RenderingPass.h"
 #include "GfxApi/BufferObjects/Fbo.h"
-#include "Resources/ShaderProg.h"
+#include "Resources/ShaderProgram.h"
 #include "Resources/RsrcPtr.h"
 #include "GfxApi/BufferObjects/Vbo.h"
 #include "GfxApi/BufferObjects/Vao.h"
@@ -44,7 +44,7 @@ class Smo: public RenderingPass
 		/// pyramid, see the blend file with the vertex positions
 		boost::array<Geom, Camera::CT_NUM> camGeom;
 
-		RsrcPtr<ShaderProg> sProg;
+		RsrcPtr<ShaderProgram> sProg;
 
 		void initCamGeom();
 

+ 2 - 2
src/Renderer/Ssao.cpp

@@ -79,11 +79,11 @@ void Ssao::init(const RendererInitializer& initializer)
 
 	std::string pps = "#define HPASS\n#define COL_R\n";
 	hblurSProg.loadRsrc(
-		ShaderProg::createSrcCodeToCache(SHADER_FILENAME, pps.c_str()).c_str());
+		ShaderProgram::createSrcCodeToCache(SHADER_FILENAME, pps.c_str()).c_str());
 
 	pps = "#define VPASS\n#define COL_R\n";
 	vblurSProg.loadRsrc(
-		ShaderProg::createSrcCodeToCache(SHADER_FILENAME, pps.c_str()).c_str());
+		ShaderProgram::createSrcCodeToCache(SHADER_FILENAME, pps.c_str()).c_str());
 
 	//
 	// noise map

+ 4 - 4
src/Renderer/Ssao.h

@@ -4,7 +4,7 @@
 #include "RenderingPass.h"
 #include "GfxApi/BufferObjects/Fbo.h"
 #include "Resources/Texture.h"
-#include "Resources/ShaderProg.h"
+#include "Resources/ShaderProgram.h"
 #include "Resources/RsrcPtr.h"
 #include "GfxApi/BufferObjects/Vbo.h"
 #include "GfxApi/BufferObjects/Vao.h"
@@ -44,9 +44,9 @@ class Ssao: private RenderingPass
 		Fbo hblurFbo;
 		Fbo vblurFbo;
 		RsrcPtr<Texture> noiseMap;
-		RsrcPtr<ShaderProg> ssaoSProg;
-		RsrcPtr<ShaderProg> hblurSProg;
-		RsrcPtr<ShaderProg> vblurSProg;
+		RsrcPtr<ShaderProgram> ssaoSProg;
+		RsrcPtr<ShaderProgram> hblurSProg;
+		RsrcPtr<ShaderProgram> vblurSProg;
 
 		void createFbo(Fbo& fbo, Texture& fai);
 };

+ 24 - 0
src/Resources/AttributeShaderProgramVariable.h

@@ -0,0 +1,24 @@
+#ifndef ATTRIBUTE_SHADER_PROGRAM_VARIABLE_H
+#define ATTRIBUTE_SHADER_PROGRAM_VARIABLE_H
+
+#include "ShaderProgramVariable.h"
+
+
+/// Attribute shader variable
+class AttributeShaderProgramVariable: public ShaderProgramVariable
+{
+	public:
+		AttributeShaderProgramVariable(
+			int loc_, const char* name_, GLenum glDataType_,
+			const ShaderProgram& fatherSProg_);
+};
+
+
+inline AttributeShaderProgramVariable::AttributeShaderProgramVariable(
+	int loc_, const char* name_,
+	GLenum glDataType_, const ShaderProgram& fatherSProg_)
+:	ShaderProgramVariable(loc_, name_, glDataType_, SVT_UNIFORM, fatherSProg_)
+{}
+
+
+#endif

+ 2 - 1
src/Resources/BuildinMaterialVariable.cpp

@@ -64,7 +64,8 @@ boost::unordered_map<BuildinMaterialVariable::BuildinVariable, GLenum>
 // Constructor                                                                 =
 //==============================================================================
 BuildinMaterialVariable::BuildinMaterialVariable(
-	const SProgVar* cpSProgVar, const SProgVar* dpSProgVar,
+	const ShaderProgramVariable* cpSProgVar,
+	const ShaderProgramVariable* dpSProgVar,
 	const char* name)
 :	MaterialVariable(T_BUILDIN, cpSProgVar, dpSProgVar),
  	var(BV_NUM)

+ 2 - 2
src/Resources/BuildinMaterialVariable.h

@@ -44,8 +44,8 @@ class BuildinMaterialVariable: public MaterialVariable
 			BV_NUM ///< The number of all variables
 		};
 
-		BuildinMaterialVariable(const SProgVar* cpSProgVar,
-			const SProgVar* dpSProgVar, const char* name);
+		BuildinMaterialVariable(const ShaderProgramVariable* cpSProgVar,
+			const ShaderProgramVariable* dpSProgVar, const char* name);
 
 		GETTER_R_BY_VAL(BuildinVariable, var, getVariableEnum)
 

+ 5 - 5
src/Resources/Material.cpp

@@ -5,7 +5,7 @@
 #include <boost/lexical_cast.hpp>
 #include "Resources/Material.h"
 #include "Resources/Texture.h"
-#include "Resources/ShaderProg.h"
+#include "Resources/ShaderProgram.h"
 #include "Misc/PropertyTree.h"
 
 
@@ -162,7 +162,7 @@ void Material::load(const char* filename)
 			parseCustomShader(msGenericDefines, customMsSProgTree.get(),
 				source);
 			std::string shaderFilename =
-				ShaderProg::createSrcCodeToCache("shaders/MsMpGeneric.glsl",
+				ShaderProgram::createSrcCodeToCache("shaders/MsMpGeneric.glsl",
 					source.c_str());
 			shaderProg.loadRsrc(shaderFilename.c_str());
 		}
@@ -174,7 +174,7 @@ void Material::load(const char* filename)
 			parseCustomShader(dpGenericDefines, customDpSProgTree.get(),
 				source);
 			std::string shaderFilename =
-				ShaderProg::createSrcCodeToCache("shaders/DpGeneric.glsl",
+				ShaderProgram::createSrcCodeToCache("shaders/DpGeneric.glsl",
 					source.c_str());
 			shaderProg.loadRsrc(shaderFilename.c_str());
 		}
@@ -272,7 +272,7 @@ void Material::load(const char* filename)
 
 				const ptree& valueTree = userDefinedVarTree.get_child("value");
 
-				const SProgUniVar& uni =
+				const UniformShaderProgramVariable& uni =
 					shaderProg->getUniformVariable(varName.c_str());
 
 				// read the values
@@ -320,7 +320,7 @@ void Material::load(const char* filename)
 // parseTextureTag                                                             =
 //==============================================================================
 void Material::parseTextureTag(const boost::property_tree::ptree& pt,
-	const SProgUniVar& uni)
+	const UniformShaderProgramVariable& uni)
 {
 	boost::optional<std::string> texture =
 		pt.get_optional<std::string>("texture");

+ 16 - 12
src/Resources/Material.h

@@ -5,7 +5,7 @@
 #include <boost/property_tree/ptree_fwd.hpp>
 #include <boost/array.hpp>
 #include "Math/Math.h"
-#include "Resources/ShaderProg.h"
+#include "Resources/ShaderProgram.h"
 #include "RsrcPtr.h"
 #include "MtlUserDefinedVar.h"
 
@@ -144,9 +144,10 @@ class Material: private MaterialProps
 
 		/// @name Accessors
 		/// @{
-		const SProgAttribVar* getStdAttribVar(StdAttribVars id) const;
-		const SProgUniVar* getStdUniVar(StdUniVars id) const;
-		const ShaderProg& getShaderProg() const;
+		const AttributeShaderProgramVariable* getStdAttribVar(
+			StdAttribVars id) const;
+		const UniformShaderProgramVariable* getStdUniVar(StdUniVars id) const;
+		const ShaderProgram& getShaderProg() const;
 		GETTER_R_BY_VAL(bool, castsShadowFlag, castsShadow)
 		GETTER_R_BY_VAL(bool, renderInBlendingStageFlag, renderInBlendingStage)
 		GETTER_R_BY_VAL(int, blendingSfactor, getBlendingSfactor)
@@ -191,10 +192,11 @@ class Material: private MaterialProps
 			stdAttribVarInfos;
 		static boost::array<StdVarNameAndGlDataTypePair, SUV_NUM>
 			stdUniVarInfos;
-		boost::array<const SProgAttribVar*, SAV_NUM> stdAttribVars;
-		boost::array<const SProgUniVar*, SUV_NUM> stdUniVars;
+		boost::array<const AttributeShaderProgramVariable*, SAV_NUM>
+			stdAttribVars;
+		boost::array<const UniformShaderProgramVariable*, SUV_NUM> stdUniVars;
 		/// The most important aspect of materials
-		RsrcPtr<ShaderProg> shaderProg;
+		RsrcPtr<ShaderProgram> shaderProg;
 
 		/// The func sweeps all the variables of the shader program to find
 		/// standard shader program variables. It updates the stdAttribVars and
@@ -206,30 +208,32 @@ class Material: private MaterialProps
 		/// @param[in] defines The acceptable defines array
 		/// @param[in] pt The property tree. Its not the root tree
 		/// @param[out] source The source to feed to
-		/// ShaderProg::createSrcCodeToCache
+		/// ShaderProgram::createSrcCodeToCache
 		static void parseCustomShader(const PreprocDefines defines[],
 			const boost::property_tree::ptree& pt,
 			std::string& source);
 
 		/// Parse the texture tag
 		void parseTextureTag(const boost::property_tree::ptree& pt,
-			const SProgUniVar& uni);
+			const UniformShaderProgramVariable& uni);
 };
 
 
-inline const SProgAttribVar* Material::getStdAttribVar(StdAttribVars id) const
+inline const AttributeShaderProgramVariable* Material::getStdAttribVar(
+	StdAttribVars id) const
 {
 	return stdAttribVars[id];
 }
 
 
-inline const SProgUniVar* Material::getStdUniVar(StdUniVars id) const
+inline const UniformShaderProgramVariable* Material::getStdUniVar(
+	StdUniVars id) const
 {
 	return stdUniVars[id];
 }
 
 
-inline const ShaderProg& Material::getShaderProg() const
+inline const ShaderProgram& Material::getShaderProg() const
 {
 	return *shaderProg;
 }

+ 118 - 19
src/Resources/Material2.cpp

@@ -4,7 +4,7 @@
 #include "MaterialShaderProgramCreator.h"
 #include "Core/App.h"
 #include "Core/Globals.h"
-#include "ShaderProg.h"
+#include "ShaderProgram.h"
 #include <boost/foreach.hpp>
 #include <boost/property_tree/ptree.hpp>
 #include <boost/property_tree/xml_parser.hpp>
@@ -57,6 +57,25 @@ Material2::~Material2()
 {}
 
 
+//==============================================================================
+// load                                                                        =
+//==============================================================================
+void Material2::load(const char* filename)
+{
+	try
+	{
+		using namespace boost::property_tree;
+		ptree pt;
+		read_xml(filename, pt);
+		parseMaterialTag(pt.get_child("material"));
+	}
+	catch(std::exception& e)
+	{
+		throw EXCEPTION("File \"" + filename + "\" failed: " + e.what());
+	}
+}
+
+
 //==============================================================================
 // parseMaterialTag                                                            =
 //==============================================================================
@@ -157,6 +176,9 @@ void Material2::parseMaterialTag(const boost::property_tree::ptree& pt)
 
 	cpShaderProg.loadRsrc(cfile.c_str());
 	dpShaderProg.loadRsrc(dfile.c_str());
+
+	//boost::optional<>
+	getVariables(pt.get_child("shaderProgram.ins"));
 }
 
 
@@ -194,27 +216,104 @@ std::string Material2::createShaderProgSourceToCache(const std::string& source)
 
 
 //==============================================================================
-// load                                                                        =
+// getVariables                                                                =
 //==============================================================================
-void Material2::load(const char* filename)
+void Material2::getVariables(const boost::property_tree::ptree& pt)
 {
-	try
-	{
-		using namespace boost::property_tree;
-		ptree pt;
-		read_xml(filename, pt);
-		parseMaterialTag(pt.get_child("material"));
-	}
-	catch(std::exception& e)
+	using namespace boost::property_tree;
+
+	BOOST_FOREACH(const ShaderProgramVariable& sv,
+		cpShaderProg->getVariables())
 	{
-		throw EXCEPTION("File \"" + filename + "\" failed: " + e.what());
-	}
-}
+		const char* svName = sv.getName().c_str();
 
+		// XXX
+		const ShaderProgramVariable* dpSv = NULL;
+		if(dpShaderProg->variableExists(svName))
+		{
+			dpSv = &dpShaderProg->getVariable(svName);
+		}
 
-//==============================================================================
-// getVariables                                                                =
-//==============================================================================
-void Material2::getVariables()
-{
+		MaterialVariable* mv = NULL;
+
+		// Buildin or user defined?
+		if(BuildinMaterialVariable::isBuildin(svName))
+		{
+			mv = new BuildinMaterialVariable(&sv, dpSv, svName);
+		}
+		else
+		{
+			// Get uniforms
+			if(sv.getType() != ShaderProgramVariable::SVT_UNIFORM)
+			{
+				throw EXCEPTION("XXX"); // XXX
+			}
+
+			const UniformShaderProgramVariable* uniC =
+				static_cast<const UniformShaderProgramVariable*>(&sv);
+
+			const UniformShaderProgramVariable* uniD = NULL;
+
+			if(dpSv)
+			{
+				const UniformShaderProgramVariable* uniD =
+					static_cast<const UniformShaderProgramVariable*>(dpSv);
+			}
+
+			// Find the ptree that contains the value
+			const ptree* inPt = NULL;
+			BOOST_FOREACH(const ptree::value_type& v, pt)
+			{
+				if(v.first != "in")
+				{
+					throw EXCEPTION("XXX"); // XXX
+				}
+
+				if(v.second.get<std::string>("name") == svName)
+				{
+					inPt = &v.second;
+					break;
+				}
+			}
+
+			if(inPt == NULL)
+			{
+				throw EXCEPTION("Variable not buildin and not found: " +
+					svName);
+			}
+
+			// Get the value
+			switch(sv.getGlDataType())
+			{
+				// sampler2D
+				case GL_SAMPLER_2D:
+					mv = new UserMaterialVariable(uniC, uniD,
+						inPt->get<std::string>("sampler2D").c_str());
+					break;
+				// float
+				case GL_FLOAT:
+					mv = new UserMaterialVariable(uniC, uniD,
+						PropertyTree::getFloat(*inPt));
+					break;
+				// vec2
+				case GL_FLOAT_VEC2:
+					mv = new UserMaterialVariable(uniC, uniD,
+						PropertyTree::getVec2(*inPt));
+					break;
+				// vec3
+				case GL_FLOAT_VEC3:
+					mv = new UserMaterialVariable(uniC, uniD,
+						PropertyTree::getVec3(*inPt));
+					break;
+				// vec4
+				case GL_FLOAT_VEC4:
+					mv = new UserMaterialVariable(uniC, uniD,
+						PropertyTree::getVec4(*inPt));
+					break;
+				// default is error
+				default:
+					ASSERT(0);
+			}
+		}
+	}
 }

+ 9 - 9
src/Resources/Material2.h

@@ -13,9 +13,9 @@
 #include <boost/property_tree/ptree_fwd.hpp>
 
 
-class SProgAttribVar;
-class SProgUniVar;
-class ShaderProg;
+class AttributeShaderProgramVariable;
+class UniformShaderProgramVariable;
+class ShaderProgram;
 namespace Scanner {
 class Scanner;
 }
@@ -133,10 +133,10 @@ class Material2: private MaterialProperties
 		/// Access the base class just for copying in other classes
 		GETTER_R(MaterialProperties, *this, accessMaterialPropertiesBaseClass)
 
-		const ShaderProg& getColorPassShaderProgram() const
+		const ShaderProgram& getColorPassShaderProgram() const
 			{return *cpShaderProg;}
 
-		const ShaderProg& getDepthPassShaderProgram() const
+		const ShaderProgram& getDepthPassShaderProgram() const
 			{return *dpShaderProg;}
 		/// @}
 
@@ -157,14 +157,14 @@ class Material2: private MaterialProperties
 
 		BuildinEnumToBuildinHashMap enumToBuildinMtlVar; ///< To find
 
-		Vec<UserMaterialVariable*> userMtlVars; ///< To find
+		Vec<UserMaterialVariable*> userMtlVars; ///< To iterate
 
 		/// The most important aspect of materials. Shader program for color
 		/// passes
-		RsrcPtr<ShaderProg> cpShaderProg;
+		RsrcPtr<ShaderProgram> cpShaderProg;
 
 		/// Shader program for depth passes
-		RsrcPtr<ShaderProg> dpShaderProg;
+		RsrcPtr<ShaderProgram> dpShaderProg;
 
 		/// From "GL_ZERO" return GL_ZERO
 		static ConstCharPtrHashMap<GLenum>::Type txtToBlengGlEnum;
@@ -180,7 +180,7 @@ class Material2: private MaterialProperties
 		std::string createShaderProgSourceToCache(const std::string& source);
 
 		/// XXX
-		void getVariables();
+		void getVariables(const boost::property_tree::ptree& pt);
 };
 
 

+ 7 - 7
src/Resources/MaterialShaderProgramCreator.cpp

@@ -49,9 +49,6 @@ ConstCharPtrHashMap<MaterialShaderProgramCreator::ArgQualifier>::Type
 	("inout", AQ_INOUT);
 
 
-const char* MaterialShaderProgramCreator::depthPassDefine = "DEPTH_PASS";
-
-
 //==============================================================================
 // Constructor                                                                 =
 //==============================================================================
@@ -415,6 +412,7 @@ void MaterialShaderProgramCreator::parseInTag(
 
 	const std::string& name = pt.get<std::string>("name");
 	boost::optional<const ptree&> valuePt = pt.get_child_optional("value");
+	GLenum glType;
 
 	line = "uniform ";
 
@@ -422,15 +420,14 @@ void MaterialShaderProgramCreator::parseInTag(
 	if(!valuePt)
 	{
 		BuildinMaterialVariable::BuildinVariable tmp;
-		GLenum dataType;
 
-		if(!BuildinMaterialVariable::isBuildin(name.c_str(), &tmp, &dataType))
+		if(!BuildinMaterialVariable::isBuildin(name.c_str(), &tmp, &glType))
 		{
 			throw EXCEPTION("The variable is not build in: " + name);
 		}
 
 		boost::unordered_map<GLenum, const char*>::const_iterator it =
-			glTypeToTxt.find(dataType);
+			glTypeToTxt.find(glType);
 
 		ASSERT(it != glTypeToTxt.end() &&
 			"Buildin's type is not registered");
@@ -453,7 +450,10 @@ void MaterialShaderProgramCreator::parseInTag(
 				name);
 		}
 
-		line += v.first;
+		const std::string& typeTxt = v.first;
+
+		line += typeTxt;
+		glType = txtToGlType.at(typeTxt.c_str());
 	}
 
 	line += " " + name + ";";

+ 3 - 7
src/Resources/MaterialShaderProgramCreator.h

@@ -3,6 +3,7 @@
 
 #include "Util/ConstCharPtrHashMap.h"
 #include "Util/Vec.h"
+#include "Util/Accessors.h"
 #include <GL/glew.h>
 #include <boost/property_tree/ptree_fwd.hpp>
 #include <boost/ptr_container/ptr_vector.hpp>
@@ -23,9 +24,6 @@ class MaterialShaderProgramCreator
 		/// XXX
 		const std::string& getShaderProgramSource() const {return source;}
 
-		/// XXX
-		static const char* getDepthPassDefine() {return depthPassDefine;}
-
 	private:
 		//======================================================================
 		// Nested                                                              =
@@ -79,15 +77,13 @@ class MaterialShaderProgramCreator
 		/// Container that holds the function definitions
 		boost::ptr_vector<FuncDefinition> funcDefs;
 
-		/// Go from funtion name to function definition
+		/// Go from function name to function definition
 		ConstCharPtrHashMap<FuncDefinition*>::Type funcNameToDef;
 
 		Vec<std::string> srcLines; ///< The lines of the shader program source
 
 		std::string source; ///< Shader program final source
 
-		static const char* depthPassDefine; ///< XXX
-
 		//======================================================================
 		// Methods                                                             =
 		//======================================================================
@@ -118,7 +114,7 @@ class MaterialShaderProgramCreator
 		void parseShaderProgramTag(const boost::property_tree::ptree& pt);
 
 		/// Parse what is within the @code <in></in> @endcode
-		static void parseInTag(const boost::property_tree::ptree& pt,
+		void parseInTag(const boost::property_tree::ptree& pt,
 			std::string& line);
 
 		/// Parse what is within the @code <operation></operation> @endcode

+ 8 - 5
src/Resources/MaterialVariable.cpp

@@ -1,5 +1,5 @@
 #include "MaterialVariable.h"
-#include "SProgVar.h"
+#include "ShaderProgramVariable.h"
 #include "Util/Assert.h"
 #include "Util/Exception.h"
 
@@ -7,8 +7,9 @@
 //==============================================================================
 // Constructor                                                                 =
 //==============================================================================
-MaterialVariable::MaterialVariable(Type type_, const SProgVar* cpSProgVar_,
-	const SProgVar* dpSProgVar_)
+MaterialVariable::MaterialVariable(Type type_,
+	const ShaderProgramVariable* cpSProgVar_,
+	const ShaderProgramVariable* dpSProgVar_)
 :	type(type_),
  	cpSProgVar(cpSProgVar_),
  	dpSProgVar(dpSProgVar_)
@@ -34,7 +35,8 @@ MaterialVariable::MaterialVariable(Type type_, const SProgVar* cpSProgVar_,
 //==============================================================================
 // getColorPassShaderProgramVariable                                           =
 //==============================================================================
-const SProgVar& MaterialVariable::getColorPassShaderProgramVariable() const
+const ShaderProgramVariable&
+	MaterialVariable::getColorPassShaderProgramVariable() const
 {
 	ASSERT(isColorPass());
 	return *cpSProgVar;
@@ -44,7 +46,8 @@ const SProgVar& MaterialVariable::getColorPassShaderProgramVariable() const
 //==============================================================================
 // getDepthPassShaderProgramVariable                                           =
 //==============================================================================
-const SProgVar& MaterialVariable::getDepthPassShaderProgramVariable() const
+const ShaderProgramVariable&
+	MaterialVariable::getDepthPassShaderProgramVariable() const
 {
 	ASSERT(isDepthPass());
 	return *dpSProgVar;

+ 9 - 7
src/Resources/MaterialVariable.h

@@ -6,7 +6,7 @@
 #include <string>
 
 
-class SProgVar;
+class ShaderProgramVariable;
 
 
 /// XXX
@@ -22,14 +22,14 @@ class MaterialVariable
 		};
 
 		/// XXX
-		MaterialVariable(Type type, const SProgVar* cpSProgVar,
-			const SProgVar* dpSProgVar);
+		MaterialVariable(Type type, const ShaderProgramVariable* cpSProgVar,
+			const ShaderProgramVariable* dpSProgVar);
 
 		/// @name Accessors
 		/// @{
 		GETTER_R_BY_VAL(Type, type, getType)
-		const SProgVar& getColorPassShaderProgramVariable() const;
-		const SProgVar& getDepthPassShaderProgramVariable() const;
+		const ShaderProgramVariable& getColorPassShaderProgramVariable() const;
+		const ShaderProgramVariable& getDepthPassShaderProgramVariable() const;
 		/// Applies to the color pass shader program
 		bool isColorPass() const {return cpSProgVar != NULL;}
 		/// Applies to the depth pass shader program
@@ -40,8 +40,10 @@ class MaterialVariable
 
 	private:
 		Type type;
-		const SProgVar* cpSProgVar; ///< The color pass shader program variable
-		const SProgVar* dpSProgVar; ///< The depth pass shader program variable
+		/// The color pass shader program variable
+		const ShaderProgramVariable* cpSProgVar;
+		/// The depth pass shader program variable
+		const ShaderProgramVariable* dpSProgVar;
 };
 
 

+ 6 - 6
src/Resources/MtlUserDefinedVar.cpp

@@ -7,7 +7,7 @@
 //==============================================================================
 
 template<>
-MtlUserDefinedVar::MtlUserDefinedVar(const SProgUniVar& var, const Fai& fai_)
+MtlUserDefinedVar::MtlUserDefinedVar(const UniformShaderProgramVariable& var, const Fai& fai_)
 :	sProgVar(var)
 {
 	ASSERT(var.getGlDataType() == GL_SAMPLER_2D);
@@ -16,7 +16,7 @@ MtlUserDefinedVar::MtlUserDefinedVar(const SProgUniVar& var, const Fai& fai_)
 
 
 template<>
-MtlUserDefinedVar::MtlUserDefinedVar(const SProgUniVar& var, const float& f)
+MtlUserDefinedVar::MtlUserDefinedVar(const UniformShaderProgramVariable& var, const float& f)
 :	sProgVar(var)
 {
 	ASSERT(var.getGlDataType() == GL_FLOAT);
@@ -25,7 +25,7 @@ MtlUserDefinedVar::MtlUserDefinedVar(const SProgUniVar& var, const float& f)
 
 
 template<>
-MtlUserDefinedVar::MtlUserDefinedVar(const SProgUniVar& var, const Vec2& v)
+MtlUserDefinedVar::MtlUserDefinedVar(const UniformShaderProgramVariable& var, const Vec2& v)
 :	sProgVar(var)
 {
 	ASSERT(var.getGlDataType() == GL_FLOAT_VEC2);
@@ -34,7 +34,7 @@ MtlUserDefinedVar::MtlUserDefinedVar(const SProgUniVar& var, const Vec2& v)
 
 
 template<>
-MtlUserDefinedVar::MtlUserDefinedVar(const SProgUniVar& var, const Vec3& v)
+MtlUserDefinedVar::MtlUserDefinedVar(const UniformShaderProgramVariable& var, const Vec3& v)
 :	sProgVar(var)
 {
 	ASSERT(var.getGlDataType() == GL_FLOAT_VEC3);
@@ -43,7 +43,7 @@ MtlUserDefinedVar::MtlUserDefinedVar(const SProgUniVar& var, const Vec3& v)
 
 
 template<>
-MtlUserDefinedVar::MtlUserDefinedVar(const SProgUniVar& var, const Vec4& v)
+MtlUserDefinedVar::MtlUserDefinedVar(const UniformShaderProgramVariable& var, const Vec4& v)
 :	sProgVar(var)
 {
 	ASSERT(var.getGlDataType() == GL_FLOAT_VEC4);
@@ -52,7 +52,7 @@ MtlUserDefinedVar::MtlUserDefinedVar(const SProgUniVar& var, const Vec4& v)
 
 
 template<>
-MtlUserDefinedVar::MtlUserDefinedVar(const SProgUniVar& var,
+MtlUserDefinedVar::MtlUserDefinedVar(const UniformShaderProgramVariable& var,
 	const std::string& texFilename)
 :	sProgVar(var)
 {

+ 4 - 4
src/Resources/MtlUserDefinedVar.h

@@ -4,7 +4,7 @@
 #include <boost/variant.hpp>
 #include "Util/Accessors.h"
 #include "Math/Math.h"
-#include "SProgUniVar.h"
+#include "UniformShaderProgramVariable.h"
 #include "RsrcPtr.h"
 
 
@@ -32,11 +32,11 @@ class MtlUserDefinedVar
 		/// Contructor
 		/// @tparam Type Can be std::string, Fai, float, Vec2, Vec3, Vec4
 		template<typename Type>
-		MtlUserDefinedVar(const SProgUniVar& sProgVar, const Type& val);
+		MtlUserDefinedVar(const UniformShaderProgramVariable& sProgVar, const Type& val);
 
 		/// @name Accessors
 		/// @{
-		const SProgUniVar& getUniVar() const {return sProgVar;}
+		const UniformShaderProgramVariable& getUniVar() const {return sProgVar;}
 
 		const DataVariant& getDataVariant() const {return data;}
 
@@ -49,7 +49,7 @@ class MtlUserDefinedVar
 
 	private:
 		DataVariant data;
-		const SProgUniVar& sProgVar; ///< Know a part of the ShaderProg resource
+		const UniformShaderProgramVariable& sProgVar; ///< Know a part of the ShaderProg resource
 };
 
 

+ 2 - 2
src/Resources/ResourceManager.cpp

@@ -2,7 +2,7 @@
 
 #include "Resources/Texture.h"
 #include "Resources/Material.h"
-#include "Resources/ShaderProg.h"
+#include "Resources/ShaderProgram.h"
 #include "Mesh.h"
 #include "Skeleton.h"
 #include "SkelAnim.h"
@@ -49,7 +49,7 @@ ResourceManager::~ResourceManager()
 
 
 //SPECIALIZE_TEMPLATE_STUFF(Texture, textures)
-SPECIALIZE_TEMPLATE_STUFF(ShaderProg, shaderProgs)
+SPECIALIZE_TEMPLATE_STUFF(ShaderProgram, shaderProgs)
 SPECIALIZE_TEMPLATE_STUFF(Material, materials)
 SPECIALIZE_TEMPLATE_STUFF(Mesh, meshes)
 SPECIALIZE_TEMPLATE_STUFF(Skeleton, skeletons)

+ 2 - 2
src/Resources/ResourceManager.h

@@ -11,7 +11,7 @@
 
 
 class Texture;
-class ShaderProg;
+class ShaderProgram;
 class Material;
 class Mesh;
 class Skeleton;
@@ -64,7 +64,7 @@ class ResourceManager
 		/// @name Containers
 		/// @{
 		Types<Texture>::Container textures;
-		Types<ShaderProg>::Container shaderProgs;
+		Types<ShaderProgram>::Container shaderProgs;
 		Types<Material>::Container materials;
 		Types<Mesh>::Container meshes;
 		Types<Skeleton>::Container skeletons;

+ 0 - 22
src/Resources/SProgAttribVar.h

@@ -1,22 +0,0 @@
-#ifndef S_PROG_ATTRIB_VAR_H
-#define S_PROG_ATTRIB_VAR_H
-
-#include "SProgVar.h"
-
-
-/// Attribute shader variable
-class SProgAttribVar: public SProgVar
-{
-	public:
-		SProgAttribVar(int loc_, const char* name_, GLenum glDataType_,
-			const ShaderProg& fatherSProg_);
-};
-
-
-inline SProgAttribVar::SProgAttribVar(int loc_, const char* name_,
-	GLenum glDataType_, const ShaderProg& fatherSProg_)
-:	SProgVar(loc_, name_, glDataType_, SVT_UNIFORM, fatherSProg_)
-{}
-
-
-#endif

+ 0 - 164
src/Resources/SProgLoader.cpp

@@ -1,164 +0,0 @@
-#include "SProgLoader.h"
-#include "Util/Exception.h"
-#include "Util/Util.h"
-
-#include <boost/property_tree/ptree.hpp>
-#include <boost/property_tree/xml_parser.hpp>
-#include <boost/foreach.hpp>
-#include <boost/lexical_cast.hpp>
-
-
-//==============================================================================
-// Destructor                                                                  =
-//==============================================================================
-SProgLoader::~SProgLoader()
-{}
-
-
-//==============================================================================
-// parseShaderProgBlock                                                        =
-//==============================================================================
-void SProgLoader::parseShaderProgBlock(const boost::property_tree::ptree& pt,
-	Output& out)
-{
-	using namespace boost::property_tree;
-	std::string allCode;
-
-	BOOST_FOREACH(const ptree::value_type& v, pt)
-	{
-		// <transformFeedbackVaryings> ... </transformFeedbackVaryings>
-		if(v.first == "transformFeedbackVaryings")
-		{
-			BOOST_FOREACH(const ptree::value_type& v2, v.second)
-			{
-				if(v2.first != "transformFeedbackVarying")
-				{
-					throw EXCEPTION("Expected transformFeedbackVarying"
-						" and not " + v2.first);
-				}
-
-				const std::string& name = v2.second.data();
-				out.tfbVaryings.push_back(name);
-			}
-		}
-		// <allShader> ... </allShader>
-		else if(v.first == "allShader")
-		{
-			parseShaderBlock(v.second, allCode);
-		}
-		// <vertexShader> ... </vertexShader>
-		else if(v.first == "vertexShader")
-		{
-			out.vertShaderSource += allCode;
-			parseShaderBlock(v.second, out.vertShaderSource);
-		}
-		// <geometryShader> ... </geometryShader>
-		else if(v.first == "geometryShader")
-		{
-			out.geomShaderSource += allCode;
-			parseShaderBlock(v.second, out.geomShaderSource);
-		}
-		// <fragmentShader> ... </fragmentShader>
-		else if(v.first == "fragmentShader")
-		{
-			out.fragShaderSource += allCode;
-			parseShaderBlock(v.second, out.fragShaderSource);
-		}
-		// <include> ... </include>
-		else if(v.first == "include")
-		{
-			SProgLoader spl(v.second.data().c_str());
-
-			BOOST_FOREACH(const std::string& trffbvar, spl.out.tfbVaryings)
-			{
-				out.tfbVaryings.push_back(trffbvar);
-			}
-
-			out.vertShaderSource += spl.out.vertShaderSource;
-			out.geomShaderSource += spl.out.geomShaderSource;
-			out.fragShaderSource += spl.out.fragShaderSource;
-		}
-		// error
-		else
-		{
-			throw EXCEPTION("Incorrect tag: " + v.first);
-		}
-	}
-}
-
-
-//==============================================================================
-// parseShaderBlock                                                            =
-//==============================================================================
-void SProgLoader::parseShaderBlock(const boost::property_tree::ptree& pt,
-	std::string& src)
-{
-	using namespace boost::property_tree;
-
-	BOOST_FOREACH(const ptree::value_type& v, pt)
-	{
-		if(v.first == "include")
-		{
-			src += Util::readFile(v.second.data().c_str());
-		}
-		else if(v.first == "code")
-		{
-			src += v.second.data();
-		}
-		else
-		{
-			throw EXCEPTION("Expecting <include> or <code> and not: " +
-				v.first);
-		}
-	}
-}
-
-
-//==============================================================================
-// parseFile                                                                   =
-//==============================================================================
-void SProgLoader::parseFile(const char* filename)
-{
-	try
-	{
-		using namespace boost::property_tree;
-		ptree pt;
-		read_xml(filename, pt);
-		parsePtree(pt.get_child("shaderProgram"));
-	}
-	catch(std::exception& e)
-	{
-		throw EXCEPTION("File \"" + filename + "\" failed: " + e.what());
-	}
-	catch(...)
-	{
-		throw EXCEPTION("Fucken boost");
-	}
-}
-
-
-//==============================================================================
-// parsePtree                                                                  =
-//==============================================================================
-void SProgLoader::parsePtree(const boost::property_tree::ptree& pt_)
-{
-	try
-	{
-		using namespace boost::property_tree;
-
-		boost::optional<const ptree&> pt =
-			pt_.get_child_optional("shaderProgram");
-		if(pt)
-		{
-			parseShaderProgBlock(pt.get(), out);
-		}
-		else
-		{
-			parseShaderProgBlock(pt_, out);
-		}
-	}
-	catch(std::exception& e)
-	{
-		throw EXCEPTION("XML parsing failed: " + e.what());
-	}
-}

+ 0 - 53
src/Resources/SProgLoader.h

@@ -1,53 +0,0 @@
-#ifndef S_PROG_LOADER_H
-#define S_PROG_LOADER_H
-
-#include "Util/Vec.h"
-#include "Util/Accessors.h"
-#include <string>
-#include <boost/property_tree/ptree_fwd.hpp>
-
-
-/// @todo
-class SProgLoader
-{
-	public:
-		SProgLoader() {}
-		SProgLoader(const char* filename) {parseFile(filename);}
-		SProgLoader(const boost::property_tree::ptree& pt) {parsePtree(pt);}
-		~SProgLoader();
-
-		/// @name Accessors
-		/// @{
-		GETTER_R(Vec<std::string>, out.tfbVaryings, getTranformFeedbackVaryings)
-		GETTER_R(std::string, out.vertShaderSource, getVertexShaderSource)
-		GETTER_R(std::string, out.geomShaderSource, getGeometryShaderSource)
-		GETTER_R(std::string, out.fragShaderSource, getFragmentShaderSource)
-		/// @}
-
-		void parseFile(const char* filename);
-		void parsePtree(const boost::property_tree::ptree& pt);
-
-	private:
-		struct Output
-		{
-			Vec<std::string> tfbVaryings; ///< Names and and ids for transform
-			                              ///< feedback varyings
-			std::string vertShaderSource; ///< The vert shader source
-			std::string geomShaderSource; ///< The geom shader source
-			std::string fragShaderSource; ///< The frag shader source
-		};
-
-		Output out;
-
-		/// Parse what is inside the:
-		/// @code <shaderProgram>...</shaderProgram> @endcode
-		static void parseShaderProgBlock(const boost::property_tree::ptree& pt,
-			Output& out);
-
-		/// Parse what is inside a shader block. It appends the src string
-		static void parseShaderBlock(const boost::property_tree::ptree& pt,
-			std::string& src);
-};
-
-
-#endif

+ 0 - 37
src/Resources/SProgUniVar.h

@@ -1,37 +0,0 @@
-#ifndef S_PROG_UNI_VAR_H
-#define S_PROG_UNI_VAR_H
-
-#include "SProgVar.h"
-#include "Math/Math.h"
-
-
-class Texture;
-
-
-/// Uniform shader variable
-class SProgUniVar: public SProgVar
-{
-	public:
-		SProgUniVar(int loc_, const char* name_, GLenum glDataType_,
-			const ShaderProg& fatherSProg_);
-
-		/// @name Set the var
-		/// @{
-		void set(const float f[], uint size = 1) const;
-		void set(const Vec2 v2[], uint size = 1) const;
-		void set(const Vec3 v3[], uint size = 1) const;
-		void set(const Vec4 v4[], uint size = 1) const;
-		void set(const Mat3 m3[], uint size = 1) const;
-		void set(const Mat4 m4[], uint size = 1) const;
-		void set(const Texture& tex, uint texUnit) const;
-		/// @}
-};
-
-
-inline SProgUniVar::SProgUniVar(int loc_, const char* name_,
-	GLenum glDataType_, const ShaderProg& fatherSProg_)
-:	SProgVar(loc_, name_, glDataType_, SVT_UNIFORM, fatherSProg_)
-{}
-
-
-#endif

+ 23 - 19
src/Resources/ShaderProg.cpp → src/Resources/ShaderProgram.cpp

@@ -4,7 +4,7 @@
 #include <boost/functional/hash.hpp>
 #include <fstream>
 #include <sstream>
-#include "Resources/ShaderProg.h"
+#include "Resources/ShaderProgram.h"
 #include "ShaderProgramPrePreprocessor.h"
 #include "Core/App.h" // To get cache dir
 #include "GfxApi/GlException.h"
@@ -21,7 +21,7 @@
 // Statics                                                                     =
 //==============================================================================
 
-std::string ShaderProg::stdSourceCode(
+std::string ShaderProgram::stdSourceCode(
 	"#version 330 core\n"
 	"precision lowp float;\n"
 	"#pragma optimize(on)\n"
@@ -32,7 +32,7 @@ std::string ShaderProg::stdSourceCode(
 //==============================================================================
 // Destructor                                                                  =
 //==============================================================================
-ShaderProg::~ShaderProg()
+ShaderProgram::~ShaderProgram()
 {
 	/// @todo add code
 }
@@ -41,7 +41,7 @@ ShaderProg::~ShaderProg()
 //==============================================================================
 // createAndCompileShader                                                      =
 //==============================================================================
-uint ShaderProg::createAndCompileShader(const char* sourceCode,
+uint ShaderProgram::createAndCompileShader(const char* sourceCode,
 	const char* preproc, int type) const
 {
 	uint glId = 0;
@@ -98,7 +98,7 @@ uint ShaderProg::createAndCompileShader(const char* sourceCode,
 //==============================================================================
 // link                                                                        =
 //==============================================================================
-void ShaderProg::link() const
+void ShaderProgram::link() const
 {
 	// link
 	glLinkProgram(glId);
@@ -125,7 +125,7 @@ void ShaderProg::link() const
 //==============================================================================
 // getUniAndAttribVars                                                         =
 //==============================================================================
-void ShaderProg::getUniAndAttribVars()
+void ShaderProgram::getUniAndAttribVars()
 {
 	int num;
 	boost::array<char, 256> name_;
@@ -152,7 +152,8 @@ void ShaderProg::getUniAndAttribVars()
 			continue;
 		}
 
-		SProgAttribVar* var = new SProgAttribVar(loc, &name_[0], type, *this);
+		AttributeShaderProgramVariable* var =
+			new AttributeShaderProgramVariable(loc, &name_[0], type, *this);
 		vars.push_back(var);
 		nameToVar[var->getName().c_str()] = var;
 		nameToAttribVar[var->getName().c_str()] = var;
@@ -177,7 +178,8 @@ void ShaderProg::getUniAndAttribVars()
 			continue;
 		}
 
-		SProgUniVar* var = new SProgUniVar(loc, &name_[0], type, *this);
+		UniformShaderProgramVariable* var =
+			new UniformShaderProgramVariable(loc, &name_[0], type, *this);
 		vars.push_back(var);
 		nameToVar[var->getName().c_str()] = var;
 		nameToUniVar[var->getName().c_str()] = var;
@@ -188,7 +190,7 @@ void ShaderProg::getUniAndAttribVars()
 //==============================================================================
 // load                                                                        =
 //==============================================================================
-void ShaderProg::load(const char* filename)
+void ShaderProgram::load(const char* filename)
 {
 	rsrcFilename = filename;
 	ASSERT(glId == std::numeric_limits<uint>::max());
@@ -240,7 +242,7 @@ void ShaderProg::load(const char* filename)
 //==============================================================================
 // getVariable                                                                 =
 //==============================================================================
-const SProgVar& ShaderProg::getVariable(const char* name) const
+const ShaderProgramVariable& ShaderProgram::getVariable(const char* name) const
 {
 	VarsHashMap::const_iterator it = nameToVar.find(name);
 	if(it == nameToVar.end())
@@ -254,7 +256,8 @@ const SProgVar& ShaderProg::getVariable(const char* name) const
 //==============================================================================
 // getAttributeVariable                                                        =
 //==============================================================================
-const SProgAttribVar& ShaderProg::getAttributeVariable(const char* name) const
+const AttributeShaderProgramVariable& ShaderProgram::getAttributeVariable(
+	const char* name) const
 {
 	AttribVarsHashMap::const_iterator it = nameToAttribVar.find(name);
 	if(it == nameToAttribVar.end())
@@ -268,7 +271,8 @@ const SProgAttribVar& ShaderProg::getAttributeVariable(const char* name) const
 //==============================================================================
 // getUniformVariable                                                          =
 //==============================================================================
-const SProgUniVar& ShaderProg::getUniformVariable(const char* name) const
+const UniformShaderProgramVariable& ShaderProgram::getUniformVariable(
+	const char* name) const
 {
 	UniVarsHashMap::const_iterator it = nameToUniVar.find(name);
 	if(it == nameToUniVar.end())
@@ -282,7 +286,7 @@ const SProgUniVar& ShaderProg::getUniformVariable(const char* name) const
 //==============================================================================
 // variableExists                                                              =
 //==============================================================================
-bool ShaderProg::variableExists(const char* name) const
+bool ShaderProgram::variableExists(const char* name) const
 {
 	VarsHashMap::const_iterator it = nameToVar.find(name);
 	return it != nameToVar.end();
@@ -292,7 +296,7 @@ bool ShaderProg::variableExists(const char* name) const
 //==============================================================================
 // uniformVariableExists                                                       =
 //==============================================================================
-bool ShaderProg::uniformVariableExists(const char* name) const
+bool ShaderProgram::uniformVariableExists(const char* name) const
 {
 	UniVarsHashMap::const_iterator it = nameToUniVar.find(name);
 	return it != nameToUniVar.end();
@@ -302,7 +306,7 @@ bool ShaderProg::uniformVariableExists(const char* name) const
 //==============================================================================
 // attributeVariableExists                                                     =
 //==============================================================================
-bool ShaderProg::attributeVariableExists(const char* name) const
+bool ShaderProgram::attributeVariableExists(const char* name) const
 {
 	AttribVarsHashMap::const_iterator it = nameToAttribVar.find(name);
 	return it != nameToAttribVar.end();
@@ -312,7 +316,7 @@ bool ShaderProg::attributeVariableExists(const char* name) const
 //==============================================================================
 // createSrcCodeToCache                                                        =
 //==============================================================================
-std::string ShaderProg::createSrcCodeToCache(const char* sProgFPathName,
+std::string ShaderProgram::createSrcCodeToCache(const char* sProgFPathName,
 	const char* preAppendedSrcCode)
 {
 	if(strlen(preAppendedSrcCode) < 1)
@@ -354,15 +358,15 @@ std::string ShaderProg::createSrcCodeToCache(const char* sProgFPathName,
 //==============================================================================
 // getShaderInfoString                                                         =
 //==============================================================================
-std::string ShaderProg::getShaderInfoString() const
+std::string ShaderProgram::getShaderInfoString() const
 {
 	std::stringstream ss;
 
 	ss << "Variables:\n";
-	BOOST_FOREACH(const SProgVar& var, vars)
+	BOOST_FOREACH(const ShaderProgramVariable& var, vars)
 	{
 		ss << var.getName() << " " << var.getLoc() << " ";
-		if(var.getType() == SProgVar::SVT_ATTRIBUTE)
+		if(var.getType() == ShaderProgramVariable::SVT_ATTRIBUTE)
 		{
 			ss << "attribute";
 		}

+ 23 - 19
src/Resources/ShaderProg.h → src/Resources/ShaderProgram.h

@@ -1,13 +1,13 @@
-#ifndef SHADER_PROG_H
-#define SHADER_PROG_H
+#ifndef SHADER_PROGRAM_H
+#define SHADER_PROGRAM_H
 
 #include <boost/ptr_container/ptr_vector.hpp>
 #include <GL/glew.h>
 #include <limits>
 #include "Util/ConstCharPtrHashMap.h"
 #include "Util/Assert.h"
-#include "SProgUniVar.h"
-#include "SProgAttribVar.h"
+#include "UniformShaderProgramVariable.h"
+#include "AttributeShaderProgramVariable.h"
 #include "Util/Vec.h"
 #include "GfxApi/GlStateMachine.h"
 #include "Core/Globals.h"
@@ -23,16 +23,16 @@ class ShaderProgramPrePreprocessor;
 /// vector of attribute variables. Every variable is a struct that contains
 /// the variable's name, location, OpenGL data type and if it is a uniform or
 /// an attribute var.
-class ShaderProg
+class ShaderProgram
 {
 	public:
-		ShaderProg();
-		~ShaderProg();
+		ShaderProgram();
+		~ShaderProgram();
 
 		/// @name Accessors
 		/// @{
 		GLuint getGlId() const;
-		GETTER_R(boost::ptr_vector<SProgVar>, vars, getVariables)
+		GETTER_R(boost::ptr_vector<ShaderProgramVariable>, vars, getVariables)
 		/// @}
 
 		/// Resource load
@@ -46,9 +46,11 @@ class ShaderProg
 		/// variable not found so ask if the variable with that name exists
 		/// prior using any of these
 		/// @{
-		const SProgVar& getVariable(const char* varName) const;
-		const SProgUniVar& getUniformVariable(const char* varName) const;
-		const SProgAttribVar& getAttributeVariable(const char* varName) const;
+		const ShaderProgramVariable& getVariable(const char* varName) const;
+		const UniformShaderProgramVariable&
+			getUniformVariable(const char* varName) const;
+		const AttributeShaderProgramVariable&
+			getAttributeVariable(const char* varName) const;
 		/// @}
 
 		/// @name Check for variable existance
@@ -74,13 +76,15 @@ class ShaderProg
 
 	private:
 		/// XXX
-		typedef ConstCharPtrHashMap<SProgVar*>::Type VarsHashMap;
+		typedef ConstCharPtrHashMap<ShaderProgramVariable*>::Type VarsHashMap;
 
 		/// XXX
-		typedef ConstCharPtrHashMap<SProgUniVar*>::Type UniVarsHashMap;
+		typedef ConstCharPtrHashMap<UniformShaderProgramVariable*>::Type
+			UniVarsHashMap;
 
 		/// XXX
-		typedef ConstCharPtrHashMap<SProgAttribVar*>::Type AttribVarsHashMap;
+		typedef ConstCharPtrHashMap<AttributeShaderProgramVariable*>::Type
+			AttribVarsHashMap;
 
 		std::string rsrcFilename;
 		GLuint glId; ///< The OpenGL ID of the shader program
@@ -93,7 +97,7 @@ class ShaderProg
 
 		/// @name Containers
 		/// @{
-		boost::ptr_vector<SProgVar> vars; ///< All the vars
+		boost::ptr_vector<ShaderProgramVariable> vars; ///< All the vars
 		VarsHashMap nameToVar; ///< Variable searching
 		UniVarsHashMap nameToUniVar; ///< Uniform searching
 		AttribVarsHashMap nameToAttribVar; ///< Attribute searching
@@ -119,19 +123,19 @@ class ShaderProg
 // Inlines                                                                     =
 //==============================================================================
 
-inline ShaderProg::ShaderProg():
-	glId(std::numeric_limits<uint>::max())
+inline ShaderProgram::ShaderProgram()
+:	glId(std::numeric_limits<uint>::max())
 {}
 
 
-inline GLuint ShaderProg::getGlId() const
+inline GLuint ShaderProgram::getGlId() const
 {
 	ASSERT(glId != std::numeric_limits<uint>::max());
 	return glId;
 }
 
 
-inline void ShaderProg::bind() const
+inline void ShaderProgram::bind() const
 {
 	ASSERT(glId != std::numeric_limits<uint>::max());
 	GlStateMachineSingleton::getInstance().useShaderProg(glId);

+ 1 - 1
src/Resources/ShaderProgramPrePreprocessor.cpp

@@ -132,7 +132,7 @@ void ShaderProgramPrePreprocessor::parseFileForPragmas(
 }
 
 
-//==============================================================================
+//=============================================================================/
 // parseFile                                                                   =
 //==============================================================================
 void ShaderProgramPrePreprocessor::parseFile(const char* filename)

+ 12 - 10
src/Resources/SProgVar.h → src/Resources/ShaderProgramVariable.h

@@ -1,5 +1,5 @@
-#ifndef S_PROG_VAR_H
-#define S_PROG_VAR_H
+#ifndef SHADER_PROGRAM_VARIABLE_H
+#define SHADER_PROGRAM_VARIABLE_H
 
 #include <GL/glew.h>
 #include <string>
@@ -7,11 +7,11 @@
 #include "Util/Accessors.h"
 
 
-class ShaderProg;
+class ShaderProgram;
 
 
 /// Shader program variable. The type is attribute or uniform
-class SProgVar: public boost::noncopyable
+class ShaderProgramVariable: public boost::noncopyable
 {
 	public:
 		/// Shader var types
@@ -21,12 +21,13 @@ class SProgVar: public boost::noncopyable
 			SVT_UNIFORM    ///< SVT_UNIFORM
 		};
 
-		SProgVar(GLint loc_, const char* name_, GLenum glDataType_,
-			ShaderVarType type_, const ShaderProg& fatherSProg_);
+		ShaderProgramVariable(GLint loc_, const char* name_,
+			GLenum glDataType_, ShaderVarType type_,
+			const ShaderProgram& fatherSProg_);
 
 		/// @name Accessors
 		/// @{
-		const ShaderProg& getFatherSProg() const {return fatherSProg;}
+		const ShaderProgram& getFatherSProg() const {return fatherSProg;}
 		GETTER_R(GLint, loc, getLoc)
 		GETTER_R(std::string, name, getName)
 		GETTER_R(GLenum, glDataType, getGlDataType)
@@ -41,12 +42,13 @@ class SProgVar: public boost::noncopyable
 		GLenum glDataType;
 		ShaderVarType type; ///< @ref SVT_ATTRIBUTE or @ref SVT_UNIFORM
 		/// We need the ShaderProg of this variable mainly for sanity checks
-		const ShaderProg& fatherSProg;
+		const ShaderProgram& fatherSProg;
 };
 
 
-inline SProgVar::SProgVar(GLint loc_, const char* name_, GLenum glDataType_,
-	ShaderVarType type_, const ShaderProg& fatherSProg_)
+inline ShaderProgramVariable::ShaderProgramVariable(GLint loc_,
+	const char* name_, GLenum glDataType_,
+	ShaderVarType type_, const ShaderProgram& fatherSProg_)
 :	loc(loc_),
 	name(name_),
 	glDataType(glDataType_),

+ 9 - 9
src/Resources/SProgUniVar.cpp → src/Resources/UniformShaderProgramVariable.cpp

@@ -1,5 +1,5 @@
-#include "SProgUniVar.h"
-#include "Resources/ShaderProg.h"
+#include "UniformShaderProgramVariable.h"
+#include "Resources/ShaderProgram.h"
 #include "Resources/Texture.h"
 #include "GfxApi/GlStateMachine.h"
 
@@ -19,7 +19,7 @@
 		getName().c_str()) == getLoc());
 
 
-void SProgUniVar::set(const float f[], uint size) const
+void UniformShaderProgramVariable::set(const float f[], uint size) const
 {
 	STD_SET_UNI_CHECK();
 	ASSERT(getGlDataType() == GL_FLOAT);
@@ -34,7 +34,7 @@ void SProgUniVar::set(const float f[], uint size) const
 	}
 }
 
-void SProgUniVar::set(const Vec2 v2[], uint size) const
+void UniformShaderProgramVariable::set(const Vec2 v2[], uint size) const
 {
 	STD_SET_UNI_CHECK();
 	ASSERT(getGlDataType() == GL_FLOAT_VEC2);
@@ -48,7 +48,7 @@ void SProgUniVar::set(const Vec2 v2[], uint size) const
 	}
 }
 
-void SProgUniVar::set(const Vec3 v3[], uint size) const
+void UniformShaderProgramVariable::set(const Vec3 v3[], uint size) const
 {
 	STD_SET_UNI_CHECK();
 	ASSERT(getGlDataType() == GL_FLOAT_VEC3);
@@ -63,28 +63,28 @@ void SProgUniVar::set(const Vec3 v3[], uint size) const
 	}
 }
 
-void SProgUniVar::set(const Vec4 v4[], uint size) const
+void UniformShaderProgramVariable::set(const Vec4 v4[], uint size) const
 {
 	STD_SET_UNI_CHECK();
 	ASSERT(getGlDataType() == GL_FLOAT_VEC4);
 	glUniform4fv(getLoc(), size, &(const_cast<Vec4&>(v4[0]))[0]);
 }
 
-void SProgUniVar::set(const Mat3 m3[], uint size) const
+void UniformShaderProgramVariable::set(const Mat3 m3[], uint size) const
 {
 	STD_SET_UNI_CHECK();
 	ASSERT(getGlDataType() == GL_FLOAT_MAT3);
 	glUniformMatrix3fv(getLoc(), size, true, &(m3[0])[0]);
 }
 
-void SProgUniVar::set(const Mat4 m4[], uint size) const
+void UniformShaderProgramVariable::set(const Mat4 m4[], uint size) const
 {
 	STD_SET_UNI_CHECK();
 	ASSERT(getGlDataType() == GL_FLOAT_MAT4);
 	glUniformMatrix4fv(getLoc(), size, true, &(m4[0])[0]);
 }
 
-void SProgUniVar::set(const Texture& tex, uint texUnit) const
+void UniformShaderProgramVariable::set(const Texture& tex, uint texUnit) const
 {
 	STD_SET_UNI_CHECK();
 	ASSERT(getGlDataType() == GL_SAMPLER_2D ||

+ 39 - 0
src/Resources/UniformShaderProgramVariable.h

@@ -0,0 +1,39 @@
+#ifndef UNIFORM_SHADER_PROGRAM_VARIABLE_H
+#define UNIFORM_SHADER_PROGRAM_VARIABLE_H
+
+#include "ShaderProgramVariable.h"
+#include "Math/Math.h"
+
+
+class Texture;
+
+
+/// Uniform shader variable
+class UniformShaderProgramVariable: public ShaderProgramVariable
+{
+	public:
+		UniformShaderProgramVariable(int loc_, const char* name_,
+			GLenum glDataType_,
+			const ShaderProgram& fatherSProg_);
+
+		/// @name Set the var
+		/// @{
+		void set(const float f[], uint size = 1) const;
+		void set(const Vec2 v2[], uint size = 1) const;
+		void set(const Vec3 v3[], uint size = 1) const;
+		void set(const Vec4 v4[], uint size = 1) const;
+		void set(const Mat3 m3[], uint size = 1) const;
+		void set(const Mat4 m4[], uint size = 1) const;
+		void set(const Texture& tex, uint texUnit) const;
+		/// @}
+};
+
+
+inline UniformShaderProgramVariable::UniformShaderProgramVariable(
+	int loc_, const char* name_,
+	GLenum glDataType_, const ShaderProgram& fatherSProg_)
+:	ShaderProgramVariable(loc_, name_, glDataType_, SVT_UNIFORM, fatherSProg_)
+{}
+
+
+#endif

+ 26 - 16
src/Resources/UserMaterialVariable.cpp

@@ -1,5 +1,5 @@
 #include "UserMaterialVariable.h"
-#include "SProgUniVar.h"
+#include "UniformShaderProgramVariable.h"
 #include "Texture.h"
 
 
@@ -7,45 +7,55 @@
 // Constructors                                                                =
 //==============================================================================
 
-UserMaterialVariable::UserMaterialVariable(const SProgUniVar* cpSProgUniVar,
-	const SProgUniVar* dpSProgUniVar, float val)
-:	MaterialVariable(T_USER, cpSProgUniVar, dpSProgUniVar)
+UserMaterialVariable::UserMaterialVariable(
+	const UniformShaderProgramVariable* cpUni,
+	const UniformShaderProgramVariable* dpUni,
+	float val)
+:	MaterialVariable(T_USER, cpUni, dpUni)
 {
 	ASSERT(getGlDataType() == GL_FLOAT);
 	data.scalar = val;
 }
 
 
-UserMaterialVariable::UserMaterialVariable(const SProgUniVar* cpSProgUniVar,
-	const SProgUniVar* dpSProgUniVar, const Vec2& val)
-:	MaterialVariable(T_USER, cpSProgUniVar, dpSProgUniVar)
+UserMaterialVariable::UserMaterialVariable(
+	const UniformShaderProgramVariable* cpUni,
+	const UniformShaderProgramVariable* dpUni,
+	const Vec2& val)
+:	MaterialVariable(T_USER, cpUni, dpUni)
 {
 	ASSERT(getGlDataType() == GL_FLOAT_VEC2);
 	data.vec2 = val;
 }
 
 
-UserMaterialVariable::UserMaterialVariable(const SProgUniVar* cpSProgUniVar,
-	const SProgUniVar* dpSProgUniVar, const Vec3& val)
-:	MaterialVariable(T_USER, cpSProgUniVar, dpSProgUniVar)
+UserMaterialVariable::UserMaterialVariable(
+	const UniformShaderProgramVariable* cpUni,
+	const UniformShaderProgramVariable* dpUni,
+	const Vec3& val)
+:	MaterialVariable(T_USER, cpUni, dpUni)
 {
 	ASSERT(getGlDataType() == GL_FLOAT_VEC3);
 	data.vec3 = val;
 }
 
 
-UserMaterialVariable::UserMaterialVariable(const SProgUniVar* cpSProgUniVar,
-	const SProgUniVar* dpSProgUniVar, const Vec4& val)
-:	MaterialVariable(T_USER, cpSProgUniVar, dpSProgUniVar)
+UserMaterialVariable::UserMaterialVariable(
+	const UniformShaderProgramVariable* cpUni,
+	const UniformShaderProgramVariable* dpUni,
+	const Vec4& val)
+:	MaterialVariable(T_USER, cpUni, dpUni)
 {
 	ASSERT(getGlDataType() == GL_FLOAT_VEC4);
 	data.vec4 = val;
 }
 
 
-UserMaterialVariable::UserMaterialVariable(const SProgUniVar* cpSProgUniVar,
-	const SProgUniVar* dpSProgUniVar, const char* texFilename)
-:	MaterialVariable(T_USER, cpSProgUniVar, dpSProgUniVar)
+UserMaterialVariable::UserMaterialVariable(
+	const UniformShaderProgramVariable* cpUni,
+	const UniformShaderProgramVariable* dpUni,
+	const char* texFilename)
+:	MaterialVariable(T_USER, cpUni, dpUni)
 {
 	ASSERT(getGlDataType() == GL_SAMPLER_2D);
 	data.texture.loadRsrc(texFilename);

+ 11 - 11
src/Resources/UserMaterialVariable.h

@@ -7,7 +7,7 @@
 
 
 class Texture;
-class SProgUniVar;
+class UniformShaderProgramVariable;
 
 
 /// XXX
@@ -26,16 +26,16 @@ class UserMaterialVariable: public MaterialVariable
 
 		/// @name Constructors
 		/// @{
-		UserMaterialVariable(const SProgUniVar* cpSProgUniVar,
-			const SProgUniVar* dpSProgUniVar, float val);
-		UserMaterialVariable(const SProgUniVar* cpSProgUniVar,
-			const SProgUniVar* dpSProgUniVar, const Vec2& val);
-		UserMaterialVariable(const SProgUniVar* cpSProgUniVar,
-			const SProgUniVar* dpSProgUniVar, const Vec3& val);
-		UserMaterialVariable(const SProgUniVar* cpSProgUniVar,
-			const SProgUniVar* dpSProgUniVar, const Vec4& val);
-		UserMaterialVariable(const SProgUniVar* cpSProgUniVar,
-			const SProgUniVar* dpSProgUniVar, const char* texFilename);
+		UserMaterialVariable(const UniformShaderProgramVariable* cpUni,
+			const UniformShaderProgramVariable* dpUni, float val);
+		UserMaterialVariable(const UniformShaderProgramVariable* cpUni,
+			const UniformShaderProgramVariable* dpUni, const Vec2& val);
+		UserMaterialVariable(const UniformShaderProgramVariable* cpUni,
+			const UniformShaderProgramVariable* dpUni, const Vec3& val);
+		UserMaterialVariable(const UniformShaderProgramVariable* cpUni,
+			const UniformShaderProgramVariable* dpUni, const Vec4& val);
+		UserMaterialVariable(const UniformShaderProgramVariable* cpUni,
+			const UniformShaderProgramVariable* dpUni, const char* texFilename);
 		/// @}
 
 		/// @name Accessors

+ 6 - 5
src/Scene/MaterialRuntime.h

@@ -64,10 +64,11 @@ class MaterialRuntime: private MaterialProps
 		GETTER_SETTER_BY_VAL(bool, wireframe, isWireframeEnabled,
 			setWireframeEnabled)
 
-		const SProgAttribVar* getStdAttribVar(
+		const AttributeShaderProgramVariable* getStdAttribVar(
 			Material::StdAttribVars id) const;
-		const SProgUniVar* getStdUniVar(Material::StdUniVars id) const;
-		const ShaderProg& getShaderProg() const {return mtl.getShaderProg();}
+		const UniformShaderProgramVariable*
+			getStdUniVar(Material::StdUniVars id) const;
+		const ShaderProgram& getShaderProg() const {return mtl.getShaderProg();}
 		/// @}
 
 		bool isBlendingEnabled() const;
@@ -102,14 +103,14 @@ void MaterialRuntime::setUserDefVarValue(const char* name, const Type& value)
 }
 
 
-inline const SProgAttribVar* MaterialRuntime::getStdAttribVar(
+inline const AttributeShaderProgramVariable* MaterialRuntime::getStdAttribVar(
 	Material::StdAttribVars id) const
 {
 	return mtl.getStdAttribVar(id);
 }
 
 
-inline const SProgUniVar* MaterialRuntime::getStdUniVar(
+inline const UniformShaderProgramVariable* MaterialRuntime::getStdUniVar(
 	Material::StdUniVars id) const
 {
 	return mtl.getStdUniVar(id);

+ 1 - 1
src/Scene/MaterialRuntimeUserDefinedVar.h

@@ -20,7 +20,7 @@ class MaterialRuntimeUserDefinedVar
 
 		/// @name Accessors
 		/// @{
-		const SProgUniVar& getUniVar() const {return rsrc.getUniVar();}
+		const UniformShaderProgramVariable& getUniVar() const {return rsrc.getUniVar();}
 
 		const std::string& getName() const {return getUniVar().getName();}
 

+ 1 - 1
src/Ui/Painter.h

@@ -38,7 +38,7 @@ class Painter
 		/// @name Data
 		/// @{
 		boost::scoped_ptr<Font> font;
-		RsrcPtr<ShaderProg> sProg;
+		RsrcPtr<ShaderProgram> sProg;
 
 		Vec2 pos;
 		Vec4 col;

+ 5 - 3
src/Util/Assert.h

@@ -5,14 +5,16 @@
 #include <cstdlib>
 
 
-/// Assertion. Print an error and stop the debugger (if it runs through a debugger) and then abort
+/// Assertion. Print an error and stop the debugger (if it runs through a
+/// debugger) and then abort
 #if defined(NDEBUG)
 #	define ASSERT(x) ((void)0)
 #else
 #	define ASSERT(x) \
 		if(!(x)) { \
-			std::cerr << "(" << __FILE__ << ":" << __LINE__ << " " << __func__ << ") " << \
-			             "Assertion failed: " << #x << std::endl; \
+			std::cerr << "(" << __FILE__ << ":" << __LINE__ << " " << \
+				__func__ << ") " << \
+				"Assertion failed: " << #x << std::endl; \
 			asm("int $3"); \
 			abort(); \
 		}