Garry's Mod Wiki

render.RenderFlashlights

  render.RenderFlashlights( function renderFunc )

Description

Renders additive flashlights on an IMesh, a direct replacement for render.PushFlashlightMode.

Arguments

1 function renderFunc
The function that renders the IMesh, or a model.

Example

Shows an example usage of this function.

function ENT:CreateMesh() -- Destroy any previous meshes if ( self.Mesh ) then self.Mesh:Destroy() end -- Get a list of all meshes of a model local visualMeshes = util.GetModelMeshes( "models/combine_helicopter/helicopter_bomb01.mdl" ) -- Check if the model even exists if ( !visualMeshes ) then return end -- Select the first mesh local visualMesh = visualMeshes[ 1 ] -- Set the material to draw the mesh with from the model data self.myMaterial = Material( visualMesh.material ) -- You can apply any changes to visualMesh.trianges table here, distorting the mesh -- or any other changes you can come up with -- Create and build the mesh self.Mesh = Mesh( visualMesh.material ) self.Mesh:BuildFromTriangles( visualMesh.triangles ) end function ENT:DrawModelOrMesh() -- Move the mesh to the entity's position for upcoming drawing operation cam.PushModelMatrix( self:GetWorldTransformMatrix() ) -- The material to render our mesh with render.SetMaterial( self.myMaterial ) -- Draw our mesh self.Mesh:Draw() -- Undo the cam.PushModelMatrix call above cam.PopModelMatrix() end function ENT:Draw() if ( !self.Mesh ) then return self:CreateMesh() end -- Draw the mesh normally self:DrawModelOrMesh() -- Draw the additive flashlight layers render.RenderFlashlights( function() self:DrawModelOrMesh() end ) end