瀏覽代碼

per-context instance

ncannasse 7 年之前
父節點
當前提交
7c366cd237
共有 1 個文件被更改,包括 8 次插入4 次删除
  1. 8 4
      h3d/prim/Plan2D.hx

+ 8 - 4
h3d/prim/Plan2D.hx

@@ -4,11 +4,11 @@ class Plan2D extends Primitive {
 
 	function new() {
 	}
-	
+
 	override function triCount() {
 		return 2;
 	}
-	
+
 	override function vertexCount() {
 		return 4;
 	}
@@ -43,9 +43,13 @@ class Plan2D extends Primitive {
 		engine.renderQuadBuffer(buffer);
 	}
 
-	static var inst = null;
 	public static function get() {
-		if( inst == null ) inst = new Plan2D();
+		var engine = h3d.Engine.getCurrent();
+		var inst = @:privateAccess engine.resCache.get(Plan2D);
+		if( inst == null ) {
+			inst = new Plan2D();
+			@:privateAccess engine.resCache.set(Plan2D, inst);
+		}
 		return inst;
 	}