Global flagRender:Int = 0
Global flagGrab:Int=0
'WRAP VERSIONE MINIB3D
Function signalRender()
	flagRender=2
	flagGrab=0
End Function

Function signalGrab()
	If(flagGrab=0 And flagRender<=0)
	  'RIMETTI SE VUOI FEATURIZZARE IL RENDER SWITCH' GrabImage(ViewMngr.GrabbedImage,200,32)
	   flagGrab=flagGrab+1
	   Debuglog "GRAB "+flagGrab
	EndIf
	
End Function

Function VGC_createCamera:tCamera()
   Return CreateCamera()
EndFunction 

Function VGC_CameraViewport(camera:tCamera,x:Int,y:Int,w:Int,h:Int)
	CameraViewport camera,x,y,w,h
End Function

Function VGC_renderWorld()
  'RIMETTI SE VUOI FEATURIZZARE IL RENDER SWITCH'If(flagRender>0)
   RenderWorld() 
   flagRender=flagRender-1
   'DebugLog "RENDER "+flagRender+" "+flagGrab
  'RIMETTI SE VUOI FEATURIZZARE IL RENDER SWITCH'EndIf
EndFunction 

Function VGC_renderWorld_view() 
		ViewMngr.View[0].CAMERA.HideEntity() 
		ViewMngr.View[1].Camera.HideEntity()
		ViewMngr.View[2].Camera.HideEntity()
		ViewMngr.View[3].Camera.HideEntity()
		If(ViewMngr.View[0].sizeOfViewPort() > 0) Then ViewMngr.View[0].CAMERA.ShowEntity() 
		If(ViewMngr.View[1].sizeOfViewPort() > 0) Then ViewMngr.View[1].CAMERA.ShowEntity() 
		If(ViewMngr.View[2].sizeOfViewPort() > 0) Then ViewMngr.View[2].CAMERA.ShowEntity() 
		If(ViewMngr.View[3].sizeOfViewPort() > 0) Then ViewMngr.View[3].CAMERA.ShowEntity() 

		tForm_MediaManager(ProgMngr.FormMngr.getQuad("media")).CameraThumb.HideEntity()
  'RIMETTI SE VUOI FEATURIZZARE IL RENDER SWITCH'If(flagRender>0)		
	RenderWorld() 
    flagRender=flagRender-1
    'DebugLog "RENDER V"+flagRender+" "+flagGrab
 'RIMETTI SE VUOI FEATURIZZARE IL RENDER SWITCH' EndIf	
  
End Function

Function VGC_renderWorld_Thumb()
		ViewMngr.View[0].Camera.HideEntity()
		ViewMngr.View[1].Camera.HideEntity()
		ViewMngr.View[2].Camera.HideEntity()
		ViewMngr.View[3].Camera.HideEntity()
		tForm_MediaManager(ProgMngr.FormMngr.getQuad("media")).CameraThumb.ShowEntity()
		DebugLog "render"
	RenderWorld() 
End Function



Function VGC_updateWorld()
   UpdateWorld()
End Function


Function VGC_loadmesh:TEntity(file:String)
	Return LoadMesh(file)	'LoadAnimMesh(file)'
End Function


Function VGC_createCube:tEntity()
	Return CreateCube()
End Function

Function VGC_PositionEntity(entity:tEntity,x:Float,y:Float,z:Float)
	PositionEntity entity,x,y,z
End Function

Function VGC_RotateEntity(entity:tEntity, x:Float, y:Float, z:Float) 
	RotateEntity entity,x,y,z
End Function

Function VGC_loadSprite:TSprite(file:String) 
    Local testImg:TImage = LoadImage(file) 
	If(testImg <> Null) 
	   testImg = Null
	   Return LoadSprite(file) 

	EndIf
End Function

Function VGC_Wireframe(value:Int) 

	Wireframe value
End Function


Function VGC_setViewPort(x:Int, y:Int, w:Int, h:Int) 
	SetViewport x, y + S_screenY - ScreenY, W, h
End Function


