Garry's Mod Wiki

render.DrawTextureToScreenRect

  render.DrawTextureToScreenRect( ITexture tex, number x, number y, number width, number height )

Description

Draws a textured rectangle.

This is a rendering function that requires a 2d rendering context.

This means that it will only work in 2d Rendering Hooks.

Arguments

1 ITexture tex
The texture to draw.
2 number x
The x coordinate of the rectangle to draw.
3 number y
The y coordinate of the rectangle to draw.
4 number width
The width of the rectangle to draw.
5 number height
The height of the rectangle to draw.

Example

local mat = CreateMaterial( "testHackTexture", "UnlitGeneric", { ["$basetexture"] = "_rt_WaterRefraction", } ) local refractTex = mat:GetTexture( "$basetexture" ) mat:SetTexture( "$basetexture", "_rt_WaterReflection" ) local reflectTex = mat:GetTexture( "$basetexture" ) hook.Add( "HUDPaint", "drawWaterReflectRefract", function() render.DrawTextureToScreenRect( refractTex, 0, 0, ScrW() / 3, ScrH() / 3 ) render.DrawTextureToScreenRect( reflectTex, ScrW() / 3 * 2, 0, ScrW() / 3, ScrH() / 3 ) end )