2
0
Эх сурвалжийг харах

minor fix for scn support

Nicolas Cannasse 10 жил өмнө
parent
commit
a29f8f4435
2 өөрчлөгдсөн 23 нэмэгдсэн , 6 устгасан
  1. 5 0
      h3d/impl/ScnDriver.hx
  2. 18 6
      hxd/Key.hx

+ 5 - 0
h3d/impl/ScnDriver.hx

@@ -317,6 +317,10 @@ class ScnDriver extends Driver {
 		return defTex;
 	}
 
+	public function getTexture( id : Int ) {
+		return textureMap.get(id);
+	}
+
 	@:access(h3d.impl.ManagedBuffer)
 	public function replay( op : Operation ) {
 		switch( op ) {
@@ -333,6 +337,7 @@ class ScnDriver extends Driver {
 		case SelectShader(id, data):
 			if( data != null ) {
 				var s : hxsl.RuntimeShader = haxe.Unserializer.run(data.toString());
+				@:privateAccess (s.id = hxsl.RuntimeShader.UID++); // make sure id is unique
 				savedShaders.set(id, s);
 			}
 			d.selectShader(savedShaders.get(id));

+ 18 - 6
hxd/Key.hx

@@ -79,6 +79,10 @@ class Key {
 	public static inline var LALT = ALT | LOC_LEFT;
 	public static inline var RALT = ALT | LOC_RIGHT;
 
+	#if noEngine
+	public static var frameCount = 0;
+	#end
+
 	static var initDone = false;
 	static var keyPressed : Array<Int> = [];
 
@@ -86,12 +90,20 @@ class Key {
 		return keyPressed[code] > 0;
 	}
 
+	public static inline function getFrame() {
+		#if noEngine
+		return frameCount;
+		#else
+		return h3d.Engine.getCurrent().frameCount + 1;
+		#end
+	}
+
 	public static function isPressed( code : Int ) {
-		return keyPressed[code] == h3d.Engine.getCurrent().frameCount+1;
+		return keyPressed[code] == getFrame();
 	}
 
 	public static function isReleased( code : Int ) {
-		return keyPressed[code] == -(h3d.Engine.getCurrent().frameCount+1);
+		return keyPressed[code] == -getFrame();
 	}
 
 	public static function initialize() {
@@ -125,13 +137,13 @@ class Key {
 	static function onEvent( e : Event ) {
 		switch( e.kind ) {
 		case EKeyDown:
-			keyPressed[e.keyCode] = h3d.Engine.getCurrent().frameCount+1;
+			keyPressed[e.keyCode] = getFrame();
 		case EKeyUp:
-			keyPressed[e.keyCode] = -(h3d.Engine.getCurrent().frameCount+1);
+			keyPressed[e.keyCode] = -getFrame();
 		case EPush:
-			keyPressed[e.button] = h3d.Engine.getCurrent().frameCount+1;
+			keyPressed[e.button] = getFrame();
 		case ERelease:
-			keyPressed[e.button] = -(h3d.Engine.getCurrent().frameCount+1);
+			keyPressed[e.button] = -getFrame();
 		default:
 		}
 	}