FreePlanarReflection reflection
Parameters
| reflection - managed reflection handle, or zero |
Description
|
Detaches a reflection handle's receivers and frees its service state. GPU resources stay alive only as long as already submitted work needs them, then retire. The camera, plane entity and receiver materials remain available. After freeing, set your variable to zero and do not reuse the old handle. Passing zero does nothing. A handle invalidated by camera, plane or world deletion can still be freed once. Settings and receiver association commands require a live handle. Recreating a handle requires associating its receivers again. Requires Extended mode. See also: CreatePlanarReflection, PlanarReflectionSettings, PlanarReflectionEnabled, EntityPlanarReflection. |
Example
; Extended mode. A finite vertical mirror reflects the moving marker. Graphics3D 800,600,0,2 SetBuffer BackBuffer() camera=CreateCamera():PositionEntity camera,3,2.7,-7 light=CreateLight():RotateEntity light,35,-25,0 AmbientLight 65,65,65 plane=CreatePivot():PositionEntity plane,0,1.8,3:RotateEntity plane,-90,0,0 PointEntity camera,plane mirror=CreateMesh():surface=CreateSurface(mirror) AddVertex surface,-2,0,-1.5,0,0:AddVertex surface,2,0,-1.5,1,0 AddVertex surface,2,0,1.5,1,1:AddVertex surface,-2,0,1.5,0,1 AddTriangle surface,0,3,1:AddTriangle surface,1,3,2:UpdateNormals mirror PositionEntity mirror,0,1.8,3:RotateEntity mirror,-90,0,0 material=LoadShader("builtin:planar-reflection") ShaderColor material,"FallbackColor",35,65,80 EntityShader mirror,material reflection=CreatePlanarReflection(camera,plane) EntityPlanarReflection mirror,reflection marker=CreateCone(16):ScaleEntity marker,.55,1.2,.55:PositionEntity marker,-1.4,1,-4 EntityColor marker,240,160,35 arm=CreateCylinder(12,True,marker):ScaleEntity arm,.12,.9,.12 RotateEntity arm,0,0,90:PositionEntity arm,.7,.4,0:EntityColor arm,50,170,190 floor=CreatePlane():PositionEntity floor,0,-.3,0:EntityColor floor,40,50,65 active=True:scale#=.5 While Not KeyHit(1) TurnEntity marker,0,.4,0 If KeyHit(57) If reflection FreePlanarReflection reflection:reflection=0 Else reflection=CreatePlanarReflection(camera,plane) EntityPlanarReflection mirror,reflection EndIf EndIf RenderWorld Text 12,12,"Space frees/recreates the reflection handle; Esc exits" Flip Wend FreePlanarReflection reflection FreeShader material ClearWorld End
Index