Sfoglia il codice sorgente

mouse events + resize ok

ncannasse 8 anni fa
parent
commit
57c8a002fb
3 ha cambiato i file con 17 aggiunte e 14 eliminazioni
  1. 7 7
      h3d/impl/DirectXDriver.hx
  2. 9 7
      hxd/Stage.hl.hx
  3. 1 0
      hxd/System.hl.hx

+ 7 - 7
h3d/impl/DirectXDriver.hx

@@ -135,11 +135,6 @@ class DirectXDriver extends h3d.impl.Driver {
 			defaultDepthInst.width = width;
 			defaultDepthInst.height = height;
 		}
-		if( extraDepthInst != null ) @:privateAccess {
-			extraDepthInst.width = width;
-			extraDepthInst.height = height;
-			extraDepthInst.dispose();
-		}
 
 		var buf = Driver.getBackBuffer();
 		defaultTarget = Driver.createRenderTargetView(buf);
@@ -149,6 +144,13 @@ class DirectXDriver extends h3d.impl.Driver {
 		outputHeight = height;
 
 		setRenderTarget(null);
+
+		if( extraDepthInst != null ) @:privateAccess {
+			extraDepthInst.width = width;
+			extraDepthInst.height = height;
+			extraDepthInst.dispose();
+			extraDepthInst.b = allocDepthBuffer(extraDepthInst);
+		}
 	}
 
 	override function begin(frame:Int) {
@@ -183,8 +185,6 @@ class DirectXDriver extends h3d.impl.Driver {
 	override function getDefaultDepthBuffer():h3d.mat.DepthBuffer {
 		if( extraDepthInst == null )
 			extraDepthInst = new h3d.mat.DepthBuffer(outputWidth, outputHeight);
-		if( extraDepthInst.isDisposed() )
-			allocDepthBuffer(extraDepthInst);
 		return extraDepthInst;
 	}
 

+ 9 - 7
hxd/Stage.hl.hx

@@ -116,7 +116,7 @@ class Stage {
 		return false;
 	}
 
-	#if (psgl || hldx)
+	#if psgl
 
 	function get_vsync() : Bool return true;
 
@@ -133,7 +133,7 @@ class Stage {
 		return b;
 	}
 
-	function onEvent( e : sdl.Event ) : Bool {
+	function onEvent( e : #if hldx dx.Event #else sdl.Event #end ) : Bool {
 		var eh = null;
 		switch( e.type ) {
 		case WindowState:
@@ -169,6 +169,12 @@ class Stage {
 			curMouseX = e.mouseX;
 			curMouseY = e.mouseY;
 			eh = new Event(EMove, e.mouseX, e.mouseY);
+		case MouseWheel:
+			eh = new Event(EWheel, mouseX, mouseY);
+			eh.wheelDelta = -e.wheelDelta;
+		#if hlsdl
+		case GControllerAdded, GControllerRemoved, GControllerUp, GControllerDown, GControllerAxis:
+			@:privateAccess hxd.Pad.onEvent( e );
 		case KeyDown:
 			eh = new Event(EKeyDown);
 			if( e.keyCode & (1 << 30) != 0 ) e.keyCode = (e.keyCode & ((1 << 30) - 1)) + 1000;
@@ -187,11 +193,6 @@ class Stage {
 				if( e.keyCode == K.SHIFT ) shiftDown = false;
 				onEvent(e);
 			}
-		case MouseWheel:
-			eh = new Event(EWheel, mouseX, mouseY);
-			eh.wheelDelta = -e.wheelDelta;
-		case GControllerAdded, GControllerRemoved, GControllerUp, GControllerDown, GControllerAxis:
-			@:privateAccess hxd.Pad.onEvent( e );
 		case TextInput:
 			eh = new Event(ETextInput, mouseX, mouseY);
 			var c = e.keyCode & 0xFF;
@@ -203,6 +204,7 @@ class Stage {
 				((c & 0x1F) << 12) | (((e.keyCode >> 8) & 0x7F) << 6) | ((e.keyCode >> 16) & 0x7F);
 			else
 				((c & 0x0F) << 18) | (((e.keyCode >> 8) & 0x7F) << 12) | (((e.keyCode >> 16) & 0x7F) << 6) | ((e.keyCode >> 24) & 0x7F);
+		#end
 		case Quit:
 			return onClose();
 		default:

+ 1 - 0
hxd/System.hl.hx

@@ -81,6 +81,7 @@ class System {
 		#elseif hldx
 			@:privateAccess Stage.inst = new Stage(title, width, height);
 			init();
+			dx.Loop.defaultEventHandler = @:privateAccess Stage.inst.onEvent;
 		#end
 
 		#end