Переглянути джерело

Allow loading shaders from hrt/shaders

Clement Espeute 3 роки тому
батько
коміт
b4462c7a6d
2 змінених файлів з 13 додано та 6 видалено
  1. 12 5
      hide/tools/Macros.hx
  2. 1 1
      hide/tools/ShaderLoader.hx

+ 12 - 5
hide/tools/Macros.hx

@@ -16,11 +16,18 @@ class Macros {
 
 	#if macro
 	static function includeShaderSources() {
-		var path = Context.resolvePath("h3d/shader/BaseMesh.hx");
-		var dir = new haxe.io.Path(path).dir;
-		for( f in sys.FileSystem.readDirectory(dir) )
-			if( StringTools.endsWith(f,".hx") )
-				Context.addResource("shader/" + f.substr(0, -3), sys.io.File.getBytes(dir + "/" + f));
+		var paths = [
+			"h3d/shader/BaseMesh.hx",
+			"hrt/shader/BaseEmitter.hx",
+		];
+
+		for (pathStr in paths) {
+			var path = Context.resolvePath(pathStr);
+			var dir = new haxe.io.Path(path).dir;
+			for( f in sys.FileSystem.readDirectory(dir) )
+				if( StringTools.endsWith(f,".hx") )
+					Context.addResource("shader/" + f.substr(0, -3), sys.io.File.getBytes(dir + "/" + f));
+		}
 	}
 
 	public static function buildSaveLoad() {

+ 1 - 1
hide/tools/ShaderLoader.hx

@@ -73,7 +73,7 @@ class ShaderLoader {
 			if( sys.FileSystem.exists(file) )
 				return { file : file, expr : loadShaderString(file, sys.io.File.getContent(file), null) };
 		}
-		if( StringTools.startsWith(name,"h3d.shader.") ) {
+		if( StringTools.startsWith(name,"h3d.shader.") || StringTools.startsWith(name,"hrt.shader.")) {
 			var r = haxe.Resource.getString("shader/" + name.substr(11));
 			if( r != null ) return { file : null, expr : loadShaderString(path, r, null) };
 		}