Panagiotis Christopoulos Charitos vor 14 Jahren
Ursprung
Commit
08a0eea503
40 geänderte Dateien mit 1116 neuen und 903 gelöschten Zeilen
  1. 252 250
      .cproject
  2. 0 24
      src/Resources/AttributeShaderProgramVariable.h
  3. 2 2
      src/Resources/CMakeLists.txt
  4. 6 202
      src/Resources/Material.h
  5. 6 2
      src/Resources/Model.cpp
  6. 14 3
      src/Resources/ModelPatch.cpp
  7. 6 4
      src/Resources/ModelPatch.h
  8. 1 1
      src/Resources/ResourceManager.h
  9. 4 137
      src/Resources/ShaderProgram.h
  10. 0 39
      src/Resources/UniformShaderProgramVariable.h
  11. 14 8
      src/Resources/material/BuildinVariable.cpp
  12. 10 5
      src/Resources/material/BuildinVariable.h
  13. 13 0
      src/Resources/material/Common.cpp
  14. 25 0
      src/Resources/material/Common.h
  15. 30 26
      src/Resources/material/Material.cpp
  16. 189 0
      src/Resources/material/Material.h
  17. 35 0
      src/Resources/material/Properties.h
  18. 26 20
      src/Resources/material/ShaderProgramCreator.cpp
  19. 8 3
      src/Resources/material/ShaderProgramCreator.h
  20. 29 19
      src/Resources/material/UserVariable.cpp
  21. 22 16
      src/Resources/material/UserVariable.h
  22. 10 4
      src/Resources/material/Variable.cpp
  23. 15 16
      src/Resources/material/Variable.h
  24. 30 0
      src/Resources/shader_program/AttributeVariable.h
  25. 15 0
      src/Resources/shader_program/Fwd.h
  26. 15 10
      src/Resources/shader_program/PrePreprocessor.cpp
  27. 16 10
      src/Resources/shader_program/PrePreprocessor.h
  28. 23 18
      src/Resources/shader_program/ShaderProgram.cpp
  29. 149 0
      src/Resources/shader_program/ShaderProgram.h
  30. 39 25
      src/Resources/shader_program/UniformVariable.cpp
  31. 52 0
      src/Resources/shader_program/UniformVariable.h
  32. 15 9
      src/Resources/shader_program/Variable.h
  33. 9 9
      src/Scene/MaterialRuntime.cpp
  34. 5 5
      src/Scene/MaterialRuntime.h
  35. 0 2
      src/Scene/ModelNode.h
  36. 0 1
      src/Scene/ModelPatchNode.h
  37. 2 3
      src/Scene/PatchNode.h
  38. 8 9
      src/Scene/RenderableNode.h
  39. 11 11
      src/Scene/UserMaterialVariableRuntime.cpp
  40. 10 10
      src/Scene/UserMaterialVariableRuntime.h

+ 252 - 250
.cproject

@@ -29,266 +29,268 @@
 						</toolChain>
 						</toolChain>
 					</folderInfo>
 					</folderInfo>
 					<sourceEntries>
 					<sourceEntries>
-						<entry excluding="include|Collision|src" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
 						<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="src"/>
 						<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="src"/>
+						<entry excluding="include|Collision|src" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
 					</sourceEntries>
 					</sourceEntries>
 				</configuration>
 				</configuration>
 			</storageModule>
 			</storageModule>
 			<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
 			<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
 			<storageModule moduleId="org.eclipse.cdt.core.language.mapping"/>
 			<storageModule moduleId="org.eclipse.cdt.core.language.mapping"/>
 			<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
 			<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
-			<storageModule moduleId="scannerConfiguration">
-				<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
-				<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
-					<buildOutputProvider>
-						<openAction enabled="true" filePath=""/>
-						<parser enabled="true"/>
-					</buildOutputProvider>
-					<scannerInfoProvider id="specsFile">
-						<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
-						<parser enabled="true"/>
-					</scannerInfoProvider>
-				</profile>
-				<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
-					<buildOutputProvider>
-						<openAction enabled="true" filePath=""/>
-						<parser enabled="true"/>
-					</buildOutputProvider>
-					<scannerInfoProvider id="makefileGenerator">
-						<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
-						<parser enabled="true"/>
-					</scannerInfoProvider>
-				</profile>
-				<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
-					<buildOutputProvider>
-						<openAction enabled="true" filePath=""/>
-						<parser enabled="true"/>
-					</buildOutputProvider>
-					<scannerInfoProvider id="specsFile">
-						<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
-						<parser enabled="true"/>
-					</scannerInfoProvider>
-				</profile>
-				<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
-					<buildOutputProvider>
-						<openAction enabled="true" filePath=""/>
-						<parser enabled="true"/>
-					</buildOutputProvider>
-					<scannerInfoProvider id="specsFile">
-						<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
-						<parser enabled="true"/>
-					</scannerInfoProvider>
-				</profile>
-				<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
-					<buildOutputProvider>
-						<openAction enabled="true" filePath=""/>
-						<parser enabled="true"/>
-					</buildOutputProvider>
-					<scannerInfoProvider id="specsFile">
-						<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
-						<parser enabled="true"/>
-					</scannerInfoProvider>
-				</profile>
-				<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
-					<buildOutputProvider>
-						<openAction enabled="true" filePath=""/>
-						<parser enabled="true"/>
-					</buildOutputProvider>
-					<scannerInfoProvider id="specsFile">
-						<runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/${specs_file}&quot;'" command="sh" useDefault="true"/>
-						<parser enabled="true"/>
-					</scannerInfoProvider>
-				</profile>
-				<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
-					<buildOutputProvider>
-						<openAction enabled="true" filePath=""/>
-						<parser enabled="true"/>
-					</buildOutputProvider>
-					<scannerInfoProvider id="specsFile">
-						<runAction arguments="-c 'g++ -E -P -v -dD &quot;${plugin_state_location}/specs.cpp&quot;'" command="sh" useDefault="true"/>
-						<parser enabled="true"/>
-					</scannerInfoProvider>
-				</profile>
-				<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
-					<buildOutputProvider>
-						<openAction enabled="true" filePath=""/>
-						<parser enabled="true"/>
-					</buildOutputProvider>
-					<scannerInfoProvider id="specsFile">
-						<runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/specs.c&quot;'" command="sh" useDefault="true"/>
-						<parser enabled="true"/>
-					</scannerInfoProvider>
-				</profile>
-				<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.cross.base.1593777304;cdt.managedbuild.toolchain.gnu.cross.base.1593777304.1771284297;cdt.managedbuild.tool.gnu.cross.cpp.compiler.454660912;cdt.managedbuild.tool.gnu.cpp.compiler.input.264866474">
-					<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
-					<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
-						<buildOutputProvider>
-							<openAction enabled="true" filePath=""/>
-							<parser enabled="true"/>
-						</buildOutputProvider>
-						<scannerInfoProvider id="specsFile">
-							<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
-							<parser enabled="true"/>
-						</scannerInfoProvider>
-					</profile>
-					<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
-						<buildOutputProvider>
-							<openAction enabled="true" filePath=""/>
-							<parser enabled="true"/>
-						</buildOutputProvider>
-						<scannerInfoProvider id="makefileGenerator">
-							<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
-							<parser enabled="true"/>
-						</scannerInfoProvider>
-					</profile>
-					<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
-						<buildOutputProvider>
-							<openAction enabled="true" filePath=""/>
-							<parser enabled="true"/>
-						</buildOutputProvider>
-						<scannerInfoProvider id="specsFile">
-							<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
-							<parser enabled="true"/>
-						</scannerInfoProvider>
-					</profile>
-					<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
-						<buildOutputProvider>
-							<openAction enabled="true" filePath=""/>
-							<parser enabled="true"/>
-						</buildOutputProvider>
-						<scannerInfoProvider id="specsFile">
-							<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
-							<parser enabled="true"/>
-						</scannerInfoProvider>
-					</profile>
-					<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
-						<buildOutputProvider>
-							<openAction enabled="true" filePath=""/>
-							<parser enabled="true"/>
-						</buildOutputProvider>
-						<scannerInfoProvider id="specsFile">
-							<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
-							<parser enabled="true"/>
-						</scannerInfoProvider>
-					</profile>
-					<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
-						<buildOutputProvider>
-							<openAction enabled="true" filePath=""/>
-							<parser enabled="true"/>
-						</buildOutputProvider>
-						<scannerInfoProvider id="specsFile">
-							<runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/${specs_file}&quot;'" command="sh" useDefault="true"/>
-							<parser enabled="true"/>
-						</scannerInfoProvider>
-					</profile>
-					<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
-						<buildOutputProvider>
-							<openAction enabled="true" filePath=""/>
-							<parser enabled="true"/>
-						</buildOutputProvider>
-						<scannerInfoProvider id="specsFile">
-							<runAction arguments="-c 'g++ -E -P -v -dD &quot;${plugin_state_location}/specs.cpp&quot;'" command="sh" useDefault="true"/>
-							<parser enabled="true"/>
-						</scannerInfoProvider>
-					</profile>
-					<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
-						<buildOutputProvider>
-							<openAction enabled="true" filePath=""/>
-							<parser enabled="true"/>
-						</buildOutputProvider>
-						<scannerInfoProvider id="specsFile">
-							<runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/specs.c&quot;'" command="sh" useDefault="true"/>
-							<parser enabled="true"/>
-						</scannerInfoProvider>
-					</profile>
-				</scannerConfigBuildInfo>
-				<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.cross.base.1593777304">
-					<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
-					<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
-						<buildOutputProvider>
-							<openAction enabled="true" filePath=""/>
-							<parser enabled="true"/>
-						</buildOutputProvider>
-						<scannerInfoProvider id="specsFile">
-							<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
-							<parser enabled="true"/>
-						</scannerInfoProvider>
-					</profile>
-					<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
-						<buildOutputProvider>
-							<openAction enabled="true" filePath=""/>
-							<parser enabled="true"/>
-						</buildOutputProvider>
-						<scannerInfoProvider id="makefileGenerator">
-							<runAction arguments="-E -P -v -dD" command="" useDefault="true"/>
-							<parser enabled="true"/>
-						</scannerInfoProvider>
-					</profile>
-					<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
-						<buildOutputProvider>
-							<openAction enabled="true" filePath=""/>
-							<parser enabled="true"/>
-						</buildOutputProvider>
-						<scannerInfoProvider id="specsFile">
-							<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
-							<parser enabled="true"/>
-						</scannerInfoProvider>
-					</profile>
-					<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
-						<buildOutputProvider>
-							<openAction enabled="true" filePath=""/>
-							<parser enabled="true"/>
-						</buildOutputProvider>
-						<scannerInfoProvider id="specsFile">
-							<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
-							<parser enabled="true"/>
-						</scannerInfoProvider>
-					</profile>
-					<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
-						<buildOutputProvider>
-							<openAction enabled="true" filePath=""/>
-							<parser enabled="true"/>
-						</buildOutputProvider>
-						<scannerInfoProvider id="specsFile">
-							<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
-							<parser enabled="true"/>
-						</scannerInfoProvider>
-					</profile>
-					<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
-						<buildOutputProvider>
-							<openAction enabled="true" filePath=""/>
-							<parser enabled="true"/>
-						</buildOutputProvider>
-						<scannerInfoProvider id="specsFile">
-							<runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/${specs_file}&quot;'" command="sh" useDefault="true"/>
-							<parser enabled="true"/>
-						</scannerInfoProvider>
-					</profile>
-					<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
-						<buildOutputProvider>
-							<openAction enabled="true" filePath=""/>
-							<parser enabled="true"/>
-						</buildOutputProvider>
-						<scannerInfoProvider id="specsFile">
-							<runAction arguments="-c 'g++ -E -P -v -dD &quot;${plugin_state_location}/specs.cpp&quot;'" command="sh" useDefault="true"/>
-							<parser enabled="true"/>
-						</scannerInfoProvider>
-					</profile>
-					<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
-						<buildOutputProvider>
-							<openAction enabled="true" filePath=""/>
-							<parser enabled="true"/>
-						</buildOutputProvider>
-						<scannerInfoProvider id="specsFile">
-							<runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/specs.c&quot;'" command="sh" useDefault="true"/>
-							<parser enabled="true"/>
-						</scannerInfoProvider>
-					</profile>
-				</scannerConfigBuildInfo>
-			</storageModule>
 		</cconfiguration>
 		</cconfiguration>
 	</storageModule>
 	</storageModule>
 	<storageModule moduleId="cdtBuildSystem" version="4.0.0">
 	<storageModule moduleId="cdtBuildSystem" version="4.0.0">
 		<project id="anki.null.323176720" name="anki"/>
 		<project id="anki.null.323176720" name="anki"/>
 	</storageModule>
 	</storageModule>
+	<storageModule moduleId="scannerConfiguration">
+		<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
+		<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
+			<buildOutputProvider>
+				<openAction enabled="true" filePath=""/>
+				<parser enabled="true"/>
+			</buildOutputProvider>
+			<scannerInfoProvider id="specsFile">
+				<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+				<parser enabled="true"/>
+			</scannerInfoProvider>
+		</profile>
+		<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
+			<buildOutputProvider>
+				<openAction enabled="true" filePath=""/>
+				<parser enabled="true"/>
+			</buildOutputProvider>
+			<scannerInfoProvider id="makefileGenerator">
+				<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
+				<parser enabled="true"/>
+			</scannerInfoProvider>
+		</profile>
+		<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
+			<buildOutputProvider>
+				<openAction enabled="true" filePath=""/>
+				<parser enabled="true"/>
+			</buildOutputProvider>
+			<scannerInfoProvider id="specsFile">
+				<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+				<parser enabled="true"/>
+			</scannerInfoProvider>
+		</profile>
+		<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
+			<buildOutputProvider>
+				<openAction enabled="true" filePath=""/>
+				<parser enabled="true"/>
+			</buildOutputProvider>
+			<scannerInfoProvider id="specsFile">
+				<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
+				<parser enabled="true"/>
+			</scannerInfoProvider>
+		</profile>
+		<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
+			<buildOutputProvider>
+				<openAction enabled="true" filePath=""/>
+				<parser enabled="true"/>
+			</buildOutputProvider>
+			<scannerInfoProvider id="specsFile">
+				<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
+				<parser enabled="true"/>
+			</scannerInfoProvider>
+		</profile>
+		<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
+			<buildOutputProvider>
+				<openAction enabled="true" filePath=""/>
+				<parser enabled="true"/>
+			</buildOutputProvider>
+			<scannerInfoProvider id="specsFile">
+				<runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/${specs_file}&quot;'" command="sh" useDefault="true"/>
+				<parser enabled="true"/>
+			</scannerInfoProvider>
+		</profile>
+		<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
+			<buildOutputProvider>
+				<openAction enabled="true" filePath=""/>
+				<parser enabled="true"/>
+			</buildOutputProvider>
+			<scannerInfoProvider id="specsFile">
+				<runAction arguments="-c 'g++ -E -P -v -dD &quot;${plugin_state_location}/specs.cpp&quot;'" command="sh" useDefault="true"/>
+				<parser enabled="true"/>
+			</scannerInfoProvider>
+		</profile>
+		<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
+			<buildOutputProvider>
+				<openAction enabled="true" filePath=""/>
+				<parser enabled="true"/>
+			</buildOutputProvider>
+			<scannerInfoProvider id="specsFile">
+				<runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/specs.c&quot;'" command="sh" useDefault="true"/>
+				<parser enabled="true"/>
+			</scannerInfoProvider>
+		</profile>
+		<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.cross.base.1593777304;cdt.managedbuild.toolchain.gnu.cross.base.1593777304.1771284297;cdt.managedbuild.tool.gnu.cross.cpp.compiler.454660912;cdt.managedbuild.tool.gnu.cpp.compiler.input.264866474">
+			<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
+			<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
+				<buildOutputProvider>
+					<openAction enabled="true" filePath=""/>
+					<parser enabled="true"/>
+				</buildOutputProvider>
+				<scannerInfoProvider id="specsFile">
+					<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+					<parser enabled="true"/>
+				</scannerInfoProvider>
+			</profile>
+			<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
+				<buildOutputProvider>
+					<openAction enabled="true" filePath=""/>
+					<parser enabled="true"/>
+				</buildOutputProvider>
+				<scannerInfoProvider id="makefileGenerator">
+					<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
+					<parser enabled="true"/>
+				</scannerInfoProvider>
+			</profile>
+			<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
+				<buildOutputProvider>
+					<openAction enabled="true" filePath=""/>
+					<parser enabled="true"/>
+				</buildOutputProvider>
+				<scannerInfoProvider id="specsFile">
+					<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+					<parser enabled="true"/>
+				</scannerInfoProvider>
+			</profile>
+			<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
+				<buildOutputProvider>
+					<openAction enabled="true" filePath=""/>
+					<parser enabled="true"/>
+				</buildOutputProvider>
+				<scannerInfoProvider id="specsFile">
+					<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
+					<parser enabled="true"/>
+				</scannerInfoProvider>
+			</profile>
+			<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
+				<buildOutputProvider>
+					<openAction enabled="true" filePath=""/>
+					<parser enabled="true"/>
+				</buildOutputProvider>
+				<scannerInfoProvider id="specsFile">
+					<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
+					<parser enabled="true"/>
+				</scannerInfoProvider>
+			</profile>
+			<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
+				<buildOutputProvider>
+					<openAction enabled="true" filePath=""/>
+					<parser enabled="true"/>
+				</buildOutputProvider>
+				<scannerInfoProvider id="specsFile">
+					<runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/${specs_file}&quot;'" command="sh" useDefault="true"/>
+					<parser enabled="true"/>
+				</scannerInfoProvider>
+			</profile>
+			<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
+				<buildOutputProvider>
+					<openAction enabled="true" filePath=""/>
+					<parser enabled="true"/>
+				</buildOutputProvider>
+				<scannerInfoProvider id="specsFile">
+					<runAction arguments="-c 'g++ -E -P -v -dD &quot;${plugin_state_location}/specs.cpp&quot;'" command="sh" useDefault="true"/>
+					<parser enabled="true"/>
+				</scannerInfoProvider>
+			</profile>
+			<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
+				<buildOutputProvider>
+					<openAction enabled="true" filePath=""/>
+					<parser enabled="true"/>
+				</buildOutputProvider>
+				<scannerInfoProvider id="specsFile">
+					<runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/specs.c&quot;'" command="sh" useDefault="true"/>
+					<parser enabled="true"/>
+				</scannerInfoProvider>
+			</profile>
+		</scannerConfigBuildInfo>
+		<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.cross.base.1593777304">
+			<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
+			<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
+				<buildOutputProvider>
+					<openAction enabled="true" filePath=""/>
+					<parser enabled="true"/>
+				</buildOutputProvider>
+				<scannerInfoProvider id="specsFile">
+					<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+					<parser enabled="true"/>
+				</scannerInfoProvider>
+			</profile>
+			<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
+				<buildOutputProvider>
+					<openAction enabled="true" filePath=""/>
+					<parser enabled="true"/>
+				</buildOutputProvider>
+				<scannerInfoProvider id="makefileGenerator">
+					<runAction arguments="-E -P -v -dD" command="" useDefault="true"/>
+					<parser enabled="true"/>
+				</scannerInfoProvider>
+			</profile>
+			<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
+				<buildOutputProvider>
+					<openAction enabled="true" filePath=""/>
+					<parser enabled="true"/>
+				</buildOutputProvider>
+				<scannerInfoProvider id="specsFile">
+					<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+					<parser enabled="true"/>
+				</scannerInfoProvider>
+			</profile>
+			<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
+				<buildOutputProvider>
+					<openAction enabled="true" filePath=""/>
+					<parser enabled="true"/>
+				</buildOutputProvider>
+				<scannerInfoProvider id="specsFile">
+					<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
+					<parser enabled="true"/>
+				</scannerInfoProvider>
+			</profile>
+			<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
+				<buildOutputProvider>
+					<openAction enabled="true" filePath=""/>
+					<parser enabled="true"/>
+				</buildOutputProvider>
+				<scannerInfoProvider id="specsFile">
+					<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
+					<parser enabled="true"/>
+				</scannerInfoProvider>
+			</profile>
+			<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
+				<buildOutputProvider>
+					<openAction enabled="true" filePath=""/>
+					<parser enabled="true"/>
+				</buildOutputProvider>
+				<scannerInfoProvider id="specsFile">
+					<runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/${specs_file}&quot;'" command="sh" useDefault="true"/>
+					<parser enabled="true"/>
+				</scannerInfoProvider>
+			</profile>
+			<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
+				<buildOutputProvider>
+					<openAction enabled="true" filePath=""/>
+					<parser enabled="true"/>
+				</buildOutputProvider>
+				<scannerInfoProvider id="specsFile">
+					<runAction arguments="-c 'g++ -E -P -v -dD &quot;${plugin_state_location}/specs.cpp&quot;'" command="sh" useDefault="true"/>
+					<parser enabled="true"/>
+				</scannerInfoProvider>
+			</profile>
+			<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
+				<buildOutputProvider>
+					<openAction enabled="true" filePath=""/>
+					<parser enabled="true"/>
+				</buildOutputProvider>
+				<scannerInfoProvider id="specsFile">
+					<runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/specs.c&quot;'" command="sh" useDefault="true"/>
+					<parser enabled="true"/>
+				</scannerInfoProvider>
+			</profile>
+		</scannerConfigBuildInfo>
+	</storageModule>
+	<storageModule moduleId="refreshScope"/>
+	<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
 </cproject>
 </cproject>

+ 0 - 24
src/Resources/AttributeShaderProgramVariable.h

@@ -1,24 +0,0 @@
-#ifndef ATTRIBUTE_SHADER_PROGRAM_VARIABLE_H
-#define ATTRIBUTE_SHADER_PROGRAM_VARIABLE_H
-
-#include "ShaderProgramVariable.h"
-
-
-/// Attribute shader program 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_, ATTRIBUTE, fatherSProg_)
-{}
-
-
-#endif

+ 2 - 2
src/Resources/CMakeLists.txt

@@ -1,4 +1,4 @@
-FILE(GLOB RESOURCES_SOURCES *.cpp)
-FILE(GLOB RESOURCES_HEADERS *.h)
+FILE(GLOB_RECURSE RESOURCES_SOURCES *.cpp)
+FILE(GLOB_RECURSE RESOURCES_HEADERS *.h)
 
 
 ADD_LIBRARY(Resources ${RESOURCES_SOURCES} ${RESOURCES_HEADERS})
 ADD_LIBRARY(Resources ${RESOURCES_SOURCES} ${RESOURCES_HEADERS})

+ 6 - 202
src/Resources/Material.h

@@ -1,208 +1,12 @@
-#ifndef MATERIAL_2_H
-#define MATERIAL_2_H
+#ifndef MATERIAL_H
+#define MATERIAL_H
 
 
-#include "Util/Accessors.h"
-#include "Util/ConstCharPtrHashMap.h"
-#include "UserMaterialVariable.h"
-#include "BuildinMaterialVariable.h"
-#include "RsrcPtr.h"
-#include <GL/glew.h>
-#include <boost/ptr_container/ptr_vector.hpp>
-#include <boost/array.hpp>
-#include <boost/scoped_ptr.hpp>
-#include <boost/property_tree/ptree_fwd.hpp>
+#include "material/Material.h"
 
 
 
 
-class AttributeShaderProgramVariable;
-class UniformShaderProgramVariable;
-class ShaderProgram;
-namespace Scanner {
-class Scanner;
-}
-
-
-/// Contains a few properties that other classes may use
-struct MaterialProperties
-{
-	public:
-		/// Check if blending is enabled
-		bool isBlendingEnabled() const
-			{return blendingSfactor != GL_ONE || blendingDfactor != GL_ZERO;}
-
-	protected:
-		/// Used in depth passes of shadowmapping and not in other depth passes
-		/// like EarlyZ
-		bool castsShadowFlag;
-		/// The entities with blending are being rendered in blending stage and
-		/// those without in material stage
-		bool renderInBlendingStageFlag;
-		int blendingSfactor; ///< Default GL_ONE
-		int blendingDfactor; ///< Default GL_ZERO
-		bool depthTesting;
-		bool wireframe;
-};
-
-
-/// Material resource
-///
-/// Every material keeps info of how to render a RenedrableNode. Using a node
-/// based logic it creates a couple of shader programs dynamically. One for
-/// color passes and one for depth. It also keeps two sets of material
-/// variables. The first is the build in and the second the user defined.
-/// During the renderer's shader setup the buildins will be set automatically,
-/// for the user variables the user needs to have its value in the material
-/// file. Some material variables may be present in both shader programs and
-/// some in only one of them
-///
-/// Material XML file format:
-/// @code
-/// <material>
-/// 	<castsShadow>true | false</castsShadow>
-///
-/// 	<renderInBlendingStage>true | false</renderInBlendingStage>
-///
-/// 	<blendFunctions>
-/// 		<sFactor>GL_SOMETHING</sFactor>
-/// 		<dFactor>GL_SOMETHING</dFactor>
-/// 	</blendFunctions>
-///
-/// 	<depthTesting>true | false</depthTesting>
-///
-/// 	<wireframe>true | false</wireframe>
-///
-/// 	<shaderProgram>
-/// 		<includes>
-/// 			<include>file.glsl</include>
-/// 			<include>file2.glsl</include>
-/// 		</includes>
-///
-/// 		<inputs>
-/// 			<input> *
-/// 				<name>xx</name>
-/// 				<value>
-/// 					<float>0.0</float> |
-/// 					<vec2><x>0.0</x><y>0.0</y></vec2> |
-/// 					<vec3><x>0.0</x><y>0.0</y><z>0.0</z></vec3> |
-/// 					<vec4><x>0.0</x><y>0.0</y><z>0.0</z><w>0.0</w></vec4> |
-/// 					<sampler2D>path/to/image.tga</sampler2D>
-/// 				</value>
-/// 			</input>
-/// 		</inputs>
-///
-/// 		<operations>
-/// 			<operation>
-/// 				<id>x</id>
-/// 				<function>functionName</function>
-/// 				<arguments>
-/// 					<argument>xx</argument>
-/// 					<argument>yy</argument>
-/// 				</arguments>
-/// 			</operation>
-/// 		</operations>
-///
-/// 	</shaderProgram>
-/// </material>
-/// @endcode
-/// *: For if the value is not set then the in variable will be build in or
-///    standard varying
-class Material: private MaterialProperties
-{
-	public:
-		//======================================================================
-		// Nested                                                              =
-		//======================================================================
-
-		typedef boost::ptr_vector<MaterialVariable> VarsContainer;
-
-		typedef boost::unordered_map<BuildinMaterialVariable::BuildinEnum,
-			BuildinMaterialVariable*> BuildinEnumToBuildinHashMap;
-
-		typedef boost::array<BuildinMaterialVariable*,
-			BuildinMaterialVariable::BUILDINS_NUM> BuildinsArr;
-
-		//======================================================================
-		// Methods                                                             =
-		//======================================================================
-
-		/// Initialize with default values
-		Material();
-
-		~Material();
-
-		/// @name Accessors
-		/// @{
-		GETTER_R_BY_VAL(bool, castsShadowFlag, castsShadow)
-		GETTER_R_BY_VAL(bool, renderInBlendingStageFlag, rendersInBlendingStage)
-		GETTER_R_BY_VAL(int, blendingSfactor, getBlendingSfactor)
-		GETTER_R_BY_VAL(int, blendingDfactor, getBlendingDfactor)
-		GETTER_R_BY_VAL(bool, depthTesting, isDepthTestingEnabled)
-		GETTER_R_BY_VAL(bool, wireframe, isWireframeEnabled)
-
-		/// Access the base class just for copying in other classes
-		GETTER_R(MaterialProperties, *this, accessMaterialPropertiesBaseClass)
-
-		const ShaderProgram& getShaderProgram(
-			MaterialVariable::PassType p) const {return *sProgs[p];}
-
-		// Variable accessors
-		GETTER_R(VarsContainer, mtlVars, getVariables)
-		GETTER_R(Vec<UserMaterialVariable*>, userMtlVars, getUserVariables)
-		const BuildinMaterialVariable& getBuildinVariable(
-			BuildinMaterialVariable::BuildinEnum e) const;
-		/// @}
-
-		/// Load a material file
-		void load(const char* filename);
-
-		/// Check if a buildin variable exists
-		bool buildinVariableExits(BuildinMaterialVariable::BuildinEnum e)
-			const {return buildinsArr[e] != NULL;}
-
-	private:
-		//======================================================================
-		// Nested                                                              =
-		//======================================================================
-
-		typedef Vec<RsrcPtr<ShaderProgram> > ShaderPrograms;
-
-		//======================================================================
-		// Members                                                             =
-		//======================================================================
-
-		/// From "GL_ZERO" return GL_ZERO
-		static ConstCharPtrHashMap<GLenum>::Type txtToBlengGlEnum;
-
-		/// All the material variables. Both buildins and user
-		VarsContainer mtlVars;
-
-		BuildinsArr buildinsArr; ///< To find. Initialize to int
-
-		Vec<UserMaterialVariable*> userMtlVars; ///< To iterate
-
-		/// The most important aspect of materials
-		ShaderPrograms sProgs;
-
-		//======================================================================
-		// Methods                                                             =
-		//======================================================================
-
-		/// Parse what is within the @code <material></material> @endcode
-		void parseMaterialTag(const boost::property_tree::ptree& pt);
-
-		/// XXX
-		std::string createShaderProgSourceToCache(const std::string& source);
-
-		/// XXX
-		void populateVariables(const boost::property_tree::ptree& pt);
-};
-
-
-inline const BuildinMaterialVariable& Material::getBuildinVariable(
-	BuildinMaterialVariable::BuildinEnum e) const
-{
-	ASSERT(buildinVariableExits(e));
-	return *buildinsArr[e];
-}
+/// Alias to material::Material
+class Material: public material::Material
+{};
 
 
 
 
 #endif
 #endif

+ 6 - 2
src/Resources/Model.cpp

@@ -35,9 +35,13 @@ void Model::load(const char* filename)
 			const std::string& mesh = v.second.get<std::string>("mesh");
 			const std::string& mesh = v.second.get<std::string>("mesh");
 			const std::string& material = v.second.get<std::string>("material");
 			const std::string& material = v.second.get<std::string>("material");
 
 
-			ModelPatch* patch = new ModelPatch();
+			ModelPatch* patch = new ModelPatch(mesh.c_str(), material.c_str());
 			modelPatches.push_back(patch);
 			modelPatches.push_back(patch);
-			patch->load(mesh.c_str(), material.c_str());
+		}
+
+		if(modelPatches.size() < 1)
+		{
+			throw EXCEPTION("Zero number of model patches");
 		}
 		}
 
 
 		// Bounding volume
 		// Bounding volume

+ 14 - 3
src/Resources/ModelPatch.cpp

@@ -1,14 +1,16 @@
 #include "ModelPatch.h"
 #include "ModelPatch.h"
 #include "Mesh.h"
 #include "Mesh.h"
-#include "Resources/Material.h"
+#include "Material.h"
 
 
 
 
 //==============================================================================
 //==============================================================================
 // Constructors & Destructor                                                   =
 // Constructors & Destructor                                                   =
 //==============================================================================
 //==============================================================================
 
 
-ModelPatch::ModelPatch()
-{}
+ModelPatch::ModelPatch(const char* meshFName, const char* mtlFName)
+{
+	load(meshFName, mtlFName);
+}
 
 
 
 
 ModelPatch::~ModelPatch()
 ModelPatch::~ModelPatch()
@@ -24,3 +26,12 @@ void ModelPatch::load(const char* meshFName, const char* mtlFName)
 	mesh.loadRsrc(meshFName);
 	mesh.loadRsrc(meshFName);
 	mtl.loadRsrc(mtlFName);
 	mtl.loadRsrc(mtlFName);
 }
 }
+
+
+//==============================================================================
+// supportsHwSkinning                                                          =
+//==============================================================================
+bool ModelPatch::supportsHwSkinning() const
+{
+	return mesh->hasVertWeights();
+}

+ 6 - 4
src/Resources/ModelPatch.h

@@ -12,21 +12,23 @@ class Material;
 class ModelPatch
 class ModelPatch
 {
 {
 	public:
 	public:
-		ModelPatch();
+		ModelPatch(const char* meshFName, const char* mtlFName);
 		~ModelPatch();
 		~ModelPatch();
 
 
-		/// Load the resources
-		void load(const char* meshFName, const char* mtlFName);
-
 		/// @name Accessors
 		/// @name Accessors
 		/// @{
 		/// @{
 		const Mesh& getMesh() const {return *mesh;}
 		const Mesh& getMesh() const {return *mesh;}
 		const Material& getMaterial() const {return *mtl;}
 		const Material& getMaterial() const {return *mtl;}
 		/// @}
 		/// @}
 
 
+		bool supportsHwSkinning() const;
+
 	private:
 	private:
 		RsrcPtr<Mesh> mesh; ///< The geometry
 		RsrcPtr<Mesh> mesh; ///< The geometry
 		RsrcPtr<Material> mtl; ///< Material for MS and BS
 		RsrcPtr<Material> mtl; ///< Material for MS and BS
+
+		/// Load the resources
+		void load(const char* meshFName, const char* mtlFName);
 };
 };
 
 
 
 

+ 1 - 1
src/Resources/ResourceManager.h

@@ -12,8 +12,8 @@
 
 
 class Texture;
 class Texture;
 class ShaderProgram;
 class ShaderProgram;
-class Material;
 class Mesh;
 class Mesh;
+class Material;
 class Skeleton;
 class Skeleton;
 class SkelAnim;
 class SkelAnim;
 class LightRsrc;
 class LightRsrc;

+ 4 - 137
src/Resources/ShaderProgram.h

@@ -1,145 +1,12 @@
 #ifndef SHADER_PROGRAM_H
 #ifndef SHADER_PROGRAM_H
 #define 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 "UniformShaderProgramVariable.h"
-#include "AttributeShaderProgramVariable.h"
-#include "Util/Vec.h"
-#include "GfxApi/GlStateMachine.h"
-#include "Core/Globals.h"
+#include "shader_program/ShaderProgram.h"
 
 
 
 
-class ShaderProgramPrePreprocessor;
-
-
-/// Shader program @ref Resource
-///
-/// Shader program. Combines a fragment and a vertex shader. Every shader
-/// program consist of one OpenGL ID, a vector of uniform variables and a
-/// 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 ShaderProgram
-{
-	public:
-		ShaderProgram();
-		~ShaderProgram();
-
-		/// @name Accessors
-		/// @{
-		GLuint getGlId() const;
-		GETTER_R(boost::ptr_vector<ShaderProgramVariable>, vars, getVariables)
-		/// @}
-
-		/// Resource load
-		void load(const char* filename);
-
-		/// Bind the shader program
-		void bind() const;
-
-		/// @name Variable getters
-		/// Used to find and return the variable. They throw exception if
-		/// variable not found so ask if the variable with that name exists
-		/// prior using any of these
-		/// @{
-		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
-		/// @{
-		bool variableExists(const char* varName) const;
-		bool uniformVariableExists(const char* varName) const;
-		bool attributeVariableExists(const char* varName) const;
-		/// @}
-
-		/// Used by @ref Material and @ref Renderer to create custom shaders in
-		/// the cache
-		/// @param sProgFPathName The file pathname of the shader prog
-		/// @param preAppendedSrcCode The source code we want to write on top
-		/// of the shader prog
-		/// @param newFNamePrefix The prefix of the new shader prog
-		/// @return The file pathname of the new shader prog. Its
-		/// $HOME/.anki/cache/newFNamePrefix_fName
-		static std::string createSrcCodeToCache(const char* sProgFPathName,
-			const char* preAppendedSrcCode);
-
-		/// For debuging
-		std::string getShaderInfoString() const;
-
-	private:
-		/// XXX
-		typedef ConstCharPtrHashMap<ShaderProgramVariable*>::Type VarsHashMap;
-
-		/// XXX
-		typedef ConstCharPtrHashMap<UniformShaderProgramVariable*>::Type
-			UniVarsHashMap;
-
-		/// XXX
-		typedef ConstCharPtrHashMap<AttributeShaderProgramVariable*>::Type
-			AttribVarsHashMap;
-
-		std::string rsrcFilename;
-		GLuint glId; ///< The OpenGL ID of the shader program
-		GLuint vertShaderGlId; ///< Vertex shader OpenGL id
-		GLuint geomShaderGlId; ///< Geometry shader OpenGL id
-		GLuint fragShaderGlId; ///< Fragment shader OpenGL id
-
-		/// Shader source that is used in ALL shader programs
-		static const char* stdSourceCode;
-
-		/// @name Containers
-		/// @{
-		boost::ptr_vector<ShaderProgramVariable> vars; ///< All the vars
-		VarsHashMap nameToVar; ///< Variable searching
-		UniVarsHashMap nameToUniVar; ///< Uniform searching
-		AttribVarsHashMap nameToAttribVar; ///< Attribute searching
-		/// @}
-
-		/// Query the driver to get the vars. After the linking of the shader
-		/// prog is done gather all the vars in custom containers
-		void getUniAndAttribVars();
-
-		/// Create and compile shader
-		/// @return The shader's OpenGL id
-		/// @exception Exception
-		uint createAndCompileShader(const char* sourceCode,
-			const char* preproc, int type) const;
-
-		/// Link the shader program
-		/// @exception Exception
-		void link() const;
-}; 
-
-
-//==============================================================================
-// Inlines                                                                     =
-//==============================================================================
-
-inline ShaderProgram::ShaderProgram()
-:	glId(std::numeric_limits<uint>::max())
-{}
-
-
-inline GLuint ShaderProgram::getGlId() const
-{
-	ASSERT(glId != std::numeric_limits<uint>::max());
-	return glId;
-}
-
-
-inline void ShaderProgram::bind() const
-{
-	ASSERT(glId != std::numeric_limits<uint>::max());
-	GlStateMachineSingleton::getInstance().useShaderProg(glId);
-}
+/// Alias to sprog::ShaderProgram
+class ShaderProgram: public shader_program::ShaderProgram
+{};
 
 
 
 
 #endif
 #endif

+ 0 - 39
src/Resources/UniformShaderProgramVariable.h

@@ -1,39 +0,0 @@
-#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_, UNIFORM, fatherSProg_)
-{}
-
-
-#endif

+ 14 - 8
src/Resources/BuildinMaterialVariable.cpp → src/Resources/material/BuildinVariable.cpp

@@ -1,4 +1,4 @@
-#include "BuildinMaterialVariable.h"
+#include "BuildinVariable.h"
 #include "Util/Exception.h"
 #include "Util/Exception.h"
 #include "Util/Assert.h"
 #include "Util/Assert.h"
 #include <cstring>
 #include <cstring>
@@ -6,12 +6,15 @@
 #include <boost/assign/list_of.hpp>
 #include <boost/assign/list_of.hpp>
 
 
 
 
+namespace material {
+
+
 //==============================================================================
 //==============================================================================
 // Statics                                                                     =
 // Statics                                                                     =
 //==============================================================================
 //==============================================================================
 
 
-ConstCharPtrHashMap<BuildinMaterialVariable::BuildinEnum>::Type
-	BuildinMaterialVariable::buildinNameToEnum = boost::assign::map_list_of
+ConstCharPtrHashMap<BuildinVariable::BuildinEnum>::Type
+	BuildinVariable::buildinNameToEnum = boost::assign::map_list_of
 	("position", POSITION)
 	("position", POSITION)
 	("tangent", TANGENT)
 	("tangent", TANGENT)
 	("normal", NORMAL)
 	("normal", NORMAL)
@@ -35,8 +38,8 @@ ConstCharPtrHashMap<BuildinMaterialVariable::BuildinEnum>::Type
 	("blurring", BLURRING);
 	("blurring", BLURRING);
 
 
 
 
-boost::unordered_map<BuildinMaterialVariable::BuildinEnum, GLenum>
-	BuildinMaterialVariable::buildinToGlType = boost::assign::map_list_of
+boost::unordered_map<BuildinVariable::BuildinEnum, GLenum>
+	BuildinVariable::buildinToGlType = boost::assign::map_list_of
 	(POSITION, GL_FLOAT_VEC3)
 	(POSITION, GL_FLOAT_VEC3)
 	(TANGENT, GL_FLOAT_VEC4)
 	(TANGENT, GL_FLOAT_VEC4)
 	(NORMAL, GL_FLOAT_VEC3)
 	(NORMAL, GL_FLOAT_VEC3)
@@ -63,10 +66,10 @@ boost::unordered_map<BuildinMaterialVariable::BuildinEnum, GLenum>
 //==============================================================================
 //==============================================================================
 // Constructor                                                                 =
 // Constructor                                                                 =
 //==============================================================================
 //==============================================================================
-BuildinMaterialVariable::BuildinMaterialVariable(
+BuildinVariable::BuildinVariable(
 	const char* shaderProgVarName,
 	const char* shaderProgVarName,
 	const ShaderPrograms& shaderProgsArr)
 	const ShaderPrograms& shaderProgsArr)
-:	MaterialVariable(BUILDIN, shaderProgVarName, shaderProgsArr),
+:	Variable(BUILDIN, shaderProgVarName, shaderProgsArr),
  	bEnum(BUILDINS_NUM)
  	bEnum(BUILDINS_NUM)
 {
 {
 	GLenum dataType;
 	GLenum dataType;
@@ -88,7 +91,7 @@ BuildinMaterialVariable::BuildinMaterialVariable(
 //==============================================================================
 //==============================================================================
 // isBuildin                                                                   =
 // isBuildin                                                                   =
 //==============================================================================
 //==============================================================================
-bool BuildinMaterialVariable::isBuildin(const char* name,
+bool BuildinVariable::isBuildin(const char* name,
 	BuildinEnum* var, GLenum* dataType)
 	BuildinEnum* var, GLenum* dataType)
 {
 {
 	ConstCharPtrHashMap<BuildinEnum>::Type::const_iterator it =
 	ConstCharPtrHashMap<BuildinEnum>::Type::const_iterator it =
@@ -116,3 +119,6 @@ bool BuildinMaterialVariable::isBuildin(const char* name,
 
 
 	return true;
 	return true;
 }
 }
+
+
+} // end namespace

+ 10 - 5
src/Resources/BuildinMaterialVariable.h → src/Resources/material/BuildinVariable.h

@@ -1,13 +1,16 @@
-#ifndef BUILDIN_MATERIAL_VARIABLE_H
-#define BUILDIN_MATERIAL_VARIABLE_H
+#ifndef MATERIAL_BUILDIN_VARIABLE_H
+#define MATERIAL_BUILDIN_VARIABLE_H
 
 
-#include "MaterialVariable.h"
+#include "Variable.h"
 #include "Util/ConstCharPtrHashMap.h"
 #include "Util/ConstCharPtrHashMap.h"
 #include <boost/array.hpp>
 #include <boost/array.hpp>
 
 
 
 
+namespace material {
+
+
 /// XXX
 /// XXX
-class BuildinMaterialVariable: public MaterialVariable
+class BuildinVariable: public Variable
 {
 {
 	public:
 	public:
 		/// Standard attribute variables that are acceptable inside the
 		/// Standard attribute variables that are acceptable inside the
@@ -44,7 +47,7 @@ class BuildinMaterialVariable: public MaterialVariable
 			BUILDINS_NUM ///< The number of all buildin variables
 			BUILDINS_NUM ///< The number of all buildin variables
 		};
 		};
 
 
-		BuildinMaterialVariable(
+		BuildinVariable(
 			const char* shaderProgVarName,
 			const char* shaderProgVarName,
 			const ShaderPrograms& shaderProgsArr);
 			const ShaderPrograms& shaderProgsArr);
 
 
@@ -64,4 +67,6 @@ class BuildinMaterialVariable: public MaterialVariable
 };
 };
 
 
 
 
+} // end namespace
+
 #endif
 #endif

+ 13 - 0
src/Resources/material/Common.cpp

@@ -0,0 +1,13 @@
+#include "Common.h"
+
+
+namespace material {
+
+
+boost::array<const char*, PASS_TYPES_NUM> passNames = {{
+	"COLOR_PASS",
+	"DEPTH_PASS"
+}};
+
+
+} // end namesapce

+ 25 - 0
src/Resources/material/Common.h

@@ -0,0 +1,25 @@
+#ifndef MATERIAL_COMMON_H
+#define MATERIAL_COMMON_H
+
+#include <boost/array.hpp>
+
+
+namespace material {
+
+
+/// The types of the rendering passes
+enum PassType
+{
+	COLOR_PASS,
+	DEPTH_PASS,
+	PASS_TYPES_NUM
+};
+
+
+extern boost::array<const char*, PASS_TYPES_NUM> passNames;
+
+
+} // end namespace
+
+
+#endif

+ 30 - 26
src/Resources/Material.cpp → src/Resources/material/Material.cpp

@@ -1,10 +1,10 @@
 #include "Material.h"
 #include "Material.h"
-#include "MaterialVariable.h"
+#include "Variable.h"
 #include "Misc/PropertyTree.h"
 #include "Misc/PropertyTree.h"
-#include "MaterialShaderProgramCreator.h"
+#include "ShaderProgramCreator.h"
 #include "Core/App.h"
 #include "Core/App.h"
 #include "Core/Globals.h"
 #include "Core/Globals.h"
-#include "ShaderProgram.h"
+#include "../ShaderProgram.h"
 #include <boost/foreach.hpp>
 #include <boost/foreach.hpp>
 #include <boost/property_tree/ptree.hpp>
 #include <boost/property_tree/ptree.hpp>
 #include <boost/property_tree/xml_parser.hpp>
 #include <boost/property_tree/xml_parser.hpp>
@@ -13,6 +13,9 @@
 #include <algorithm>
 #include <algorithm>
 
 
 
 
+namespace material {
+
+
 //==============================================================================
 //==============================================================================
 // Statics                                                                     =
 // Statics                                                                     =
 //==============================================================================
 //==============================================================================
@@ -51,7 +54,7 @@ Material::Material()
 
 
 	// Reset tha array
 	// Reset tha array
 	std::fill(buildinsArr.begin(), buildinsArr.end(),
 	std::fill(buildinsArr.begin(), buildinsArr.end(),
-		static_cast<BuildinMaterialVariable*>(NULL));
+		static_cast<BuildinVariable*>(NULL));
 }
 }
 
 
 
 
@@ -171,19 +174,17 @@ void Material::parseMaterialTag(const boost::property_tree::ptree& pt)
 	//
 	//
 	// shaderProgram
 	// shaderProgram
 	//
 	//
-	MaterialShaderProgramCreator mspc(pt.get_child("shaderProgram"));
+	ShaderProgramCreator mspc(pt.get_child("shaderProgram"));
 
 
-	std::string cpSrc = "#define COLOR_PASS\n" + mspc.getShaderProgramSource();
-	std::string dpSrc = "#define DEPTH_PASS\n" + mspc.getShaderProgramSource();
-
-	std::string cfile = createShaderProgSourceToCache(cpSrc);
-	std::string dfile = createShaderProgSourceToCache(dpSrc);
+	for(uint i = 0; i < PASS_TYPES_NUM; i++)
+	{
+		std::string src = std::string("#define ") + passNames[i] + "\n" +
+			mspc.getShaderProgramSource();
 
 
-	sProgs[MaterialVariable::COLOR_PASS].loadRsrc(cfile.c_str());
-	sProgs[MaterialVariable::DEPTH_PASS].loadRsrc(dfile.c_str());
+		std::string filename = createShaderProgSourceToCache(src);
 
 
-	/*INFO(cpShaderProg->getShaderInfoString());
-	INFO(dpShaderProg->getShaderInfoString());*/
+		sProgs[i].loadRsrc(filename.c_str());
+	}
 
 
 	populateVariables(pt.get_child("shaderProgram.inputs"));
 	populateVariables(pt.get_child("shaderProgram.inputs"));
 }
 }
@@ -237,7 +238,7 @@ void Material::populateVariables(const boost::property_tree::ptree& pt)
 
 
 	BOOST_FOREACH(const RsrcPtr<ShaderProgram>& sProg, sProgs)
 	BOOST_FOREACH(const RsrcPtr<ShaderProgram>& sProg, sProgs)
 	{
 	{
-		BOOST_FOREACH(const ShaderProgramVariable& v, sProg->getVariables())
+		BOOST_FOREACH(const shader_program::Variable& v, sProg->getVariables())
 		{
 		{
 			allVarNames[v.getName()] = v.getGlDataType();
 			allVarNames[v.getName()] = v.getGlDataType();
 		}
 		}
@@ -246,8 +247,8 @@ void Material::populateVariables(const boost::property_tree::ptree& pt)
 	//
 	//
 	// Iterate shader program variables
 	// Iterate shader program variables
 	//
 	//
-	MaterialVariable::ShaderPrograms sProgs_;
-	for(uint i = 0; i < MaterialVariable::PASS_TYPES_NUM; i++)
+	Variable::ShaderPrograms sProgs_;
+	for(uint i = 0; i < PASS_TYPES_NUM; i++)
 	{
 	{
 		sProgs_[i] = sProgs[i].get();
 		sProgs_[i] = sProgs[i].get();
 	}
 	}
@@ -259,10 +260,10 @@ void Material::populateVariables(const boost::property_tree::ptree& pt)
 		GLenum dataType = it->second;
 		GLenum dataType = it->second;
 
 
 		// Buildin?
 		// Buildin?
-		if(BuildinMaterialVariable::isBuildin(svName))
+		if(BuildinVariable::isBuildin(svName))
 		{
 		{
-			BuildinMaterialVariable* v =
-				new BuildinMaterialVariable(svName, sProgs_);
+			BuildinVariable* v =
+				new BuildinVariable(svName, sProgs_);
 
 
 			mtlVars.push_back(v);
 			mtlVars.push_back(v);
 			buildinsArr[v->getVariableEnum()] = v;
 			buildinsArr[v->getVariableEnum()] = v;
@@ -292,33 +293,33 @@ void Material::populateVariables(const boost::property_tree::ptree& pt)
 					svName);
 					svName);
 			}
 			}
 
 
-			UserMaterialVariable* v = NULL;
+			UserVariable* v = NULL;
 			// Get the value
 			// Get the value
 			switch(dataType)
 			switch(dataType)
 			{
 			{
 				// sampler2D
 				// sampler2D
 				case GL_SAMPLER_2D:
 				case GL_SAMPLER_2D:
-					v = new UserMaterialVariable(svName, sProgs_,
+					v = new UserVariable(svName, sProgs_,
 						valuePt->get<std::string>("sampler2D").c_str());
 						valuePt->get<std::string>("sampler2D").c_str());
 					break;
 					break;
 				// float
 				// float
 				case GL_FLOAT:
 				case GL_FLOAT:
-					v = new UserMaterialVariable(svName, sProgs_,
+					v = new UserVariable(svName, sProgs_,
 						PropertyTree::getFloat(*valuePt));
 						PropertyTree::getFloat(*valuePt));
 					break;
 					break;
 				// vec2
 				// vec2
 				case GL_FLOAT_VEC2:
 				case GL_FLOAT_VEC2:
-					v = new UserMaterialVariable(svName, sProgs_,
+					v = new UserVariable(svName, sProgs_,
 						PropertyTree::getVec2(*valuePt));
 						PropertyTree::getVec2(*valuePt));
 					break;
 					break;
 				// vec3
 				// vec3
 				case GL_FLOAT_VEC3:
 				case GL_FLOAT_VEC3:
-					v = new UserMaterialVariable(svName, sProgs_,
+					v = new UserVariable(svName, sProgs_,
 						PropertyTree::getVec3(*valuePt));
 						PropertyTree::getVec3(*valuePt));
 					break;
 					break;
 				// vec4
 				// vec4
 				case GL_FLOAT_VEC4:
 				case GL_FLOAT_VEC4:
-					v = new UserMaterialVariable(svName, sProgs_,
+					v = new UserVariable(svName, sProgs_,
 						PropertyTree::getVec4(*valuePt));
 						PropertyTree::getVec4(*valuePt));
 					break;
 					break;
 				// default is error
 				// default is error
@@ -331,3 +332,6 @@ void Material::populateVariables(const boost::property_tree::ptree& pt)
 		}
 		}
 	} // end for all sprog vars
 	} // end for all sprog vars
 }
 }
+
+
+} // end namespace

+ 189 - 0
src/Resources/material/Material.h

@@ -0,0 +1,189 @@
+#ifndef MATERIAL_MATERIAL_H
+#define MATERIAL_MATERIAL_H
+
+#include "UserVariable.h"
+#include "BuildinVariable.h"
+#include "Common.h"
+#include "Properties.h"
+#include "Util/Accessors.h"
+#include "Util/ConstCharPtrHashMap.h"
+#include <GL/glew.h>
+#include <boost/ptr_container/ptr_vector.hpp>
+#include <boost/array.hpp>
+#include <boost/scoped_ptr.hpp>
+#include <boost/property_tree/ptree_fwd.hpp>
+
+
+class ShaderProgram;
+
+
+namespace material {
+
+
+/// Material resource
+///
+/// Every material keeps info of how to render a RenedrableNode. Using a node
+/// based logic it creates a couple of shader programs dynamically. One for
+/// color passes and one for depth. It also keeps two sets of material
+/// variables. The first is the build in and the second the user defined.
+/// During the renderer's shader setup the buildins will be set automatically,
+/// for the user variables the user needs to have its value in the material
+/// file. Some material variables may be present in both shader programs and
+/// some in only one of them
+///
+/// Material XML file format:
+/// @code
+/// <material>
+/// 	<castsShadow>true | false</castsShadow>
+///
+/// 	<renderInBlendingStage>true | false</renderInBlendingStage>
+///
+/// 	<blendFunctions>
+/// 		<sFactor>GL_SOMETHING</sFactor>
+/// 		<dFactor>GL_SOMETHING</dFactor>
+/// 	</blendFunctions>
+///
+/// 	<depthTesting>true | false</depthTesting>
+///
+/// 	<wireframe>true | false</wireframe>
+///
+/// 	<shaderProgram>
+/// 		<includes>
+/// 			<include>file.glsl</include>
+/// 			<include>file2.glsl</include>
+/// 		</includes>
+///
+/// 		<inputs>
+/// 			<input> *
+/// 				<name>xx</name>
+/// 				<value>
+/// 					<float>0.0</float> |
+/// 					<vec2><x>0.0</x><y>0.0</y></vec2> |
+/// 					<vec3><x>0.0</x><y>0.0</y><z>0.0</z></vec3> |
+/// 					<vec4><x>0.0</x><y>0.0</y><z>0.0</z><w>0.0</w></vec4> |
+/// 					<sampler2D>path/to/image.tga</sampler2D>
+/// 				</value>
+/// 			</input>
+/// 		</inputs>
+///
+/// 		<operations>
+/// 			<operation>
+/// 				<id>x</id>
+/// 				<function>functionName</function>
+/// 				<arguments>
+/// 					<argument>xx</argument>
+/// 					<argument>yy</argument>
+/// 				</arguments>
+/// 			</operation>
+/// 		</operations>
+///
+/// 	</shaderProgram>
+/// </material>
+/// @endcode
+/// *: For if the value is not set then the in variable will be build in or
+///    standard varying
+class Material: private Properties
+{
+	public:
+		//======================================================================
+		// Nested                                                              =
+		//======================================================================
+
+		typedef boost::ptr_vector<Variable> VarsContainer;
+
+		typedef boost::unordered_map<BuildinVariable::BuildinEnum,
+			BuildinVariable*> BuildinEnumToBuildinHashMap;
+
+		typedef boost::array<BuildinVariable*,
+			BuildinVariable::BUILDINS_NUM> BuildinsArr;
+
+		//======================================================================
+		// Methods                                                             =
+		//======================================================================
+
+		/// Initialize with default values
+		Material();
+
+		~Material();
+
+		/// @name Accessors
+		/// @{
+		GETTER_R_BY_VAL(bool, castsShadowFlag, castsShadow)
+		GETTER_R_BY_VAL(bool, renderInBlendingStageFlag, rendersInBlendingStage)
+		GETTER_R_BY_VAL(int, blendingSfactor, getBlendingSfactor)
+		GETTER_R_BY_VAL(int, blendingDfactor, getBlendingDfactor)
+		GETTER_R_BY_VAL(bool, depthTesting, isDepthTestingEnabled)
+		GETTER_R_BY_VAL(bool, wireframe, isWireframeEnabled)
+
+		/// Access the base class just for copying in other classes
+		GETTER_R(Properties, *this, accessPropertiesBaseClass)
+
+		const ShaderProgram& getShaderProgram(PassType p) const
+			{return *sProgs[p];}
+
+		// Variable accessors
+		GETTER_R(VarsContainer, mtlVars, getVariables)
+		GETTER_R(Vec<UserVariable*>, userMtlVars, getUserVariables)
+		const BuildinVariable& getBuildinVariable(
+			BuildinVariable::BuildinEnum e) const;
+		/// @}
+
+		/// Load a material file
+		void load(const char* filename);
+
+		/// Check if a buildin variable exists
+		bool buildinVariableExits(BuildinVariable::BuildinEnum e)
+			const {return buildinsArr[e] != NULL;}
+
+	private:
+		//======================================================================
+		// Nested                                                              =
+		//======================================================================
+
+		typedef boost::array<RsrcPtr<ShaderProgram>, PASS_TYPES_NUM>
+			ShaderPrograms;
+
+		//======================================================================
+		// Members                                                             =
+		//======================================================================
+
+		/// From "GL_ZERO" return GL_ZERO
+		static ConstCharPtrHashMap<GLenum>::Type txtToBlengGlEnum;
+
+		/// All the material variables. Both buildins and user
+		VarsContainer mtlVars;
+
+		BuildinsArr buildinsArr; ///< To find. Initialize to int
+
+		Vec<UserVariable*> userMtlVars; ///< To iterate
+
+		/// The most important aspect of materials
+		ShaderPrograms sProgs;
+
+		//======================================================================
+		// Methods                                                             =
+		//======================================================================
+
+		/// Parse what is within the @code <material></material> @endcode
+		void parseMaterialTag(const boost::property_tree::ptree& pt);
+
+		/// XXX
+		std::string createShaderProgSourceToCache(const std::string& source);
+
+		/// XXX
+		void populateVariables(const boost::property_tree::ptree& pt);
+};
+
+
+inline const BuildinVariable& Material::getBuildinVariable(
+	BuildinVariable::BuildinEnum e) const
+{
+	ASSERT(buildinVariableExits(e));
+	return *buildinsArr[e];
+}
+
+
+} // end namespace
+
+
+#endif

+ 35 - 0
src/Resources/material/Properties.h

@@ -0,0 +1,35 @@
+#ifndef MATERIAL_PROPERTIES_H
+#define MATERIAL_PROPERTIES_H
+
+#include <GL/glew.h>
+
+
+namespace material {
+
+
+/// Contains a few properties that other classes may use
+struct Properties
+{
+	public:
+		/// Check if blending is enabled
+		bool isBlendingEnabled() const
+			{return blendingSfactor != GL_ONE || blendingDfactor != GL_ZERO;}
+
+	protected:
+		/// Used in depth passes of shadowmapping and not in other depth passes
+		/// like EarlyZ
+		bool castsShadowFlag;
+		/// The entities with blending are being rendered in blending stage and
+		/// those without in material stage
+		bool renderInBlendingStageFlag;
+		int blendingSfactor; ///< Default GL_ONE
+		int blendingDfactor; ///< Default GL_ZERO
+		bool depthTesting;
+		bool wireframe;
+};
+
+
+} // end namespace
+
+
+#endif

+ 26 - 20
src/Resources/MaterialShaderProgramCreator.cpp → src/Resources/material/ShaderProgramCreator.cpp

@@ -1,18 +1,21 @@
-#include "MaterialShaderProgramCreator.h"
+#include "ShaderProgramCreator.h"
 #include "Util/Scanner/Scanner.h"
 #include "Util/Scanner/Scanner.h"
 #include "Misc/Parser.h"
 #include "Misc/Parser.h"
-#include "BuildinMaterialVariable.h"
+#include "BuildinVariable.h"
 #include <boost/assign/list_of.hpp>
 #include <boost/assign/list_of.hpp>
 #include <boost/foreach.hpp>
 #include <boost/foreach.hpp>
 #include <boost/property_tree/ptree.hpp>
 #include <boost/property_tree/ptree.hpp>
 
 
 
 
+namespace material {
+
+
 //==============================================================================
 //==============================================================================
 // Statics                                                                     =
 // Statics                                                                     =
 //==============================================================================
 //==============================================================================
 
 
 boost::unordered_map<GLenum, const char*>
 boost::unordered_map<GLenum, const char*>
-MaterialShaderProgramCreator::glTypeToTxt = boost::assign::map_list_of
+ShaderProgramCreator::glTypeToTxt = boost::assign::map_list_of
 	(GL_FLOAT, "float")
 	(GL_FLOAT, "float")
 	(GL_FLOAT_VEC2, "vec2")
 	(GL_FLOAT_VEC2, "vec2")
 	(GL_FLOAT_VEC3, "vec3")
 	(GL_FLOAT_VEC3, "vec3")
@@ -23,7 +26,7 @@ MaterialShaderProgramCreator::glTypeToTxt = boost::assign::map_list_of
 	(GL_NONE, "void");
 	(GL_NONE, "void");
 
 
 
 
-ConstCharPtrHashMap<GLenum>::Type MaterialShaderProgramCreator::txtToGlType =
+ConstCharPtrHashMap<GLenum>::Type ShaderProgramCreator::txtToGlType =
 	boost::assign::map_list_of
 	boost::assign::map_list_of
 	("float", GL_FLOAT)
 	("float", GL_FLOAT)
 	("vec2", GL_FLOAT_VEC2)
 	("vec2", GL_FLOAT_VEC2)
@@ -35,22 +38,22 @@ ConstCharPtrHashMap<GLenum>::Type MaterialShaderProgramCreator::txtToGlType =
 	("void", GL_NONE);
 	("void", GL_NONE);
 
 
 
 
-boost::unordered_map<MaterialShaderProgramCreator::ArgQualifier, const char*>
-	MaterialShaderProgramCreator::argQualifierToTxt = boost::assign::map_list_of
+boost::unordered_map<ShaderProgramCreator::ArgQualifier, const char*>
+	ShaderProgramCreator::argQualifierToTxt = boost::assign::map_list_of
 	(AQ_IN, "in")
 	(AQ_IN, "in")
 	(AQ_OUT, "out")
 	(AQ_OUT, "out")
 	(AQ_INOUT, "inout");
 	(AQ_INOUT, "inout");
 
 
 
 
-ConstCharPtrHashMap<MaterialShaderProgramCreator::ArgQualifier>::Type
-	MaterialShaderProgramCreator::txtToArgQualifier = boost::assign::map_list_of
+ConstCharPtrHashMap<ShaderProgramCreator::ArgQualifier>::Type
+	ShaderProgramCreator::txtToArgQualifier = boost::assign::map_list_of
 	("in", AQ_IN)
 	("in", AQ_IN)
 	("out", AQ_OUT)
 	("out", AQ_OUT)
 	("inout", AQ_INOUT);
 	("inout", AQ_INOUT);
 
 
 
 
 ConstCharPtrHashMap<GLenum>::Type
 ConstCharPtrHashMap<GLenum>::Type
-	MaterialShaderProgramCreator::varyingNameToGlType =
+	ShaderProgramCreator::varyingNameToGlType =
 	boost::assign::map_list_of
 	boost::assign::map_list_of
 	("vTexCoords", GL_FLOAT_VEC2)
 	("vTexCoords", GL_FLOAT_VEC2)
 	("vNormal", GL_FLOAT_VEC3)
 	("vNormal", GL_FLOAT_VEC3)
@@ -62,7 +65,7 @@ ConstCharPtrHashMap<GLenum>::Type
 //==============================================================================
 //==============================================================================
 // Constructor                                                                 =
 // Constructor                                                                 =
 //==============================================================================
 //==============================================================================
-MaterialShaderProgramCreator::MaterialShaderProgramCreator(
+ShaderProgramCreator::ShaderProgramCreator(
 	const boost::property_tree::ptree& pt)
 	const boost::property_tree::ptree& pt)
 {
 {
 	parseShaderProgramTag(pt);
 	parseShaderProgramTag(pt);
@@ -72,14 +75,14 @@ MaterialShaderProgramCreator::MaterialShaderProgramCreator(
 //==============================================================================
 //==============================================================================
 // Destructor                                                                  =
 // Destructor                                                                  =
 //==============================================================================
 //==============================================================================
-MaterialShaderProgramCreator::~MaterialShaderProgramCreator()
+ShaderProgramCreator::~ShaderProgramCreator()
 {}
 {}
 
 
 
 
 //==============================================================================
 //==============================================================================
 // parseShaderFileForFunctionDefinitions                                       =
 // parseShaderFileForFunctionDefinitions                                       =
 //==============================================================================
 //==============================================================================
-void MaterialShaderProgramCreator::parseShaderFileForFunctionDefinitions(
+void ShaderProgramCreator::parseShaderFileForFunctionDefinitions(
 	const char* filename)
 	const char* filename)
 {
 {
 	Scanner::Scanner scanner(filename, false);
 	Scanner::Scanner scanner(filename, false);
@@ -274,7 +277,7 @@ void MaterialShaderProgramCreator::parseShaderFileForFunctionDefinitions(
 //==============================================================================
 //==============================================================================
 // parseUntilNewline                                                           =
 // parseUntilNewline                                                           =
 //==============================================================================
 //==============================================================================
-void MaterialShaderProgramCreator::parseUntilNewline(Scanner::Scanner& scanner)
+void ShaderProgramCreator::parseUntilNewline(Scanner::Scanner& scanner)
 {
 {
 	const Scanner::Token* token = &scanner.getCrntToken();
 	const Scanner::Token* token = &scanner.getCrntToken();
 	Scanner::TokenCode prevTc;
 	Scanner::TokenCode prevTc;
@@ -300,7 +303,7 @@ void MaterialShaderProgramCreator::parseUntilNewline(Scanner::Scanner& scanner)
 //==============================================================================
 //==============================================================================
 // getNextTokenAndSkipNewlines                                                 =
 // getNextTokenAndSkipNewlines                                                 =
 //==============================================================================
 //==============================================================================
-void MaterialShaderProgramCreator::getNextTokenAndSkipNewlines(
+void ShaderProgramCreator::getNextTokenAndSkipNewlines(
 	Scanner::Scanner& scanner)
 	Scanner::Scanner& scanner)
 {
 {
 	const Scanner::Token* token;
 	const Scanner::Token* token;
@@ -319,7 +322,7 @@ void MaterialShaderProgramCreator::getNextTokenAndSkipNewlines(
 //==============================================================================
 //==============================================================================
 // parseShaderProgramTag                                                       =
 // parseShaderProgramTag                                                       =
 //==============================================================================
 //==============================================================================
-void MaterialShaderProgramCreator::parseShaderProgramTag(
+void ShaderProgramCreator::parseShaderProgramTag(
 	const boost::property_tree::ptree& pt)
 	const boost::property_tree::ptree& pt)
 {
 {
 	usingTexCoordsAttrib = usingNormalAttrib = usingTangentAttrib = false;
 	usingTexCoordsAttrib = usingNormalAttrib = usingTangentAttrib = false;
@@ -432,7 +435,7 @@ void MaterialShaderProgramCreator::parseShaderProgramTag(
 //==============================================================================
 //==============================================================================
 // parseInputTag                                                               =
 // parseInputTag                                                               =
 //==============================================================================
 //==============================================================================
-void MaterialShaderProgramCreator::parseInputTag(
+void ShaderProgramCreator::parseInputTag(
 	const boost::property_tree::ptree& pt, std::string& line)
 	const boost::property_tree::ptree& pt, std::string& line)
 {
 {
 	using namespace boost::property_tree;
 	using namespace boost::property_tree;
@@ -444,9 +447,9 @@ void MaterialShaderProgramCreator::parseInputTag(
 	// Buildin or varying
 	// Buildin or varying
 	if(!valuePt)
 	if(!valuePt)
 	{
 	{
-		BuildinMaterialVariable::BuildinVariable tmp;
+		BuildinVariable::BuildinEnum tmp;
 
 
-		if(BuildinMaterialVariable::isBuildin(name.c_str(), &tmp, &glType))
+		if(BuildinVariable::isBuildin(name.c_str(), &tmp, &glType))
 		{
 		{
 			const char* glTypeTxt = glTypeToTxt.at(glType);
 			const char* glTypeTxt = glTypeToTxt.at(glType);
 			line += "uniform ";
 			line += "uniform ";
@@ -509,7 +512,7 @@ void MaterialShaderProgramCreator::parseInputTag(
 //==============================================================================
 //==============================================================================
 // parseOperatorTag                                                            =
 // parseOperatorTag                                                            =
 //==============================================================================
 //==============================================================================
-void MaterialShaderProgramCreator::parseOperatorTag(
+void ShaderProgramCreator::parseOperatorTag(
 	const boost::property_tree::ptree& pt)
 	const boost::property_tree::ptree& pt)
 {
 {
 	using namespace boost::property_tree;
 	using namespace boost::property_tree;
@@ -576,8 +579,11 @@ void MaterialShaderProgramCreator::parseOperatorTag(
 //==============================================================================
 //==============================================================================
 // compareStrings                                                              =
 // compareStrings                                                              =
 //==============================================================================
 //==============================================================================
-bool MaterialShaderProgramCreator::compareStrings(
+bool ShaderProgramCreator::compareStrings(
 	const std::string& a, const std::string& b)
 	const std::string& a, const std::string& b)
 {
 {
 	return a < b;
 	return a < b;
 }
 }
+
+
+} // end namespace

+ 8 - 3
src/Resources/MaterialShaderProgramCreator.h → src/Resources/material/ShaderProgramCreator.h

@@ -14,12 +14,15 @@ class Scanner;
 }
 }
 
 
 
 
+namespace material {
+
+
 /// XXX
 /// XXX
-class MaterialShaderProgramCreator
+class ShaderProgramCreator
 {
 {
 	public:
 	public:
-		MaterialShaderProgramCreator(const boost::property_tree::ptree& pt);
-		~MaterialShaderProgramCreator();
+		ShaderProgramCreator(const boost::property_tree::ptree& pt);
+		~ShaderProgramCreator();
 
 
 		/// XXX
 		/// XXX
 		const std::string& getShaderProgramSource() const {return source;}
 		const std::string& getShaderProgramSource() const {return source;}
@@ -140,4 +143,6 @@ class MaterialShaderProgramCreator
 };
 };
 
 
 
 
+} // end namespace
+
 #endif
 #endif

+ 29 - 19
src/Resources/UserMaterialVariable.cpp → src/Resources/material/UserVariable.cpp

@@ -1,72 +1,82 @@
-#include "UserMaterialVariable.h"
-#include "UniformShaderProgramVariable.h"
-#include "Texture.h"
+#include "UserVariable.h"
+#include "../Texture.h"
+
+
+namespace material {
 
 
 
 
 //==============================================================================
 //==============================================================================
 // Constructors & destructor                                                   =
 // Constructors & destructor                                                   =
 //==============================================================================
 //==============================================================================
 
 
-UserMaterialVariable::UserMaterialVariable(
+UserVariable::UserVariable(
 	const char* shaderProgVarName,
 	const char* shaderProgVarName,
 	const ShaderPrograms& shaderProgsArr,
 	const ShaderPrograms& shaderProgsArr,
 	float val)
 	float val)
-:	MaterialVariable(USER, shaderProgVarName, shaderProgsArr)
+:	Variable(USER, shaderProgVarName, shaderProgsArr)
 {
 {
 	ASSERT(getGlDataType() == GL_FLOAT);
 	ASSERT(getGlDataType() == GL_FLOAT);
-	ASSERT(getShaderProgramVariableType() == ShaderProgramVariable::UNIFORM);
+	ASSERT(getShaderProgramVariableType() ==
+		shader_program::Variable::UNIFORM);
 	data = val;
 	data = val;
 }
 }
 
 
 
 
-UserMaterialVariable::UserMaterialVariable(
+UserVariable::UserVariable(
 	const char* shaderProgVarName,
 	const char* shaderProgVarName,
 	const ShaderPrograms& shaderProgsArr,
 	const ShaderPrograms& shaderProgsArr,
 	const Vec2& val)
 	const Vec2& val)
-:	MaterialVariable(USER, shaderProgVarName, shaderProgsArr)
+:	Variable(USER, shaderProgVarName, shaderProgsArr)
 {
 {
 	ASSERT(getGlDataType() == GL_FLOAT_VEC2);
 	ASSERT(getGlDataType() == GL_FLOAT_VEC2);
-	ASSERT(getShaderProgramVariableType() == ShaderProgramVariable::UNIFORM);
+	ASSERT(getShaderProgramVariableType() ==
+		shader_program::Variable::UNIFORM);
 	data = val;
 	data = val;
 }
 }
 
 
 
 
-UserMaterialVariable::UserMaterialVariable(
+UserVariable::UserVariable(
 	const char* shaderProgVarName,
 	const char* shaderProgVarName,
 	const ShaderPrograms& shaderProgsArr,
 	const ShaderPrograms& shaderProgsArr,
 	const Vec3& val)
 	const Vec3& val)
-:	MaterialVariable(USER, shaderProgVarName, shaderProgsArr)
+:	Variable(USER, shaderProgVarName, shaderProgsArr)
 {
 {
 	ASSERT(getGlDataType() == GL_FLOAT_VEC3);
 	ASSERT(getGlDataType() == GL_FLOAT_VEC3);
-	ASSERT(getShaderProgramVariableType() == ShaderProgramVariable::UNIFORM);
+	ASSERT(getShaderProgramVariableType() ==
+		shader_program::Variable::UNIFORM);
 	data = val;
 	data = val;
 }
 }
 
 
 
 
-UserMaterialVariable::UserMaterialVariable(
+UserVariable::UserVariable(
 	const char* shaderProgVarName,
 	const char* shaderProgVarName,
 	const ShaderPrograms& shaderProgsArr,
 	const ShaderPrograms& shaderProgsArr,
 	const Vec4& val)
 	const Vec4& val)
-:	MaterialVariable(USER, shaderProgVarName, shaderProgsArr)
+:	Variable(USER, shaderProgVarName, shaderProgsArr)
 {
 {
 	ASSERT(getGlDataType() == GL_FLOAT_VEC4);
 	ASSERT(getGlDataType() == GL_FLOAT_VEC4);
-	ASSERT(getShaderProgramVariableType() == ShaderProgramVariable::UNIFORM);
+	ASSERT(getShaderProgramVariableType() ==
+		shader_program::Variable::UNIFORM);
 	data = val;
 	data = val;
 }
 }
 
 
 
 
-UserMaterialVariable::UserMaterialVariable(
+UserVariable::UserVariable(
 	const char* shaderProgVarName,
 	const char* shaderProgVarName,
 	const ShaderPrograms& shaderProgsArr,
 	const ShaderPrograms& shaderProgsArr,
 	const char* texFilename)
 	const char* texFilename)
-:	MaterialVariable(USER, shaderProgVarName, shaderProgsArr)
+:	Variable(USER, shaderProgVarName, shaderProgsArr)
 {
 {
 	ASSERT(getGlDataType() == GL_SAMPLER_2D);
 	ASSERT(getGlDataType() == GL_SAMPLER_2D);
-	ASSERT(getShaderProgramVariableType() == ShaderProgramVariable::UNIFORM);
+	ASSERT(getShaderProgramVariableType() ==
+		shader_program::Variable::UNIFORM);
 	data = RsrcPtr<Texture>();
 	data = RsrcPtr<Texture>();
 	boost::get<RsrcPtr<Texture> >(data).loadRsrc(texFilename);
 	boost::get<RsrcPtr<Texture> >(data).loadRsrc(texFilename);
 }
 }
 
 
 
 
-UserMaterialVariable::~UserMaterialVariable()
+UserVariable::~UserVariable()
 {}
 {}
+
+
+} // end namespace

+ 22 - 16
src/Resources/UserMaterialVariable.h → src/Resources/material/UserVariable.h

@@ -1,18 +1,21 @@
-#ifndef USER_MATERIAL_VARIABLE_H
-#define USER_MATERIAL_VARIABLE_H
+#ifndef MATERIAL_USER_VARIABLE_H
+#define MATERIAL_USER_VARIABLE_H
 
 
-#include "MaterialVariable.h"
+#include "Variable.h"
 #include "Math/Math.h"
 #include "Math/Math.h"
-#include "RsrcPtr.h"
-#include "UniformShaderProgramVariable.h"
+#include "../RsrcPtr.h"
+#include "../shader_program/UniformVariable.h"
 #include <boost/variant.hpp>
 #include <boost/variant.hpp>
 
 
 
 
 class Texture;
 class Texture;
 
 
 
 
+namespace material {
+
+
 /// XXX
 /// XXX
-class UserMaterialVariable: public MaterialVariable
+class UserVariable: public Variable
 {
 {
 	public:
 	public:
 		/// The data union
 		/// The data union
@@ -21,32 +24,32 @@ class UserMaterialVariable: public MaterialVariable
 
 
 		/// @name Constructors & destructor
 		/// @name Constructors & destructor
 		/// @{
 		/// @{
-		UserMaterialVariable(
+		UserVariable(
 			const char* shaderProgVarName,
 			const char* shaderProgVarName,
 			const ShaderPrograms& shaderProgsArr,
 			const ShaderPrograms& shaderProgsArr,
 			float val);
 			float val);
 
 
-		UserMaterialVariable(
+		UserVariable(
 			const char* shaderProgVarName,
 			const char* shaderProgVarName,
 			const ShaderPrograms& shaderProgsArr,
 			const ShaderPrograms& shaderProgsArr,
 			const Vec2& val);
 			const Vec2& val);
 
 
-		UserMaterialVariable(
+		UserVariable(
 			const char* shaderProgVarName,
 			const char* shaderProgVarName,
 			const ShaderPrograms& shaderProgsArr,
 			const ShaderPrograms& shaderProgsArr,
 			const Vec3& val);
 			const Vec3& val);
 
 
-		UserMaterialVariable(
+		UserVariable(
 			const char* shaderProgVarName,
 			const char* shaderProgVarName,
 			const ShaderPrograms& shaderProgsArr,
 			const ShaderPrograms& shaderProgsArr,
 			const Vec4& val);
 			const Vec4& val);
 
 
-		UserMaterialVariable(
+		UserVariable(
 			const char* shaderProgVarName,
 			const char* shaderProgVarName,
 			const ShaderPrograms& shaderProgsArr,
 			const ShaderPrograms& shaderProgsArr,
 			const char* texFilename);
 			const char* texFilename);
 
 
-		~UserMaterialVariable();
+		~UserVariable();
 		/// @}
 		/// @}
 
 
 		/// @name Accessors
 		/// @name Accessors
@@ -60,7 +63,7 @@ class UserMaterialVariable: public MaterialVariable
 		const Type& getValue() const {return boost::get<Type>(data);}
 		const Type& getValue() const {return boost::get<Type>(data);}
 
 
 		/// Uses static cast to get the uniform
 		/// Uses static cast to get the uniform
-		const UniformShaderProgramVariable&
+		const shader_program::UniformVariable&
 			getShaderProgramUniformVariable(PassType p) const;
 			getShaderProgramUniformVariable(PassType p) const;
 		/// @}
 		/// @}
 
 
@@ -69,12 +72,15 @@ class UserMaterialVariable: public MaterialVariable
 };
 };
 
 
 
 
-inline const UniformShaderProgramVariable&
-	UserMaterialVariable::getShaderProgramUniformVariable(PassType p) const
+inline const shader_program::UniformVariable&
+	UserVariable::getShaderProgramUniformVariable(PassType p) const
 {
 {
-	return static_cast<const UniformShaderProgramVariable&>(
+	return static_cast<const shader_program::UniformVariable&>(
 		getShaderProgramVariable(p));
 		getShaderProgramVariable(p));
 }
 }
 
 
 
 
+} // end namespace
+
+
 #endif
 #endif

+ 10 - 4
src/Resources/MaterialVariable.cpp → src/Resources/material/Variable.cpp

@@ -1,14 +1,17 @@
-#include "MaterialVariable.h"
-#include "ShaderProgramVariable.h"
-#include "ShaderProgram.h"
+#include "Variable.h"
+#include "../shader_program/Variable.h"
+#include "../ShaderProgram.h"
 #include "Util/Assert.h"
 #include "Util/Assert.h"
 #include "Util/Exception.h"
 #include "Util/Exception.h"
 
 
 
 
+namespace material {
+
+
 //==============================================================================
 //==============================================================================
 // Constructor                                                                 =
 // Constructor                                                                 =
 //==============================================================================
 //==============================================================================
-MaterialVariable::MaterialVariable(
+Variable::Variable(
 	Type type_,
 	Type type_,
 	const char* shaderProgVarName,
 	const char* shaderProgVarName,
 	const ShaderPrograms& shaderProgsArr)
 	const ShaderPrograms& shaderProgsArr)
@@ -44,3 +47,6 @@ MaterialVariable::MaterialVariable(
 					shaderProgVarName);
 					shaderProgVarName);
 	}
 	}
 }
 }
+
+
+} // end namespace

+ 15 - 16
src/Resources/MaterialVariable.h → src/Resources/material/Variable.h

@@ -1,8 +1,9 @@
 #ifndef MATERIAL_VARIABLE_H
 #ifndef MATERIAL_VARIABLE_H
 #define MATERIAL_VARIABLE_H
 #define MATERIAL_VARIABLE_H
 
 
+#include "Common.h"
+#include "../shader_program/Variable.h"
 #include "Util/Accessors.h"
 #include "Util/Accessors.h"
-#include "ShaderProgramVariable.h"
 #include "Util/Assert.h"
 #include "Util/Assert.h"
 #include <GL/glew.h>
 #include <GL/glew.h>
 #include <string>
 #include <string>
@@ -12,8 +13,11 @@
 class ShaderProgram;
 class ShaderProgram;
 
 
 
 
+namespace material {
+
+
 /// XXX
 /// XXX
-class MaterialVariable
+class Variable
 {
 {
 	public:
 	public:
 		/// The type
 		/// The type
@@ -23,24 +27,16 @@ class MaterialVariable
 			BUILDIN
 			BUILDIN
 		};
 		};
 
 
-		/// XXX
-		enum PassType
-		{
-			COLOR_PASS,
-			DEPTH_PASS,
-			PASS_TYPES_NUM
-		};
-
 		/// XXX Used for initialization in the constructor
 		/// XXX Used for initialization in the constructor
 		typedef boost::array<const ShaderProgram*, PASS_TYPES_NUM>
 		typedef boost::array<const ShaderProgram*, PASS_TYPES_NUM>
 			ShaderPrograms;
 			ShaderPrograms;
 
 
 		/// XXX
 		/// XXX
-		typedef boost::array<const ShaderProgramVariable*,
+		typedef boost::array<const shader_program::Variable*,
 			PASS_TYPES_NUM> ShaderProgramVariables;
 			PASS_TYPES_NUM> ShaderProgramVariables;
 
 
 		/// XXX
 		/// XXX
-		MaterialVariable(
+		Variable(
 			Type type,
 			Type type,
 			const char* shaderProgVarName,
 			const char* shaderProgVarName,
 			const ShaderPrograms& shaderProgsArr);
 			const ShaderPrograms& shaderProgsArr);
@@ -50,7 +46,7 @@ class MaterialVariable
 		GETTER_R_BY_VAL(Type, type, getType)
 		GETTER_R_BY_VAL(Type, type, getType)
 
 
 		/// XXX
 		/// XXX
-		const ShaderProgramVariable& getShaderProgramVariable(
+		const shader_program::Variable& getShaderProgramVariable(
 			PassType p) const;
 			PassType p) const;
 
 
 		/// XXX
 		/// XXX
@@ -63,7 +59,7 @@ class MaterialVariable
 		const char* getName() const {return oneSProgVar->getName().c_str();}
 		const char* getName() const {return oneSProgVar->getName().c_str();}
 
 
 		/// Get the type of all the shader program variables
 		/// Get the type of all the shader program variables
-		ShaderProgramVariable::Type getShaderProgramVariableType() const
+		shader_program::Variable::Type getShaderProgramVariableType() const
 			{return oneSProgVar->getType();}
 			{return oneSProgVar->getType();}
 		/// @}
 		/// @}
 
 
@@ -73,11 +69,11 @@ class MaterialVariable
 
 
 		/// Keep one ShaderProgramVariable here for easy access of the common
 		/// Keep one ShaderProgramVariable here for easy access of the common
 		/// variable stuff like name or GL data type etc
 		/// variable stuff like name or GL data type etc
-		const ShaderProgramVariable* oneSProgVar;
+		const shader_program::Variable* oneSProgVar;
 };
 };
 
 
 
 
-inline const ShaderProgramVariable& MaterialVariable::getShaderProgramVariable(
+inline const shader_program::Variable& Variable::getShaderProgramVariable(
 	PassType p) const
 	PassType p) const
 {
 {
 	ASSERT(inPass(p));
 	ASSERT(inPass(p));
@@ -85,4 +81,7 @@ inline const ShaderProgramVariable& MaterialVariable::getShaderProgramVariable(
 }
 }
 
 
 
 
+} // end namespace
+
+
 #endif
 #endif

+ 30 - 0
src/Resources/shader_program/AttributeVariable.h

@@ -0,0 +1,30 @@
+#ifndef SHADER_PROGRAM_ATTRIBUTE_VARIABLE_H
+#define SHADER_PROGRAM_ATTRIBUTE_VARIABLE_H
+
+#include "Variable.h"
+
+
+namespace shader_program {
+
+
+/// Attribute shader program variable
+class AttributeVariable: public Variable
+{
+	public:
+		AttributeVariable(
+			int loc, const char* name, GLenum glDataType,
+			const ShaderProgram& fatherSProg);
+};
+
+
+inline AttributeVariable::AttributeVariable(
+	int loc, const char* name,
+	GLenum glDataType, const ShaderProgram& fatherSProg)
+:	Variable(loc, name, glDataType, ATTRIBUTE, fatherSProg)
+{}
+
+
+} // end namespace
+
+
+#endif

+ 15 - 0
src/Resources/shader_program/Fwd.h

@@ -0,0 +1,15 @@
+#ifndef SHADER_PROGRAM_FWD_H
+#define SHADER_PROGRAM_FWD_H
+
+
+namespace shader_program {
+
+class ShaderProgram;
+class UniformVariable;
+class AttributeVariable;
+class PrePreprocessor;
+
+} // end namespace
+
+
+#endif

+ 15 - 10
src/Resources/ShaderProgramPrePreprocessor.cpp → src/Resources/shader_program/PrePreprocessor.cpp

@@ -1,12 +1,15 @@
+#include "PrePreprocessor.h"
+#include "Misc/Parser.h"
+#include "Util/Util.h"
+#include "Util/Exception.h"
 #include <iomanip>
 #include <iomanip>
 #include <cstring>
 #include <cstring>
 #include <iostream>
 #include <iostream>
 #include <boost/lexical_cast.hpp>
 #include <boost/lexical_cast.hpp>
 #include <boost/foreach.hpp>
 #include <boost/foreach.hpp>
-#include "ShaderProgramPrePreprocessor.h"
-#include "Misc/Parser.h"
-#include "Util/Util.h"
-#include "Util/Exception.h"
+
+
+namespace shader_program {
 
 
 
 
 static const char* MULTIPLE_DEF_MSG = " already defined in the same place. "
 static const char* MULTIPLE_DEF_MSG = " already defined in the same place. "
@@ -16,7 +19,7 @@ static const char* MULTIPLE_DEF_MSG = " already defined in the same place. "
 //==============================================================================
 //==============================================================================
 // printSourceLines                                                            =
 // printSourceLines                                                            =
 //==============================================================================
 //==============================================================================
-void ShaderProgramPrePreprocessor::printSourceLines() const
+void PrePreprocessor::printSourceLines() const
 {
 {
 	for(uint i = 0; i < sourceLines.size(); ++i)
 	for(uint i = 0; i < sourceLines.size(); ++i)
 	{
 	{
@@ -29,7 +32,7 @@ void ShaderProgramPrePreprocessor::printSourceLines() const
 //==============================================================================
 //==============================================================================
 // parseFileForPragmas                                                         =
 // parseFileForPragmas                                                         =
 //==============================================================================
 //==============================================================================
-void ShaderProgramPrePreprocessor::parseFileForPragmas(
+void PrePreprocessor::parseFileForPragmas(
 	const std::string& filename, int depth)
 	const std::string& filename, int depth)
 {
 {
 	// first check the depth
 	// first check the depth
@@ -135,7 +138,7 @@ void ShaderProgramPrePreprocessor::parseFileForPragmas(
 //=============================================================================/
 //=============================================================================/
 // parseFile                                                                   =
 // parseFile                                                                   =
 //==============================================================================
 //==============================================================================
-void ShaderProgramPrePreprocessor::parseFile(const char* filename)
+void PrePreprocessor::parseFile(const char* filename)
 {
 {
 	try
 	try
 	{
 	{
@@ -218,7 +221,7 @@ void ShaderProgramPrePreprocessor::parseFile(const char* filename)
 //==============================================================================
 //==============================================================================
 // parseStartPragma                                                            =
 // parseStartPragma                                                            =
 //==============================================================================
 //==============================================================================
-void ShaderProgramPrePreprocessor::parseStartPragma(Scanner::Scanner& scanner,
+void PrePreprocessor::parseStartPragma(Scanner::Scanner& scanner,
 	const std::string& filename, uint depth, const Vec<std::string>& lines)
 	const std::string& filename, uint depth, const Vec<std::string>& lines)
 {
 {
 	const Scanner::Token* token = &scanner.getNextToken();
 	const Scanner::Token* token = &scanner.getNextToken();
@@ -275,7 +278,7 @@ void ShaderProgramPrePreprocessor::parseStartPragma(Scanner::Scanner& scanner,
 //==============================================================================
 //==============================================================================
 // parseIncludePragma                                                          =
 // parseIncludePragma                                                          =
 //==============================================================================
 //==============================================================================
-void ShaderProgramPrePreprocessor::parseIncludePragma(
+void PrePreprocessor::parseIncludePragma(
 	Scanner::Scanner& scanner, const std::string& /*filename*/, uint depth,
 	Scanner::Scanner& scanner, const std::string& /*filename*/, uint depth,
 	const Vec<std::string>& lines)
 	const Vec<std::string>& lines)
 {
 {
@@ -307,7 +310,7 @@ void ShaderProgramPrePreprocessor::parseIncludePragma(
 //==============================================================================
 //==============================================================================
 // parseTrffbVarying                                                           =
 // parseTrffbVarying                                                           =
 //==============================================================================
 //==============================================================================
-void ShaderProgramPrePreprocessor::parseTrffbVarying(Scanner::Scanner& scanner,
+void PrePreprocessor::parseTrffbVarying(Scanner::Scanner& scanner,
 	const std::string& filename, uint /*depth*/, const Vec<std::string>& lines)
 	const std::string& filename, uint /*depth*/, const Vec<std::string>& lines)
 {
 {
 	const Scanner::Token* token = &scanner.getNextToken();
 	const Scanner::Token* token = &scanner.getNextToken();
@@ -349,3 +352,5 @@ void ShaderProgramPrePreprocessor::parseTrffbVarying(Scanner::Scanner& scanner,
 	}
 	}
 }
 }
 
 
+
+} // end namespace

+ 16 - 10
src/Resources/ShaderProgramPrePreprocessor.h → src/Resources/shader_program/PrePreprocessor.h

@@ -12,12 +12,15 @@ class Scanner;
 }
 }
 
 
 
 
+namespace shader_program {
+
+
 /// Helper class used for shader program loading
 /// Helper class used for shader program loading
 ///
 ///
 /// The class fills some of the GLSL spec deficiencies. It adds the include
 /// The class fills some of the GLSL spec deficiencies. It adds the include
 /// preprocessor directive and the support to have all the shaders in the same
 /// preprocessor directive and the support to have all the shaders in the same
 /// file. The file that includes all the shaders is called
 /// file. The file that includes all the shaders is called
-/// ShaderProgramPrePreprocessor-compatible.
+/// PrePreprocessor-compatible.
 ///
 ///
 /// The preprocessor pragmas are:
 /// The preprocessor pragmas are:
 ///
 ///
@@ -26,17 +29,17 @@ class Scanner;
 /// - #pragma anki transformFeedbackVarying <varName>
 /// - #pragma anki transformFeedbackVarying <varName>
 ///
 ///
 /// @note The order of the *ShaderBegins is important
 /// @note The order of the *ShaderBegins is important
-class ShaderProgramPrePreprocessor
+class PrePreprocessor
 {
 {
 	public:
 	public:
 		/// It loads a file and parses it
 		/// It loads a file and parses it
 		/// @param[in] filename The file to load
 		/// @param[in] filename The file to load
 		/// @exception Exception
 		/// @exception Exception
-		ShaderProgramPrePreprocessor(const char* filename)
+		PrePreprocessor(const char* filename)
 			{parseFile(filename);}
 			{parseFile(filename);}
 
 
 		/// Destructor does nothing
 		/// Destructor does nothing
-		~ShaderProgramPrePreprocessor() {}
+		~PrePreprocessor() {}
 
 
 		/// @name Accessors
 		/// @name Accessors
 		/// @{
 		/// @{
@@ -71,7 +74,7 @@ class ShaderProgramPrePreprocessor
 	
 	
 		struct CodeBeginningPragma: Pragma
 		struct CodeBeginningPragma: Pragma
 		{
 		{
-			/// The line number in the ShaderProgramPrePreprocessor-compatible
+			/// The line number in the PrePreprocessor-compatible
 			/// file
 			/// file
 			int globalLine;
 			int globalLine;
 
 
@@ -81,7 +84,7 @@ class ShaderProgramPrePreprocessor
 		/// The output of the class packed in this struct
 		/// The output of the class packed in this struct
 		struct Output
 		struct Output
 		{
 		{
-			friend class ShaderProgramPrePreprocessor;
+			friend class PrePreprocessor;
 
 
 			/// Names and and ids for transform feedback varyings
 			/// Names and and ids for transform feedback varyings
 			Vec<TrffbVaryingPragma> trffbVaryings;
 			Vec<TrffbVaryingPragma> trffbVaryings;
@@ -97,7 +100,7 @@ class ShaderProgramPrePreprocessor
 		CodeBeginningPragma geomShaderBegins;
 		CodeBeginningPragma geomShaderBegins;
 		CodeBeginningPragma fragShaderBegins;
 		CodeBeginningPragma fragShaderBegins;
 
 
-		/// Parse a ShaderProgramPrePreprocessor formated GLSL file. Use
+		/// Parse a PrePreprocessor formated GLSL file. Use
 		/// the accessors to get the output
 		/// the accessors to get the output
 		/// @param filename The file to parse
 		/// @param filename The file to parse
 		/// @exception Ecxeption
 		/// @exception Ecxeption
@@ -144,14 +147,14 @@ class ShaderProgramPrePreprocessor
 // Inlines                                                                     =
 // Inlines                                                                     =
 //==============================================================================
 //==============================================================================
 
 
-inline ShaderProgramPrePreprocessor::Pragma::Pragma(
+inline PrePreprocessor::Pragma::Pragma(
 	const std::string& definedInFile_, int definedInLine_)
 	const std::string& definedInFile_, int definedInLine_)
 :	definedInFile(definedInFile_),
 :	definedInFile(definedInFile_),
 	definedInLine(definedInLine_)
 	definedInLine(definedInLine_)
 {}
 {}
 
 
 
 
-inline ShaderProgramPrePreprocessor::TrffbVaryingPragma::TrffbVaryingPragma(
+inline PrePreprocessor::TrffbVaryingPragma::TrffbVaryingPragma(
 	const std::string& definedInFile_,
 	const std::string& definedInFile_,
 	int definedInLine_, const std::string& name_)
 	int definedInLine_, const std::string& name_)
 :	Pragma(definedInFile_, definedInLine_),
 :	Pragma(definedInFile_, definedInLine_),
@@ -160,7 +163,7 @@ inline ShaderProgramPrePreprocessor::TrffbVaryingPragma::TrffbVaryingPragma(
 
 
 
 
 template<typename Type>
 template<typename Type>
-typename Vec<Type>::const_iterator ShaderProgramPrePreprocessor::findNamed(
+typename Vec<Type>::const_iterator PrePreprocessor::findNamed(
 	const Vec<Type>& vec, const std::string& what) const
 	const Vec<Type>& vec, const std::string& what) const
 {
 {
 	typename Vec<Type>::const_iterator it = vec.begin();
 	typename Vec<Type>::const_iterator it = vec.begin();
@@ -172,4 +175,7 @@ typename Vec<Type>::const_iterator ShaderProgramPrePreprocessor::findNamed(
 }
 }
 
 
 
 
+} // end namespace
+
+
 #endif
 #endif

+ 23 - 18
src/Resources/ShaderProgram.cpp → src/Resources/shader_program/ShaderProgram.cpp

@@ -1,5 +1,5 @@
 #include "Resources/ShaderProgram.h"
 #include "Resources/ShaderProgram.h"
-#include "ShaderProgramPrePreprocessor.h"
+#include "PrePreprocessor.h"
 #include "Core/App.h" // To get cache dir
 #include "Core/App.h" // To get cache dir
 #include "GfxApi/GlException.h"
 #include "GfxApi/GlException.h"
 #include "Core/Logger.h"
 #include "Core/Logger.h"
@@ -14,7 +14,10 @@
 #include <sstream>
 #include <sstream>
 
 
 
 
-#define SPROG_EXCEPTION(x) EXCEPTION("Shader prog \"" + rsrcFilename + \
+namespace shader_program {
+
+
+#define SHADER_PROGRAM_EXCEPTION(x) EXCEPTION("Shader prog \"" + rsrcFilename + \
 	"\": " + x)
 	"\": " + x)
 
 
 
 
@@ -85,7 +88,7 @@ uint ShaderProgram::createAndCompileShader(const char* sourceCode,
 			default:
 			default:
 				ASSERT(0); // Not supported
 				ASSERT(0); // Not supported
 		}
 		}
-		throw SPROG_EXCEPTION(shaderType + " compiler error log follows:\n"
+		throw SHADER_PROGRAM_EXCEPTION(shaderType + " compiler error log follows:\n"
 			"===================================\n" +
 			"===================================\n" +
 			&infoLog[0] +
 			&infoLog[0] +
 			"\n===================================\n" + sourceCode);
 			"\n===================================\n" + sourceCode);
@@ -117,7 +120,7 @@ void ShaderProgram::link() const
 
 
 		infoLogTxt.resize(info_len + 1);
 		infoLogTxt.resize(info_len + 1);
 		glGetProgramInfoLog(glId, info_len, &charsWritten, &infoLogTxt[0]);
 		glGetProgramInfoLog(glId, info_len, &charsWritten, &infoLogTxt[0]);
-		throw SPROG_EXCEPTION("Link error log follows:\n" + infoLogTxt);
+		throw SHADER_PROGRAM_EXCEPTION("Link error log follows:\n" + infoLogTxt);
 	}
 	}
 }
 }
 
 
@@ -152,8 +155,8 @@ void ShaderProgram::getUniAndAttribVars()
 			continue;
 			continue;
 		}
 		}
 
 
-		AttributeShaderProgramVariable* var =
-			new AttributeShaderProgramVariable(loc, &name_[0], type, *this);
+		AttributeVariable* var =
+			new AttributeVariable(loc, &name_[0], type, *this);
 		vars.push_back(var);
 		vars.push_back(var);
 		nameToVar[var->getName().c_str()] = var;
 		nameToVar[var->getName().c_str()] = var;
 		nameToAttribVar[var->getName().c_str()] = var;
 		nameToAttribVar[var->getName().c_str()] = var;
@@ -178,8 +181,8 @@ void ShaderProgram::getUniAndAttribVars()
 			continue;
 			continue;
 		}
 		}
 
 
-		UniformShaderProgramVariable* var =
-			new UniformShaderProgramVariable(loc, &name_[0], type, *this);
+		UniformVariable* var =
+			new UniformVariable(loc, &name_[0], type, *this);
 		vars.push_back(var);
 		vars.push_back(var);
 		nameToVar[var->getName().c_str()] = var;
 		nameToVar[var->getName().c_str()] = var;
 		nameToUniVar[var->getName().c_str()] = var;
 		nameToUniVar[var->getName().c_str()] = var;
@@ -195,7 +198,7 @@ void ShaderProgram::load(const char* filename)
 	rsrcFilename = filename;
 	rsrcFilename = filename;
 	ASSERT(glId == std::numeric_limits<uint>::max());
 	ASSERT(glId == std::numeric_limits<uint>::max());
 
 
-	ShaderProgramPrePreprocessor pars(filename);
+	PrePreprocessor pars(filename);
 
 
 	// 1) create and compile the shaders
 	// 1) create and compile the shaders
 	std::string preprocSource = stdSourceCode;
 	std::string preprocSource = stdSourceCode;
@@ -213,7 +216,7 @@ void ShaderProgram::load(const char* filename)
 	glId = glCreateProgram();
 	glId = glCreateProgram();
 	if(glId == 0)
 	if(glId == 0)
 	{
 	{
-		throw SPROG_EXCEPTION("glCreateProgram failed");
+		throw SHADER_PROGRAM_EXCEPTION("glCreateProgram failed");
 	}
 	}
 	glAttachShader(glId, vertShaderGlId);
 	glAttachShader(glId, vertShaderGlId);
 	glAttachShader(glId, fragShaderGlId);
 	glAttachShader(glId, fragShaderGlId);
@@ -242,12 +245,12 @@ void ShaderProgram::load(const char* filename)
 //==============================================================================
 //==============================================================================
 // getVariable                                                                 =
 // getVariable                                                                 =
 //==============================================================================
 //==============================================================================
-const ShaderProgramVariable& ShaderProgram::getVariable(const char* name) const
+const Variable& ShaderProgram::getVariable(const char* name) const
 {
 {
 	VarsHashMap::const_iterator it = nameToVar.find(name);
 	VarsHashMap::const_iterator it = nameToVar.find(name);
 	if(it == nameToVar.end())
 	if(it == nameToVar.end())
 	{
 	{
-		throw SPROG_EXCEPTION("Cannot get variable: " + name);
+		throw SHADER_PROGRAM_EXCEPTION("Cannot get variable: " + name);
 	}
 	}
 	return *(it->second);
 	return *(it->second);
 }
 }
@@ -256,13 +259,13 @@ const ShaderProgramVariable& ShaderProgram::getVariable(const char* name) const
 //==============================================================================
 //==============================================================================
 // getAttributeVariable                                                        =
 // getAttributeVariable                                                        =
 //==============================================================================
 //==============================================================================
-const AttributeShaderProgramVariable& ShaderProgram::getAttributeVariable(
+const AttributeVariable& ShaderProgram::getAttributeVariable(
 	const char* name) const
 	const char* name) const
 {
 {
 	AttribVarsHashMap::const_iterator it = nameToAttribVar.find(name);
 	AttribVarsHashMap::const_iterator it = nameToAttribVar.find(name);
 	if(it == nameToAttribVar.end())
 	if(it == nameToAttribVar.end())
 	{
 	{
-		throw SPROG_EXCEPTION("Cannot get attribute loc: " + name);
+		throw SHADER_PROGRAM_EXCEPTION("Cannot get attribute loc: " + name);
 	}
 	}
 	return *(it->second);
 	return *(it->second);
 }
 }
@@ -271,13 +274,13 @@ const AttributeShaderProgramVariable& ShaderProgram::getAttributeVariable(
 //==============================================================================
 //==============================================================================
 // getUniformVariable                                                          =
 // getUniformVariable                                                          =
 //==============================================================================
 //==============================================================================
-const UniformShaderProgramVariable& ShaderProgram::getUniformVariable(
+const UniformVariable& ShaderProgram::getUniformVariable(
 	const char* name) const
 	const char* name) const
 {
 {
 	UniVarsHashMap::const_iterator it = nameToUniVar.find(name);
 	UniVarsHashMap::const_iterator it = nameToUniVar.find(name);
 	if(it == nameToUniVar.end())
 	if(it == nameToUniVar.end())
 	{
 	{
-		throw SPROG_EXCEPTION("Cannot get uniform loc: " + name);
+		throw SHADER_PROGRAM_EXCEPTION("Cannot get uniform loc: " + name);
 	}
 	}
 	return *(it->second);
 	return *(it->second);
 }
 }
@@ -363,10 +366,10 @@ std::string ShaderProgram::getShaderInfoString() const
 	std::stringstream ss;
 	std::stringstream ss;
 
 
 	ss << "Variables:\n";
 	ss << "Variables:\n";
-	BOOST_FOREACH(const ShaderProgramVariable& var, vars)
+	BOOST_FOREACH(const Variable& var, vars)
 	{
 	{
 		ss << var.getName() << " " << var.getLoc() << " ";
 		ss << var.getName() << " " << var.getLoc() << " ";
-		if(var.getType() == ShaderProgramVariable::ATTRIBUTE)
+		if(var.getType() == Variable::ATTRIBUTE)
 		{
 		{
 			ss << "attribute";
 			ss << "attribute";
 		}
 		}
@@ -380,3 +383,5 @@ std::string ShaderProgram::getShaderInfoString() const
 	return ss.str();
 	return ss.str();
 }
 }
 
 
+
+} // end namespace

+ 149 - 0
src/Resources/shader_program/ShaderProgram.h

@@ -0,0 +1,149 @@
+#ifndef SHADER_PROGRAM_SHADER_PROGRAM_H
+#define SHADER_PROGRAM_SHADER_PROGRAM_H
+
+#include "Fwd.h"
+#include "Util/ConstCharPtrHashMap.h"
+#include "Util/Assert.h"
+#include "UniformVariable.h"
+#include "AttributeVariable.h"
+#include "Util/Vec.h"
+#include "GfxApi/GlStateMachine.h"
+#include "Core/Globals.h"
+#include <boost/ptr_container/ptr_vector.hpp>
+#include <GL/glew.h>
+#include <limits>
+
+
+namespace shader_program {
+
+
+/// Shader program @ref Resource
+///
+/// Shader program. Combines a fragment and a vertex shader. Every shader
+/// program consist of one OpenGL ID, a vector of uniform variables and a
+/// 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 ShaderProgram
+{
+	public:
+		ShaderProgram();
+		~ShaderProgram();
+
+		/// @name Accessors
+		/// @{
+		GLuint getGlId() const;
+		GETTER_R(boost::ptr_vector<Variable>, vars, getVariables)
+		/// @}
+
+		/// Resource load
+		void load(const char* filename);
+
+		/// Bind the shader program
+		void bind() const;
+
+		/// @name Variable getters
+		/// Used to find and return the variable. They throw exception if
+		/// variable not found so ask if the variable with that name exists
+		/// prior using any of these
+		/// @{
+		const Variable& getVariable(const char* varName) const;
+		const UniformVariable&
+			getUniformVariable(const char* varName) const;
+		const AttributeVariable&
+			getAttributeVariable(const char* varName) const;
+		/// @}
+
+		/// @name Check for variable existance
+		/// @{
+		bool variableExists(const char* varName) const;
+		bool uniformVariableExists(const char* varName) const;
+		bool attributeVariableExists(const char* varName) const;
+		/// @}
+
+		/// Used by @ref Material and @ref Renderer to create custom shaders in
+		/// the cache
+		/// @param sProgFPathName The file pathname of the shader prog
+		/// @param preAppendedSrcCode The source code we want to write on top
+		/// of the shader prog
+		/// @param newFNamePrefix The prefix of the new shader prog
+		/// @return The file pathname of the new shader prog. Its
+		/// $HOME/.anki/cache/newFNamePrefix_fName
+		static std::string createSrcCodeToCache(const char* sProgFPathName,
+			const char* preAppendedSrcCode);
+
+		/// For debuging
+		std::string getShaderInfoString() const;
+
+	private:
+		/// XXX
+		typedef ConstCharPtrHashMap<Variable*>::Type VarsHashMap;
+
+		/// XXX
+		typedef ConstCharPtrHashMap<UniformVariable*>::Type
+			UniVarsHashMap;
+
+		/// XXX
+		typedef ConstCharPtrHashMap<AttributeVariable*>::Type
+			AttribVarsHashMap;
+
+		std::string rsrcFilename;
+		GLuint glId; ///< The OpenGL ID of the shader program
+		GLuint vertShaderGlId; ///< Vertex shader OpenGL id
+		GLuint geomShaderGlId; ///< Geometry shader OpenGL id
+		GLuint fragShaderGlId; ///< Fragment shader OpenGL id
+
+		/// Shader source that is used in ALL shader programs
+		static const char* stdSourceCode;
+
+		/// @name Containers
+		/// @{
+		boost::ptr_vector<Variable> vars; ///< All the vars
+		VarsHashMap nameToVar; ///< Variable searching
+		UniVarsHashMap nameToUniVar; ///< Uniform searching
+		AttribVarsHashMap nameToAttribVar; ///< Attribute searching
+		/// @}
+
+		/// Query the driver to get the vars. After the linking of the shader
+		/// prog is done gather all the vars in custom containers
+		void getUniAndAttribVars();
+
+		/// Create and compile shader
+		/// @return The shader's OpenGL id
+		/// @exception Exception
+		uint createAndCompileShader(const char* sourceCode,
+			const char* preproc, int type) const;
+
+		/// Link the shader program
+		/// @exception Exception
+		void link() const;
+}; 
+
+
+//==============================================================================
+// Inlines                                                                     =
+//==============================================================================
+
+inline ShaderProgram::ShaderProgram()
+:	glId(std::numeric_limits<uint>::max())
+{}
+
+
+inline GLuint ShaderProgram::getGlId() const
+{
+	ASSERT(glId != std::numeric_limits<uint>::max());
+	return glId;
+}
+
+
+inline void ShaderProgram::bind() const
+{
+	ASSERT(glId != std::numeric_limits<uint>::max());
+	GlStateMachineSingleton::getInstance().useShaderProg(glId);
+}
+
+
+} // end namespace
+
+
+#endif

+ 39 - 25
src/Resources/UniformShaderProgramVariable.cpp → src/Resources/shader_program/UniformVariable.cpp

@@ -1,27 +1,32 @@
-#include "UniformShaderProgramVariable.h"
+#include "UniformVariable.h"
 #include "Resources/ShaderProgram.h"
 #include "Resources/ShaderProgram.h"
 #include "Resources/Texture.h"
 #include "Resources/Texture.h"
 #include "GfxApi/GlStateMachine.h"
 #include "GfxApi/GlStateMachine.h"
 
 
 
 
+namespace shader_program {
+
+
 //==============================================================================
 //==============================================================================
-// set uniforms                                                                =
+// doSanityChecks                                                              =
 //==============================================================================
 //==============================================================================
-/// Standard set uniform checks
-/// - Check if initialized
-/// - if the current shader program is the var's shader program
-/// - if the GL driver gives the same location as the one the var has
-#define STD_SET_UNI_CHECK() \
-	ASSERT(getLoc() != -1); \
-	ASSERT(GlStateMachineSingleton::getInstance().getCurrentProgramGlId() == \
-		getFatherSProg().getGlId()); \
-	ASSERT(glGetUniformLocation(getFatherSProg().getGlId(), \
+void UniformVariable::doSanityChecks() const
+{
+	ASSERT(getLoc() != -1);
+	ASSERT(GlStateMachineSingleton::getInstance().getCurrentProgramGlId() ==
+		getFatherSProg().getGlId());
+	ASSERT(glGetUniformLocation(getFatherSProg().getGlId(),
 		getName().c_str()) == getLoc());
 		getName().c_str()) == getLoc());
+}
 
 
 
 
-void UniformShaderProgramVariable::set(const float f[], uint size) const
+//==============================================================================
+// set uniforms                                                                =
+//==============================================================================
+
+void UniformVariable::set(const float f[], uint size) const
 {
 {
-	STD_SET_UNI_CHECK();
+	doSanityChecks();
 	ASSERT(getGlDataType() == GL_FLOAT);
 	ASSERT(getGlDataType() == GL_FLOAT);
 
 
 	if(size == 1)
 	if(size == 1)
@@ -34,9 +39,10 @@ void UniformShaderProgramVariable::set(const float f[], uint size) const
 	}
 	}
 }
 }
 
 
-void UniformShaderProgramVariable::set(const Vec2 v2[], uint size) const
+
+void UniformVariable::set(const Vec2 v2[], uint size) const
 {
 {
-	STD_SET_UNI_CHECK();
+	doSanityChecks();
 	ASSERT(getGlDataType() == GL_FLOAT_VEC2);
 	ASSERT(getGlDataType() == GL_FLOAT_VEC2);
 	if(size == 1)
 	if(size == 1)
 	{
 	{
@@ -48,9 +54,10 @@ void UniformShaderProgramVariable::set(const Vec2 v2[], uint size) const
 	}
 	}
 }
 }
 
 
-void UniformShaderProgramVariable::set(const Vec3 v3[], uint size) const
+
+void UniformVariable::set(const Vec3 v3[], uint size) const
 {
 {
-	STD_SET_UNI_CHECK();
+	doSanityChecks();
 	ASSERT(getGlDataType() == GL_FLOAT_VEC3);
 	ASSERT(getGlDataType() == GL_FLOAT_VEC3);
 
 
 	if(size == 1)
 	if(size == 1)
@@ -63,32 +70,39 @@ void UniformShaderProgramVariable::set(const Vec3 v3[], uint size) const
 	}
 	}
 }
 }
 
 
-void UniformShaderProgramVariable::set(const Vec4 v4[], uint size) const
+
+void UniformVariable::set(const Vec4 v4[], uint size) const
 {
 {
-	STD_SET_UNI_CHECK();
+	doSanityChecks();
 	ASSERT(getGlDataType() == GL_FLOAT_VEC4);
 	ASSERT(getGlDataType() == GL_FLOAT_VEC4);
 	glUniform4fv(getLoc(), size, &(const_cast<Vec4&>(v4[0]))[0]);
 	glUniform4fv(getLoc(), size, &(const_cast<Vec4&>(v4[0]))[0]);
 }
 }
 
 
-void UniformShaderProgramVariable::set(const Mat3 m3[], uint size) const
+
+void UniformVariable::set(const Mat3 m3[], uint size) const
 {
 {
-	STD_SET_UNI_CHECK();
+	doSanityChecks();
 	ASSERT(getGlDataType() == GL_FLOAT_MAT3);
 	ASSERT(getGlDataType() == GL_FLOAT_MAT3);
 	glUniformMatrix3fv(getLoc(), size, true, &(m3[0])[0]);
 	glUniformMatrix3fv(getLoc(), size, true, &(m3[0])[0]);
 }
 }
 
 
-void UniformShaderProgramVariable::set(const Mat4 m4[], uint size) const
+
+void UniformVariable::set(const Mat4 m4[], uint size) const
 {
 {
-	STD_SET_UNI_CHECK();
+	doSanityChecks();
 	ASSERT(getGlDataType() == GL_FLOAT_MAT4);
 	ASSERT(getGlDataType() == GL_FLOAT_MAT4);
 	glUniformMatrix4fv(getLoc(), size, true, &(m4[0])[0]);
 	glUniformMatrix4fv(getLoc(), size, true, &(m4[0])[0]);
 }
 }
 
 
-void UniformShaderProgramVariable::set(const Texture& tex, uint texUnit) const
+
+void UniformVariable::set(const Texture& tex, uint texUnit) const
 {
 {
-	STD_SET_UNI_CHECK();
+	doSanityChecks();
 	ASSERT(getGlDataType() == GL_SAMPLER_2D ||
 	ASSERT(getGlDataType() == GL_SAMPLER_2D ||
 		getGlDataType() == GL_SAMPLER_2D_SHADOW);
 		getGlDataType() == GL_SAMPLER_2D_SHADOW);
 	tex.bind(texUnit);
 	tex.bind(texUnit);
 	glUniform1i(getLoc(), texUnit);
 	glUniform1i(getLoc(), texUnit);
 }
 }
+
+
+} // end namespace

+ 52 - 0
src/Resources/shader_program/UniformVariable.h

@@ -0,0 +1,52 @@
+#ifndef SHADER_PROGRAM_UNIFORM_VARIABLE_H
+#define SHADER_PROGRAM_UNIFORM_VARIABLE_H
+
+#include "Variable.h"
+#include "Math/Math.h"
+
+
+class Texture;
+
+
+namespace shader_program {
+
+
+/// Uniform shader variable
+class UniformVariable: public Variable
+{
+	public:
+		UniformVariable(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;
+		/// @}
+
+	private:
+		/// Standard set uniform checks
+		/// - Check if initialized
+		/// - if the current shader program is the var's shader program
+		/// - if the GL driver gives the same location as the one the var has
+		void doSanityChecks() const;
+};
+
+
+inline UniformVariable::UniformVariable(
+	int loc_, const char* name_,
+	GLenum glDataType_, const ShaderProgram& fatherSHADER_PROGRAM_)
+:	Variable(loc_, name_, glDataType_, UNIFORM, fatherSHADER_PROGRAM_)
+{}
+
+
+} // end namespace
+
+
+#endif

+ 15 - 9
src/Resources/ShaderProgramVariable.h → src/Resources/shader_program/Variable.h

@@ -1,17 +1,18 @@
 #ifndef SHADER_PROGRAM_VARIABLE_H
 #ifndef SHADER_PROGRAM_VARIABLE_H
 #define SHADER_PROGRAM_VARIABLE_H
 #define SHADER_PROGRAM_VARIABLE_H
 
 
+#include "Util/Accessors.h"
 #include <GL/glew.h>
 #include <GL/glew.h>
 #include <string>
 #include <string>
 #include <boost/noncopyable.hpp>
 #include <boost/noncopyable.hpp>
-#include "Util/Accessors.h"
+#include "Fwd.h"
 
 
 
 
-class ShaderProgram;
+namespace shader_program {
 
 
 
 
 /// Shader program variable. The type is attribute or uniform
 /// Shader program variable. The type is attribute or uniform
-class ShaderProgramVariable: public boost::noncopyable
+class Variable: public boost::noncopyable
 {
 {
 	public:
 	public:
 		/// Shader var types
 		/// Shader var types
@@ -21,12 +22,14 @@ class ShaderProgramVariable: public boost::noncopyable
 			UNIFORM
 			UNIFORM
 		};
 		};
 
 
-		ShaderProgramVariable(GLint loc_, const char* name_,
-			GLenum glDataType_, Type type_,
-			const ShaderProgram& fatherSProg_);
+		Variable(GLint loc, const char* name,
+			GLenum glDataType, Type type,
+			const ShaderProgram& fatherSProg);
 
 
 		/// @name Accessors
 		/// @name Accessors
 		/// @{
 		/// @{
+
+		/// XXX: refactor
 		const ShaderProgram& getFatherSProg() const {return fatherSProg;}
 		const ShaderProgram& getFatherSProg() const {return fatherSProg;}
 		GETTER_R(GLint, loc, getLoc)
 		GETTER_R(GLint, loc, getLoc)
 		GETTER_R(std::string, name, getName)
 		GETTER_R(std::string, name, getName)
@@ -46,15 +49,18 @@ class ShaderProgramVariable: public boost::noncopyable
 };
 };
 
 
 
 
-inline ShaderProgramVariable::ShaderProgramVariable(GLint loc_,
+inline Variable::Variable(GLint loc_,
 	const char* name_, GLenum glDataType_,
 	const char* name_, GLenum glDataType_,
-	Type type_, const ShaderProgram& fatherSProg_)
+	Type type_, const ShaderProgram& fatherSHADER_PROGRAM_)
 :	loc(loc_),
 :	loc(loc_),
 	name(name_),
 	name(name_),
 	glDataType(glDataType_),
 	glDataType(glDataType_),
 	type(type_),
 	type(type_),
-	fatherSProg(fatherSProg_)
+	fatherSProg(fatherSHADER_PROGRAM_)
 {}
 {}
 
 
 
 
+} // end namespace
+
+
 #endif
 #endif

+ 9 - 9
src/Scene/MaterialRuntime.cpp

@@ -1,6 +1,6 @@
 #include "MaterialRuntime.h"
 #include "MaterialRuntime.h"
 #include "Resources/Material.h"
 #include "Resources/Material.h"
-#include "UserMaterialVariableRuntime.h"
+#include "UserVariableRuntime.h"
 #include <boost/foreach.hpp>
 #include <boost/foreach.hpp>
 
 
 
 
@@ -16,12 +16,12 @@ MaterialRuntime::MaterialRuntime(const Material& mtl_)
 	me = he;
 	me = he;
 
 
 	// Create vars
 	// Create vars
-	BOOST_FOREACH(const UserMaterialVariable* var, mtl.getUserVariables())
+	BOOST_FOREACH(const UserVariable* var, mtl.getUserVariables())
 	{
 	{
-		UserMaterialVariableRuntime* varr =
-			new UserMaterialVariableRuntime(*var);
+		UserVariableRuntime* varr =
+			new UserVariableRuntime(*var);
 		vars.push_back(varr);
 		vars.push_back(varr);
-		varNameToVar[varr->getUserMaterialVariable().getName().c_str()] = varr;
+		varNameToVar[varr->getUserVariable().getName().c_str()] = varr;
 	}
 	}
 }
 }
 
 
@@ -36,10 +36,10 @@ MaterialRuntime::~MaterialRuntime()
 //==============================================================================
 //==============================================================================
 // findVariableByName                                                          =
 // findVariableByName                                                          =
 //==============================================================================
 //==============================================================================
-UserMaterialVariableRuntime& MaterialRuntime::findVariableByName(
+UserVariableRuntime& MaterialRuntime::findVariableByName(
 	const char* name)
 	const char* name)
 {
 {
-	ConstCharPtrHashMap<UserMaterialVariableRuntime*>::Type::iterator it =
+	ConstCharPtrHashMap<UserVariableRuntime*>::Type::iterator it =
 		varNameToVar.find(name);
 		varNameToVar.find(name);
 	if(it == varNameToVar.end())
 	if(it == varNameToVar.end())
 	{
 	{
@@ -53,10 +53,10 @@ UserMaterialVariableRuntime& MaterialRuntime::findVariableByName(
 //==============================================================================
 //==============================================================================
 // findVariableByName                                                          =
 // findVariableByName                                                          =
 //==============================================================================
 //==============================================================================
-const UserMaterialVariableRuntime& MaterialRuntime::findVariableByName(
+const UserVariableRuntime& MaterialRuntime::findVariableByName(
 	const char* name) const
 	const char* name) const
 {
 {
-	ConstCharPtrHashMap<UserMaterialVariableRuntime*>::Type::const_iterator
+	ConstCharPtrHashMap<UserVariableRuntime*>::Type::const_iterator
 		it = varNameToVar.find(name);
 		it = varNameToVar.find(name);
 	if(it == varNameToVar.end())
 	if(it == varNameToVar.end())
 	{
 	{

+ 5 - 5
src/Scene/MaterialRuntime.h

@@ -7,7 +7,7 @@
 #include <boost/ptr_container/ptr_vector.hpp>
 #include <boost/ptr_container/ptr_vector.hpp>
 
 
 
 
-class UserMaterialVariableRuntime;
+class UserVariableRuntime;
 class Material;
 class Material;
 
 
 
 
@@ -16,7 +16,7 @@ class MaterialRuntime: private MaterialProperties
 {
 {
 	public:
 	public:
 		/// A type
 		/// A type
-		typedef boost::ptr_vector<UserMaterialVariableRuntime>
+		typedef boost::ptr_vector<UserVariableRuntime>
 			VariablesContainer;
 			VariablesContainer;
 
 
 		/// @name Constructors & destructors
 		/// @name Constructors & destructors
@@ -48,12 +48,12 @@ class MaterialRuntime: private MaterialProperties
 		/// @param[in] name The name of the var
 		/// @param[in] name The name of the var
 		/// @return It returns a MaterialRuntimeUserDefinedVar
 		/// @return It returns a MaterialRuntimeUserDefinedVar
 		/// @exception Exception
 		/// @exception Exception
-		UserMaterialVariableRuntime& findVariableByName(
+		UserVariableRuntime& findVariableByName(
 			const char* name);
 			const char* name);
 
 
 		/// The const version of getUserDefinedVarByName
 		/// The const version of getUserDefinedVarByName
 		/// @see getUserDefinedVarByName
 		/// @see getUserDefinedVarByName
-		const UserMaterialVariableRuntime& findVariableByName(
+		const UserVariableRuntime& findVariableByName(
 			const char* name) const;
 			const char* name) const;
 
 
 		bool isBlendingEnabled() const;
 		bool isBlendingEnabled() const;
@@ -61,7 +61,7 @@ class MaterialRuntime: private MaterialProperties
 	private:
 	private:
 		const Material& mtl; ///< The resource
 		const Material& mtl; ///< The resource
 		VariablesContainer vars;
 		VariablesContainer vars;
-		ConstCharPtrHashMap<UserMaterialVariableRuntime*>::Type
+		ConstCharPtrHashMap<UserVariableRuntime*>::Type
 			varNameToVar;
 			varNameToVar;
 };
 };
 
 

+ 0 - 2
src/Scene/ModelNode.h

@@ -34,8 +34,6 @@ class ModelNode: public SceneNode
 		/// Update the bounding shape
 		/// Update the bounding shape
 		void moveUpdate();
 		void moveUpdate();
 
 
-		void frameUpdate(float /*prevUpdateTime*/, float /*crntTime*/) {}
-
 	private:
 	private:
 		RsrcPtr<Model> model;
 		RsrcPtr<Model> model;
 		Vec<ModelPatchNode*> patches;
 		Vec<ModelPatchNode*> patches;

+ 0 - 1
src/Scene/ModelPatchNode.h

@@ -17,7 +17,6 @@ class ModelPatchNode: public PatchNode
 		GETTER_R(Col::Obb, visibilityShapeWSpace, getVisibilityShapeWSpace)
 		GETTER_R(Col::Obb, visibilityShapeWSpace, getVisibilityShapeWSpace)
 
 
 		virtual void moveUpdate(); ///< Update the visibility shape
 		virtual void moveUpdate(); ///< Update the visibility shape
-		virtual void frameUpdate(float /*prevUpdateTime*/, float /*crntTime*/) {}
 
 
 	private:
 	private:
 		const ModelPatch& modelPatch;
 		const ModelPatch& modelPatch;

+ 2 - 3
src/Scene/PatchNode.h

@@ -27,7 +27,7 @@ class PatchNode: public RenderableNode
 		/// @name Accessors
 		/// @name Accessors
 		/// @{
 		/// @{
 		MaterialRuntime& getMaterialRuntime() {return *mtlRun;}
 		MaterialRuntime& getMaterialRuntime() {return *mtlRun;}
-		const MaterialRuntime& getCpMtlRun() const {return *cpMtlRun;}
+		const MaterialRuntime& getMaterialRuntime() const {return *mtlRun;}
 
 
 		const ModelPatch& getModelPatchRsrc() const {return rsrc;}
 		const ModelPatch& getModelPatchRsrc() const {return rsrc;}
 		const Vao& getCpVao() const {return cpVao;}
 		const Vao& getCpVao() const {return cpVao;}
@@ -43,8 +43,7 @@ class PatchNode: public RenderableNode
 		/// VAO for MS and BS. All VBOs could be attached except for the
 		/// VAO for MS and BS. All VBOs could be attached except for the
 		/// vert weights
 		/// vert weights
 		Vao cpVao;
 		Vao cpVao;
-		boost::scoped_ptr<MaterialRuntime> cpMtlRun;
-		boost::scoped_ptr<MaterialRuntime> dpMtlRun;
+		boost::scoped_ptr<MaterialRuntime> mtlRun;
 
 
 		/// Create a VAO given a material and an array of VBOs
 		/// Create a VAO given a material and an array of VBOs
 		static void createVao(const Material& material,
 		static void createVao(const Material& material,

+ 8 - 9
src/Scene/RenderableNode.h

@@ -9,7 +9,8 @@ class Material;
 class MaterialRuntime;
 class MaterialRuntime;
 
 
 
 
-/// Abstract class that acts as an interface for the renderable objects of the scene
+/// Abstract class that acts as an interface for the renderable objects of the
+/// scene
 class RenderableNode: public SceneNode
 class RenderableNode: public SceneNode
 {
 {
 	public:
 	public:
@@ -17,16 +18,14 @@ class RenderableNode: public SceneNode
 
 
 		virtual const Vao& getCpVao() const = 0; ///< Get color pass VAO
 		virtual const Vao& getCpVao() const = 0; ///< Get color pass VAO
 		virtual const Vao& getDpVao() const = 0; ///< Get depth pass VAO
 		virtual const Vao& getDpVao() const = 0; ///< Get depth pass VAO
+
 		/// Get vert ids number for rendering
 		/// Get vert ids number for rendering
 		virtual uint getVertIdsNum() const = 0;
 		virtual uint getVertIdsNum() const = 0;
-		/// Get color pass material
-		virtual const Material& getCpMtl() const = 0;
-		/// Get depth pass material
-		virtual const Material& getDpMtl() const = 0;
-		virtual MaterialRuntime& getCpMtlRun() = 0;
-		virtual MaterialRuntime& getDpMtlRun() = 0;
-		virtual const MaterialRuntime& getCpMtlRun() const = 0;
-		virtual const MaterialRuntime& getDpMtlRun() const = 0;
+
+		virtual const Material& getMaterial() const = 0;
+
+		virtual MaterialRuntime& getMaterialRuntime() = 0;
+		virtual const MaterialRuntime& getMaterialRuntime() const = 0;
 };
 };
 
 
 
 

+ 11 - 11
src/Scene/UserMaterialVariableRuntime.cpp

@@ -1,12 +1,12 @@
-#include "UserMaterialVariableRuntime.h"
-#include "Resources/UserMaterialVariable.h"
+#include "UserVariableRuntime.h"
+#include "Resources/UserVariable.h"
 
 
 
 
 //==============================================================================
 //==============================================================================
 // ConstructVisitor::operator() <RsrcPtr<Texture> >                            =
 // ConstructVisitor::operator() <RsrcPtr<Texture> >                            =
 //==============================================================================
 //==============================================================================
 template <>
 template <>
-void UserMaterialVariableRuntime::ConstructVisitor::
+void UserVariableRuntime::ConstructVisitor::
 	operator()<RsrcPtr<Texture> >(const RsrcPtr<Texture>& x) const
 	operator()<RsrcPtr<Texture> >(const RsrcPtr<Texture>& x) const
 {
 {
 	udvr.data = &x;
 	udvr.data = &x;
@@ -16,8 +16,8 @@ void UserMaterialVariableRuntime::ConstructVisitor::
 //==============================================================================
 //==============================================================================
 // Constructor                                                                 =
 // Constructor                                                                 =
 //==============================================================================
 //==============================================================================
-UserMaterialVariableRuntime::UserMaterialVariableRuntime(
-	const UserMaterialVariable& umv_)
+UserVariableRuntime::UserVariableRuntime(
+	const UserVariable& umv_)
 :	umv(umv_)
 :	umv(umv_)
 {
 {
 	// Initialize the data using a visitor
 	// Initialize the data using a visitor
@@ -28,7 +28,7 @@ UserMaterialVariableRuntime::UserMaterialVariableRuntime(
 //==============================================================================
 //==============================================================================
 // Destructor                                                                  =
 // Destructor                                                                  =
 //==============================================================================
 //==============================================================================
-UserMaterialVariableRuntime::~UserMaterialVariableRuntime()
+UserVariableRuntime::~UserVariableRuntime()
 {}
 {}
 
 
 
 
@@ -37,9 +37,9 @@ UserMaterialVariableRuntime::~UserMaterialVariableRuntime()
 //==============================================================================
 //==============================================================================
 
 
 template<>
 template<>
-UserMaterialVariableRuntime::ConstPtrRsrcPtrTexture&
-	UserMaterialVariableRuntime::getValue<
-	UserMaterialVariableRuntime::ConstPtrRsrcPtrTexture>()
+UserVariableRuntime::ConstPtrRsrcPtrTexture&
+	UserVariableRuntime::getValue<
+	UserVariableRuntime::ConstPtrRsrcPtrTexture>()
 {
 {
 	throw EXCEPTION("You shouldn't call this getter");
 	throw EXCEPTION("You shouldn't call this getter");
 	return boost::get<ConstPtrRsrcPtrTexture>(data);
 	return boost::get<ConstPtrRsrcPtrTexture>(data);
@@ -47,8 +47,8 @@ UserMaterialVariableRuntime::ConstPtrRsrcPtrTexture&
 
 
 
 
 template<>
 template<>
-void UserMaterialVariableRuntime::setValue<
-	UserMaterialVariableRuntime::ConstPtrRsrcPtrTexture>(
+void UserVariableRuntime::setValue<
+	UserVariableRuntime::ConstPtrRsrcPtrTexture>(
 	const ConstPtrRsrcPtrTexture& v)
 	const ConstPtrRsrcPtrTexture& v)
 {
 {
 	throw EXCEPTION("You shouldn't call this setter");
 	throw EXCEPTION("You shouldn't call this setter");

+ 10 - 10
src/Scene/UserMaterialVariableRuntime.h

@@ -7,13 +7,13 @@
 #include <boost/variant.hpp>
 #include <boost/variant.hpp>
 
 
 
 
-class UserMaterialVariable;
+class UserVariable;
 class Texture;
 class Texture;
 
 
 
 
 /// This holds a copy of the MtlUserDefinedVar's data in order to be changed
 /// This holds a copy of the MtlUserDefinedVar's data in order to be changed
 /// inside the main loop
 /// inside the main loop
-class UserMaterialVariableRuntime
+class UserVariableRuntime
 {
 {
 	public:
 	public:
 		typedef const RsrcPtr<Texture>* ConstPtrRsrcPtrTexture;
 		typedef const RsrcPtr<Texture>* ConstPtrRsrcPtrTexture;
@@ -25,13 +25,13 @@ class UserMaterialVariableRuntime
 			ConstPtrRsrcPtrTexture> DataVariant;
 			ConstPtrRsrcPtrTexture> DataVariant;
 
 
 		/// Constructor
 		/// Constructor
-		UserMaterialVariableRuntime(const UserMaterialVariable& umv);
+		UserVariableRuntime(const UserVariable& umv);
 		/// Destructor
 		/// Destructor
-		~UserMaterialVariableRuntime();
+		~UserVariableRuntime();
 
 
 		/// @name Accessors
 		/// @name Accessors
 		/// @{
 		/// @{
-		GETTER_R(UserMaterialVariable, umv, getUserMaterialVariable)
+		GETTER_R(UserVariable, umv, getUserVariable)
 		GETTER_RW(DataVariant, data, getDataVariant)
 		GETTER_RW(DataVariant, data, getDataVariant)
 
 
 		/// Get the value of the variant
 		/// Get the value of the variant
@@ -55,9 +55,9 @@ class UserMaterialVariableRuntime
 		class ConstructVisitor: public boost::static_visitor<void>
 		class ConstructVisitor: public boost::static_visitor<void>
 		{
 		{
 			public:
 			public:
-				UserMaterialVariableRuntime& udvr;
+				UserVariableRuntime& udvr;
 
 
-				ConstructVisitor(UserMaterialVariableRuntime& udmvr);
+				ConstructVisitor(UserVariableRuntime& udmvr);
 
 
 				/// Template method that applies to all DataVariant values
 				/// Template method that applies to all DataVariant values
 				/// except texture resource
 				/// except texture resource
@@ -66,13 +66,13 @@ class UserMaterialVariableRuntime
 					{udvr.getDataVariant() = x;}
 					{udvr.getDataVariant() = x;}
 		};
 		};
 
 
-		const UserMaterialVariable& umv; ///< Know the resource
+		const UserVariable& umv; ///< Know the resource
 		DataVariant data; /// The data
 		DataVariant data; /// The data
 };
 };
 
 
 
 
-inline UserMaterialVariableRuntime::ConstructVisitor::ConstructVisitor(
-	UserMaterialVariableRuntime& udvr_)
+inline UserVariableRuntime::ConstructVisitor::ConstructVisitor(
+	UserVariableRuntime& udvr_)
 :	udvr(udvr_)
 :	udvr(udvr_)
 {}
 {}