Kaynağa Gözat

Updates and fixes.

Mark Sibly 7 yıl önce
ebeveyn
işleme
7f65527b77

+ 9 - 8
modules/mojo/graphics/graphicsdevice.monkey2

@@ -306,6 +306,8 @@ Class GraphicsDevice
 	Method Render( order:Int,count:Int,offset:Int=0 )
 		
 		Validate2()
+		
+		If Not _shaderValid Return
 	
 		Local n:=order*count
 	
@@ -327,6 +329,8 @@ Class GraphicsDevice
 	Method RenderIndexed( order:Int,count:Int,offset:Int=0 )
 		
 		Validate2()
+
+		If Not _shaderValid Return
 		
 		Local n:=order*count
 		
@@ -334,15 +338,9 @@ Class GraphicsDevice
 		
 		Select _indexBuffer.Format
 		Case IndexFormat.UINT16
-'			For Local i:=0 Until n
-'				If Cast<UShort Ptr>( _indexBuffer.Data )[i]>=_vertexBuffer.Length DebugStop()
-'			Next
 			gltype=GL_UNSIGNED_SHORT
 			pitch=2
 		Case IndexFormat.UINT32
-'			For Local i:=0 Until n
-'				If Cast<UInt Ptr>( _indexBuffer.Data )[i]>=_vertexBuffer.Length DebugStop()
-'			Next
 			gltype=GL_UNSIGNED_INT
 			pitch=4
 		Default 
@@ -410,6 +408,7 @@ Class GraphicsDevice
 	Field _indexBuffer:IndexBuffer
 	Field _ublocks:=New UniformBlock[8]
 	Field _shader:Shader
+	Field _shaderValid:Bool
 	Field _rpass:Int
 	
 	Global _glSeq:Int
@@ -644,15 +643,17 @@ Class GraphicsDevice
 		If _dirty2 & Dirty.Shader
 			
 			_ublocks[0]=_shader.Uniforms
+			
+			_shaderValid=_shader.RenderPassMask & 1 Shl _rpass <> 0
 		
-			_shader.Bind( _rpass )
+			If _shaderValid _shader.Bind( _rpass )
 		Endif
 		
 		_vertexBuffer.Validate()
 		
 		If _indexBuffer _indexBuffer.Validate()
 
-		_shader.ValidateUniforms( _rpass,_ublocks )
+		If _shaderValid _shader.ValidateUniforms( _rpass,_ublocks )
 		
 		glCheck()
 		

+ 0 - 2
modules/mojo/graphics/shader.monkey2

@@ -363,7 +363,6 @@ Class Shader
 		
 		Local chunks:=New String[3]
 		
-		#rem
 		'Find //@imports in common section
 		Repeat
 			Local i:=cs.Find( "~n//@import" )
@@ -383,7 +382,6 @@ Class Shader
 			chunks[2]+=tchunks[2]
 			
 		Forever
-		#end
 		
 		chunks[0]+=cs
 		chunks[1]+=vs

+ 10 - 2
modules/mojo/graphics/texture.monkey2

@@ -300,11 +300,19 @@ Class Texture Extends Resource
 		Return Null
 	End
 
-	Function Load:Texture( path:String,flags:TextureFlags )
+	Function Load:Texture( path:String,flags:TextureFlags,flipNormalY:Bool=False )
 
 		Local pixmap:=Pixmap.Load( path,,True )
 		If Not pixmap Return Null
 		
+		If flipNormalY
+			For Local y:=0 Until pixmap.Height
+				For Local x:=0 Until pixmap.Width
+					pixmap.SetPixelARGB( x,y,pixmap.GetPixelARGB( x,y ) ~ $ff00 )
+				Next
+			Next
+		Endif
+		
 		Local texture:=New Texture( pixmap,flags )
 		
 		Return texture
@@ -391,7 +399,7 @@ Class Texture Extends Resource
 	#end
 	Method Bind( unit:Int )
 		
-		Assert( Not _cubeMap )
+'		Assert( unit<7 And Not _cubeMap )
 		
 		Local gltex:=ValidateGLTexture()
 		

+ 5 - 1
modules/mojo/graphics/vertex2f.monkey2

@@ -46,11 +46,15 @@ Class Vertex2fFormat Extends VertexFormat
 	End
 
 	Method UpdateGLAttribs() Override
-		
 		glEnableVertexAttribArray( A_POSITION ) ; glVertexAttribPointer( A_POSITION,2,GL_FLOAT,False,Pitch,Cast<Void Ptr>( 0 ) )
 		glEnableVertexAttribArray( A_TEXCOORD0 ) ; glVertexAttribPointer( A_TEXCOORD0,2,GL_FLOAT,False,Pitch,Cast<Void Ptr>( 8 ) )
 		glEnableVertexAttribArray( A_TEXCOORD1 ) ; glVertexAttribPointer( A_TEXCOORD1,2,GL_FLOAT,False,Pitch,Cast<Void Ptr>( 16 ) )
 		glEnableVertexAttribArray( A_COLOR ) ; glVertexAttribPointer( A_COLOR,4,GL_UNSIGNED_BYTE,True,Pitch,Cast<Void Ptr>( 24 ) )
+		'Need these to shut up android emulator.
+		glDisableVertexAttribArray( A_NORMAL )
+		glDisableVertexAttribArray( A_TANGENT )
+		glDisableVertexAttribArray( A_WEIGHTS )
+		glDisableVertexAttribArray( A_BONES )
 	End
 	
 End

+ 1 - 0
modules/mojo/graphics/vertex3f.monkey2

@@ -106,6 +106,7 @@ Class Vertex3fFormat Extends VertexFormat
 		glEnableVertexAttribArray( A_POSITION ) ; glVertexAttribPointer( A_POSITION,3,GL_FLOAT,False,Pitch,Cast<Void Ptr>( 0 ) )
 		glEnableVertexAttribArray( A_TEXCOORD0 ) ; glVertexAttribPointer( A_TEXCOORD0,2,GL_FLOAT,False,Pitch,Cast<Void Ptr>( 12 ) )
 		glEnableVertexAttribArray( A_TEXCOORD1 ) ; glVertexAttribPointer( A_TEXCOORD1,2,GL_FLOAT,False,Pitch,Cast<Void Ptr>( 20 ) )
+		glDisableVertexAttribArray( A_COLOR )
 		glEnableVertexAttribArray( A_NORMAL ) ; glVertexAttribPointer( A_NORMAL,3,GL_FLOAT,False,Pitch,Cast<Void Ptr>( 28 ) )
 		glEnableVertexAttribArray( A_TANGENT ) ; glVertexAttribPointer( A_TANGENT,4,GL_FLOAT,False,Pitch,Cast<Void Ptr>( 40 ) )
 		glEnableVertexAttribArray( A_WEIGHTS ) ; glVertexAttribPointer( A_WEIGHTS,4,GL_FLOAT,False,Pitch,Cast<Void Ptr>( 56 ) )