

'Shader Functions
Rem
bbdoc:
bbdoc:
End Rem
Function InitShader(Bru:TBrush)
	Bru.InitShader()
End Function
Rem
bbdoc:
bbdoc:
End Rem
Function AddShaderObject(bru:TBrush , vert:String = Null , frag:String = Null)
	bru.AddShaderObject(vert , frag)
End Function
Rem
bbdoc:
bbdoc:
End Rem
Function ListShaders(bru:TBrush) 
	bru.ListShaders()
End Function
Rem
bbdoc:
bbdoc:
End Rem
Function ShaderActivate(bru:TBrush) 
	bru.ShaderActivate()
End Function
Rem
bbdoc:
bbdoc:
End Rem
Function ShaderDeActivate(bru:TBrush) 
	bru.ShaderDeActivate()
End Function
Rem
bbdoc:
bbdoc:
End Rem
Function ProgramAttriBegin(bru:TBrush)
	bru.ProgramAttriBegin()
End Function
Rem
bbdoc:
bbdoc:
End Rem
Function ProgramAttriEnd(bru:TBrush) 
	bru.ProgramAttriEnd()
End Function
Rem
bbdoc:
bbdoc:
End Rem
Function SetUI1(bru:TBrush , Name:String , para:Int)
	bru.SetUI1(Name,para)
End Function
Rem
bbdoc:
bbdoc:
End Rem
Function SetUI2(bru:TBrush , Name:String , para:Int , para1:Int)
	bru.SetUI2(Name,para,para1)
End Function
Rem
bbdoc:
bbdoc:
End Rem
Function SetUI3(bru:TBrush , Name:String , para:Int , para1:Int , para2:Int)
	bru.SetUI3(Name,para,para1,para2)
End Function
Rem
bbdoc:
bbdoc:
End Rem
Function SetUI4(bru:TBrush , Name:String , para:Int , para1:Int , para2:Int , para3:Int) 
	bru.SetUI4(Name,para,para1,para2,para3)
End Function
Rem
bbdoc:
bbdoc:
End Rem
Function SetUF1(bru:TBrush , Name:String , para:Float)
	bru.SetUF1(Name,para)
End Function
Rem
bbdoc:
bbdoc:
End Rem
Function SetUF2(bru:TBrush , Name:String , para:Float, para1:Float)
	bru.SetUF2(Name,para,para1)
End Function
Rem
bbdoc:
bbdoc:
End Rem
Function SetUF3(bru:TBrush , Name:String , para:Float, para1:Float, para2:Float)
	bru.SetUF3(Name,para,para1,para2)
End Function
Rem
bbdoc:
bbdoc:
End Rem
Function SetUF4(bru:TBrush , Name:String , para:Float, para1:Float, para2:Float, para3:Float) 
	bru.SetUF4(Name,para,para1,para2,para3)
End Function
Rem
bbdoc:
bbdoc:
End Rem
Function SetAF1(bru:TBrush , Name:String , para:Float)
	bru.SetAF1(Name,para)
End Function
Rem
bbdoc:
bbdoc:
End Rem
Function SetAF2(bru:TBrush , Name:String , para:Float, para1:Float)
	bru.SetAF2(Name,para,para1)
End Function
Rem
bbdoc:
bbdoc:
End Rem
Function SetAF3(bru:TBrush , Name:String , para:Float, para1:Float, para2:Float)
	bru.SetAF3(Name,para,para1,para2)
End Function
Rem
bbdoc:
bbdoc:
End Rem
Function SetAF4(bru:TBrush , Name:String , para:Float, para1:Float, para2:Float, para3:Float) 
	bru.SetAF4(Name,para,para1,para2,para3)
End Function
Rem
bbdoc:
bbdoc:
End Rem
Function SetAS1(bru:TBrush , Name:String , para:Short)
	bru.SetAS1(Name,para)
End Function
Rem
bbdoc:
bbdoc:
End Rem
Function SetAS2(bru:TBrush , Name:String , para:Short , para1:Short)
	bru.SetAS2(Name,para,para1)
End Function
Rem
bbdoc:
bbdoc:
End Rem
Function SetAS3(bru:TBrush , Name:String , para:Short , para1:Short , para2:Short)
	bru.SetAS3(Name,para,para1,para2)
End Function
Rem
bbdoc:
bbdoc:
End Rem
Function SetAS4(bru:TBrush , Name:String , para:Short , para1:Short , para2:Short , para3:Short) 
	bru.SetAS4(Name,para,para1,para2,para3)
End Function
Rem
bbdoc:
bbdoc:
End Rem
Function SetAD1(bru:TBrush , Name:String , para:Double)
	bru.SetAD1(Name,para)
End Function
Rem
bbdoc:
bbdoc:
End Rem
Function SetAD2(bru:TBrush , Name:String , para:Double, para1:Double)
	bru.SetAD2(Name,para,para1)
End Function
Rem
bbdoc:
bbdoc:
End Rem
Function SetAD3(bru:TBrush , Name:String , para:Double, para1:Double, para2:Double)
	bru.SetAD3(Name,para,para1,para2)
End Function
Rem
bbdoc:
bbdoc:
End Rem
Function SetAD4(bru:TBrush , Name:String , para:Double, para1:Double, para2:Double, para3:Double) 
	bru.SetAD4(Name,para,para1,para2,para3)
End Function
Rem
bbdoc:
bbdoc:
End Rem
Function SetM2(bru:TBrush , Name:String , Matrix:Float[,] , Trans:Int)
	bru.SetM2(Name,Matrix,trans)
End Function
Rem
bbdoc:
bbdoc:
End Rem
Function SetM3(bru:TBrush , Name:String , Matrix:Float[,] , Trans:Int)
	bru.SetM3(Name,Matrix,trans)
End Function
Rem
bbdoc:
bbdoc:
End Rem
Function SetM4(bru:TBrush , Name:String , Matrix:Float[,] , Trans:Int)
	bru.SetM4(Name,Matrix,trans)
End Function
Rem
bbdoc:
bbdoc:
End Rem
Function BrushShaderTexture(bru:TBrush , texture:TTexture , index = 0)
	bru.BrushShaderTexture(texture,index)
End Function
Rem
bbdoc:
bbdoc:
End Rem
Function ActivateShader(Ent:Tentity,mode:Byte = False) 
	Ent.ActivateShader(mode)
End Function
Rem
bbdoc:
bbdoc:
End Rem
Function EntityShaderTexture(ent:Tentity , texture:TTexture , Frame = 0 , index = 0)
	ent.EntityShaderTexture(texture , Frame , index)
End Function
Rem
bbdoc:
bbdoc:
End Rem
Function TrisRendered:Int()
	Return TGLobal.TrisRendered()
End Function
Rem
bbdoc:
End Rem
Function UpdateVBOBuffer(Mesh:TMesh)
	mesh.UpdateBuffer()
End Function

Rem
bbdoc:
bbdoc:
End Rem
Function LoadMD2:TMesh(Url:Object)
	Return TMesh.LoadMD2(Url)
End Function
Rem
bbdoc:
bbdoc:
End Rem
Function AnimateMD2(MD2:TMesh , mode:Int = 1 , Speed:Float = 1.0 , Start_frame:Int = 0 , Last_Frame:Int = - 1 , Transition:Float = 0.0)
	MD2.AnimateMD2(mode , speed , start_frame , last_frame , transition)
End Function
Rem
bbdoc:
bbdoc:
End Rem
Function MD2AnimTime:Float(md2:TMesh)
	Return md2.md2_time
End Function
Rem
bbdoc:
bbdoc:
End Rem
Function MD2AnimLength:Int(md2:TMesh)
	Return md2.md2_framenumber
End Function
Rem
bbdoc:
End Rem
Function MD2Animating:Byte(md2:TMesh)
	Return md2.md2_anim
End Function
Rem
bbdoc: 
End Rem
Function MD2AnimSpeed(md2:TMesh , Speed:Float)
	md2.md2_speed = speed
End Function


'Shadow Functions

Rem
bbdoc: 
End Rem
Function ShowShadow(Active:Byte)
	TGlobal.ActiveShadow = Active
End Function

Rem
bbdoc:
End Rem
Function SetShadowMode(ZMode:Int = 1 , SRender:Int = 0)
	TGlobal.ShadowMode = SRender
	TGlobal.ShadowRender = ZMode
End Function

Rem
bbdoc:
End Rem
Function EntityShadow(MEsh:TMesh , Light:TLight)
	Light.AddShadowEntity(Mesh)
End Function

'Extra Functions
Function SetClippingPlane(X:Float , Y:Float , Z:Float , NX:Float , NY:Float , NZ:Float , Clip:Int = 0 , Camera:TCamera = Null)
	Local PL:TPlane = TPlane.CreatePlane(TVector.Create(X , Y , Z) , TVector.Create(NX , NY , NZ) )
	Camera.Update()
	glEnable(GL_CLIP_PLANE0+Clip);
	glClipPlane(GL_CLIP_PLANE0+Clip, [Double(pl.equation[0]),Double(pl.equation[1]),Double(pl.equation[2]),Double(pl.equation[3])]);
End Function

Rem
bbdoc:
End Rem
Function DeactivateClippingPlane(Clip:Int = 0)
		glDisable(GL_CLIP_PLANE0+Clip);
End Function

Rem
bbdoc:
End Rem
Function BackBufferToTexExt(tex:TTexture , Buffer:Int = GL_DEPTH_COMPONENT)
	tex.BackBufferToTexExt(,,Buffer)
End Function

Rem
bbdoc: 
End Rem
Function VectorDistance:Float(Entity:TEntity,Vector:TVector)
	Return Entity.VectorDistance(Vector)
End Function

'Terrain Functions

Rem
bbdoc:
End Rem
Function LoadTerrain:TTerrain(URL:String,Chunksize:Int = 64)
	Local T:TTerrain = New TTerrain
	T.Load(uRL,Chunksize)
	Return T
End Function

Rem
bbdoc:
End Rem
Function PositionTerrain(Terrain:TTerrain , X:Float , Y:Float , Z:Float)
	Terrain.Position X, Y, Z
End Function

Rem
bbdoc:
End Rem
Function ScaleTerrain(Terrain:TTerrain , X:Float , Y:Float , Z:Float)
	Terrain.Scale X, Y, Z
End Function

Rem
bbdoc:
End Rem
Function TextureTerrain(Terrain:TTerrain , File:String , Layer:Int = 0)
	Terrain.TextureFromFile(File ,,,Layer) 
End Function

Rem
bbdoc:
End Rem
Function TerrainY(Terrain:TTerrain,X:Float,Y:Float,Z:Float,Mode:Int = 1)
	Select Mode 
		Case 0
			Return Terrain.GetHeight(X , Y , Z)
		Case 1
			Return TerrainYMedium(Terrain , X , Y , Z)
		Case 2
			Return TerrainYSlow(Terrain , X , Y , Z)
	End Select
End Function

'Some Additional Functions

Rem
bbdoc:
End Rem
Function CanvasGraphics3D(Canvas:TGadget)
	TGlobal.CanvasGraphics3D(Canvas)
End Function

Rem
bbdoc:
End Rem
Function UpdateCanvas3D(Canvas:TGadget)
	TGlobal.UpdateCanvas3D(Canvas)
End Function

Rem
bbdoc:
End Rem
Function MeshUseVBO(Mesh:TMesh , State:Byte) 
	Mesh.MeshUseVBO(State)
End Function

Rem
bbdoc:
End Rem
Function EntityRenderMode(Entity:TEntity , Mode:Int = RENDER_FULL)
	Entity.RenderStyle = Mode
End Function



