Skip to content

Instantly share code, notes, and snippets.

@thelastpenguin
Created December 5, 2015 21:23
Show Gist options
  • Save thelastpenguin/c0375f62bf73bace49f5 to your computer and use it in GitHub Desktop.
Save thelastpenguin/c0375f62bf73bace49f5 to your computer and use it in GitHub Desktop.
Example of a working gmod render target
local texture = GetRenderTarget('uniquert'..os.time(), 512, 100, false)
local mat = CreateMaterial("uniquemat"..os.time(),"UnlitGeneric",{
['$basetexture'] = texture,
});
hook.Add('HUDPaint', 'sao', function()
local scrw, scrh = ScrW(), ScrH()
-- this is a perfect render target dealio.
render.PushRenderTarget(texture)
cam.Start2D()
render.OverrideAlphaWriteEnable(true, true)
cam.End2D()
render.PopRenderTarget()
mat:SetTexture('$basetexture', texture)
surface.SetDrawColor(255,255,255)
surface.SetMaterial(mat)
surface.DrawTexturedRect(0, 0, 512 , 100)
end)
@chloelcdev
Copy link

I don't understand how to use this. Where are you giving it any origin or angle with which to use the RT?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment