Revision Difference
render.PushFilterMag#561105
<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>Anisotropic Filtering (This is not antialiasing)</description>
<description>Showcases the difference between different filtering modes.</description>
<code>
render.PushFilterMag( TEXFILTER.ANISOTROPIC )⤶
render.PushFilterMin( TEXFILTER.ANISOTROPIC )⤶
⤶
-- Render stuff here⤶
⤶
render.PopFilterMag()⤶
render.PopFilterMin()⤶
-- 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"⤶
⤶
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 )⤶
⤶
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 )⤶
⤶
end )⤶
</code>
<output><upload src="70c/8dc3a1e216d7866.gif" size="1659874" name="hl2_eKnL9y0wEk.gif" /></output>⤶
</example>