Sfoglia il codice sorgente

separate Driver.end() (called in Engine.end) / Driver.present() (called at end of mainLoop)

ncannasse 7 anni fa
parent
commit
4d000b38c9
5 ha cambiato i file con 24 aggiunte e 8 eliminazioni
  1. 1 1
      h3d/Engine.hx
  2. 3 0
      h3d/impl/Driver.hx
  3. 13 1
      h3d/impl/GlDriver.hx
  4. 5 0
      h3d/impl/LogDriver.hx
  5. 2 6
      hxd/System.hl.hx

+ 1 - 1
h3d/Engine.hx

@@ -283,7 +283,7 @@ class Engine {
 	}
 
 	public function end() {
-		driver.present();
+		driver.end();
 	}
 
 	public function getCurrentTarget() {

+ 3 - 0
h3d/impl/Driver.hx

@@ -202,6 +202,9 @@ class Driver {
 	public function present() {
 	}
 
+	public function end() {
+	}
+
 	public function setDebug( b : Bool ) {
 	}
 

+ 13 - 1
h3d/impl/GlDriver.hx

@@ -1031,10 +1031,18 @@ class GlDriver extends Driver {
 		gl.drawElements(GL.TRIANGLES, ntriangles * 3, GL.UNSIGNED_SHORT, startIndex * 2);
 	}
 
-	override function present() {
+	override function end() {
 		// no gl finish or flush !
 	}
 
+	override function present() {
+		#if hlsdl
+		@:privateAccess hxd.Stage.inst.window.present();
+		#elseif usesys
+		haxe.System.present();
+		#end
+	}
+
 	override function isDisposed() {
 		#if (nme || openfl) //lime ??
 		return false;
@@ -1095,6 +1103,10 @@ class GlDriver extends Driver {
 			gl.viewport(0, 0, bufferWidth, bufferHeight);
 			return;
 		}
+
+		if( tex.depthBuffer != null && (tex.depthBuffer.width != tex.width || tex.depthBuffer.height != tex.height) )
+			throw "Invalid depth buffer size : does not match render target size";
+
 		#if js
 		if( mipLevel > 0 ) throw "Cannot render to mipLevel, use upload() instead";
 		#end

+ 5 - 0
h3d/impl/LogDriver.hx

@@ -284,6 +284,11 @@ class LogDriver extends Driver {
 		d.setRenderTargets(textures);
 	}
 
+	override function end() {
+		log('End');
+		d.end();
+	}
+	
 	override function present() {
 		log('Present');
 		d.present();

+ 2 - 6
hxd/System.hl.hx

@@ -69,12 +69,8 @@ class System {
 		if( loopFunc != null ) loopFunc();
 
 		// present
-		#if usesys
-		haxe.System.present();
-		#elseif hlsdl
-		@:privateAccess hxd.Stage.inst.window.present();
-		#end
-
+		var cur = h3d.Engine.getCurrent();
+		if( cur != null ) cur.driver.present();
 		return true;
 	}