-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix draw.SimpleText not working due to fonts not resolving + try impl…
…ementing min/mag filtering (failing)
- Loading branch information
Showing
28 changed files
with
240 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
game/experiment/scripts/lua/utilities/test/gmod_texture_filters.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--[[ | ||
Source: https://wiki.facepunch.com/gmod/render_min_mag_filters#usageexample | ||
lua_openscript_cl utilities/test/gmod_texture_filters.lua | ||
--]] | ||
|
||
-- 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("silkicons/anchor.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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.