瀏覽代碼

Added 'instance' UniformBlock type.

Mark Sibly 8 年之前
父節點
當前提交
581ebc9a05
共有 3 個文件被更改,包括 13 次插入18 次删除
  1. 1 1
      modules/mojo/graphics/image.monkey2
  2. 11 16
      modules/mojo/graphics/shader.monkey2
  3. 1 1
      modules/mojo/graphics/uniformblock.monkey2

+ 1 - 1
modules/mojo/graphics/image.monkey2

@@ -454,7 +454,7 @@ Class Image Extends Resource
 	
 		_rect=rect
 		_shader=shader
-		_uniforms=New UniformBlock( 2 )
+		_uniforms=New UniformBlock( 3 )
 		
 		SetTexture( 0,texture )
 		

+ 11 - 16
modules/mojo/graphics/shader.monkey2

@@ -32,9 +32,12 @@ Class GLUniform
 		If name.StartsWith( "r_" )
 			name=name.Slice( 2 )
 			block=1
-		Else If name.StartsWith( "m_" )
+		Else If name.StartsWith( "i_" )
 			name=name.Slice( 2 )
 			block=2
+		Else If name.StartsWith( "m_" )
+			name=name.Slice( 2 )
+			block=3
 		Endif
 		
 		uniformId=UniformBlock.GetUniformId( name,block )
@@ -106,25 +109,15 @@ Class GLProgram
 
 	Method ValidateUniforms( ublocks:UniformBlock[] )
 		
-		#rem
-		If _glRetroSeq<>glRetroSeq
-			For Local i:=0 Until _ublockSeqs.Length
-				_ublockSeqs[i]=0
-			Next
-			_glRetroSeq=glRetroSeq
-		Endif
-		#end
-		
-'		For Local i:=0 Until 8
-'			glActiveTexture( GL_TEXTURE0+i )
-'			glBindTexture( GL_TEXTURE_2D,0 )
-'		Next
-
 		For Local i:=0 Until 4
 
 			Local ublock:=ublocks[ i ]
 			
-			If Not ublock Or ublock.Seq=_ublockSeqs[i] Continue
+			If Not ublock Continue
+			
+			If ublock.Name<>i Print "OOOPS!"
+			
+			If ublock.Seq=_ublockSeqs[i] Continue
 			
 			_ublockSeqs[i]=ublock.Seq
 			
@@ -165,6 +158,8 @@ Class GLProgram
 		Next
 		
 		For Local i:=0 Until 4
+			
+'			If Not ublocks[i] continue
 		
 			If Not _textures[i] Continue
 			

+ 1 - 1
modules/mojo/graphics/uniformblock.monkey2

@@ -265,7 +265,7 @@ Class UniformBlock Extends Resource
 	End
 	
 	Method GetFloatPtr:Float Ptr( id:Int,type:Type )
-		DebugAssert( _uniforms[id].type=type,"Invalid uniform type" )
+		DebugAssert( _uniforms[id].type=type,"Invalid uniform type "+Int(_uniforms[id].type)+" expecting "+Int(type) )
 		Return _uniforms[id].GetFloatPtr()
 	End