Garry's Mod Wiki

Revision Difference

render.PushFilterMag#561133

<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> <realm>Client and Menu</realm> <args> <arg name="texFilterType" type="number">The texture filter type, 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 filtes = {} filtes[ TEXFILTER.NONE ] = "NONE" filtes[ TEXFILTER.POINT ] = "POINT" filtes[ TEXFILTER.LINEAR ] = "LINEAR" filtes[ TEXFILTER.ANISOTROPIC ] = "ANISOTROPIC" 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 local filter = math.floor( CurTime() % 4 ) -- 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( filtes[ filter ], "ChatFont", pos + 1, pos + 1, color_white ) draw.SimpleText( filters[ filter ], "ChatFont", pos + 1, pos + 1, color_white ) end ) </code> <output><upload src="70c/8dc3a1e216d7866.gif" size="1659874" name="hl2_eKnL9y0wEk.gif" /></output> <output><image src="70c/8dc3a1e216d7866.gif" size="1659874" name="hl2_eKnL9y0wEk.gif" /></output> </example>