Garry's Mod Wiki

Revision Difference

render.DrawTextureToScreenRect#566358

<function name="DrawTextureToScreenRect" parent="render" type="libraryfunc"> <description> Draws a textured rectangle. <rendercontext hook="false" type="2D"></rendercontext> </description> <realm>Client</realm> <file line="158-L166">lua/includes/extensions/client/render.lua</file> <args> <arg name="tex" type="ITexture">The texture to draw.</arg> <arg name="x" type="number">The x coordinate of the rectangle to draw.</arg> <arg name="y" type="number">The y coordinate of the rectangle to draw.</arg> <arg name="width" type="number">The width of the rectangle to draw.</arg> <arg name="height" type="number">The height of the rectangle to draw.</arg> </args> </function> ⤶ <example>⤶ <summary>Draws the water reflection and water refractions textures in top corners of the screen.</summary>⤶ <code>⤶ 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 )⤶ </code>⤶ </example>