Garry's Mod Wiki

Revision Difference

render.PushFilterMag#561147

<function name="PushFilterMag" parent="render" type="libraryfunc"> <description>Pushes a texture filter onto the magnification texture filter stack.⤶ ⤶ See also <page>render.PushFilterMin</page> and <page>render.PopFilterMag</page>. </description>⤶ <description>⤶ Pushes (Adds) a texture filter onto the magnification texture filter stack. This will modify how textures are stretched to sizes larger than their native resolution for upcoming rendering and drawing operations. ⤶ For a version of this same function that modifies filtering for texture sizes smaller than their native resolution, see <page text="render.PushFilterMin()">render.PushFilterMin</page>⤶ ⤶ Always be sure to call <page text="render.PopFilterMag()">render.PopFilterMag</page> afterwards to avoid texture filtering problems.⤶ ⤶ For more detailed information and a usage example, see <page text="the texture minification and magnification render reference.">render_min_mag_filters</page>⤶ ⤶ </description>⤶ <realm>Client and Menu</realm> <args> <arg name="texFilterType" type="number">The texture filter type, see <page>Enums/TEXFILTER</page></arg> <arg name="texFilterType" type="number">The texture filter to use. For available options, see <page>Enums/TEXFILTER</page></arg> </args> </function> ⤶ <example>⤶ <description>Showcases the difference between different filtering modes.</description>⤶ <code>⤶ -- Calling Material() every frame is quite expensive⤶ -- So we call it once, outside of any hooks, and cache the result in a local variable⤶ local ourMat = Material( "entities/sent_ball.png" )⤶ local sizeBig = 500⤶ local sizeSmall = 100⤶ local pos = 100⤶ ⤶ local filters = {}⤶ filters[ TEXFILTER.NONE ] = "NONE"⤶ filters[ TEXFILTER.POINT ] = "POINT"⤶ filters[ TEXFILTER.LINEAR ] = "LINEAR"⤶ filters[ TEXFILTER.ANISOTROPIC ] = "ANISOTROPIC"⤶ ⤶ hook.Add( "HUDPaint", "PutAUniqueHookNameHere", function()⤶ surface.SetDrawColor( 255, 255, 255, 255 ) -- Set the drawing color⤶ surface.SetMaterial( ourMat ) -- Use our cached material⤶ ⤶ -- Show each filter for 1 second each ⤶ -- (TEXFILTER enums correspond to integer numbers)⤶ local filter = math.floor( CurTime() % 4 )⤶ ⤶ render.PushFilterMag( filter )⤶ render.PushFilterMin( filter )⤶ ⤶ -- Actually draw the rectangle with a magnification filter⤶ surface.DrawTexturedRect( pos, pos, sizeBig, sizeBig )⤶ ⤶ -- Actually draw the rectangle with a minification filter⤶ surface.DrawTexturedRect( pos + sizeBig + 1, pos, sizeSmall, sizeSmall )⤶ ⤶ render.PopFilterMin()⤶ render.PopFilterMag()⤶ ⤶ draw.SimpleText( filters[ filter ], "ChatFont", pos + 1, pos + 1, color_white )⤶ ⤶ end )⤶ </code>⤶ <output><image src="70c/8dc3a1e216d7866.gif" size="1659874" name="hl2_eKnL9y0wEk.gif" /></output>⤶ ⤶ </example>