소스 검색

Fixed canvas.Flush() so it always updates any render target modifications.

Mark Sibly 7 년 전
부모
커밋
1d540836b6
2개의 변경된 파일28개의 추가작업 그리고 23개의 파일을 삭제
  1. 9 4
      modules/mojo/graphics/canvas.monkey2
  2. 19 19
      modules/mojo/graphics/graphicsdevice.monkey2

+ 9 - 4
modules/mojo/graphics/canvas.monkey2

@@ -1281,9 +1281,13 @@ Class Canvas
 		DebugAssert( Not _lighting,"Canvas.Clear() cannot be used while lighting" )
 		If _lighting Return
 		
-		Flush()
+		Validate()
 			
 		_device.Clear( color )
+
+		_drawNV=0
+		_drawOps.Clear()
+		_drawOp=New DrawOp
 	End
 	
 	#rem monkeydoc Flushes drawing commands.
@@ -1294,11 +1298,13 @@ Class Canvas
 	
 	#end
 	Method Flush()
-	
-		Validate()
 		
+		_device.FlushTarget()
+	
 		If _drawOps.Empty Return
 		
+		Validate()
+		
 		_drawVB.Invalidate( 0,_drawNV )
 		
 		_drawVB.Unlock()
@@ -1761,7 +1767,6 @@ Class Canvas
 		Endif
 		
 		_dirty=Null
-		
 	End
 	
 	Method RenderDrawOps( rpass:Int )

+ 19 - 19
modules/mojo/graphics/graphicsdevice.monkey2

@@ -363,6 +363,25 @@ Class GraphicsDevice
 		
 		glCheck()
 	End
+
+	Method FlushTarget()
+		
+		If Not _modified Return
+		
+		_modified=False
+		
+		If Not _rtarget Or Not _rtarget.NumColorTextures Return
+			
+'		Validate()
+			
+		For Local i:=0 Until _rtarget.NumColorTextures
+			
+			Local texture:=_rtarget.GetColorTexture( i )
+			
+			texture.Modified( _viewport & _scissor )
+		Next
+		
+	End
 	
 	Private
 	
@@ -447,25 +466,6 @@ Class GraphicsDevice
 		glCheck()
 	End
 	
-	Method FlushTarget()
-		
-		If Not _modified Return
-		
-		_modified=False
-		
-		If Not _rtarget Or Not _rtarget.NumColorTextures Return
-			
-'		Validate()
-			
-		For Local i:=0 Until _rtarget.NumColorTextures
-			
-			Local texture:=_rtarget.GetColorTexture( i )
-			
-			texture.Modified( _viewport & _scissor )
-		Next
-		
-	End
-	
 	Method Validate()
 		
 		glCheck()