I'm making a custom entity and I'm trying to draw a texture on it using cam.Start2D and rendertargets.
I have looked at the toolgun and at wire text screens, but I [b]still[/b] can't get it to work.
this is in the cl_init.lua of the entity:
[lua]local RenderTarget = GetRenderTarget("FAdmin_MOTD", 128, 128, true)
local gripTexture = surface.GetTextureID( "sprites/grip" )
function ENT:Draw()
self.Entity:DrawModel()
local posX, posY = self:LocalToWorld(Vector(1.8079, -0.6743, -62.3193)):ToScreen() -- Not used
local OldRT = render.GetRenderTarget()
render.SetRenderTarget(RenderTarget)
render.SetViewPort(0, 0, 512, 512)
cam.Start2D()
surface.SetDrawColor(255, 255, 255, 255)
surface.SetTexture(gripTexture)
surface.DrawTexturedRect(0, 0, 512, 512)
cam.End2D()
//render.SetViewPort(0, 0, ScrW(), ScrH())
render.SetRenderTarget(OldRT)
end[/lua]
settings/render_targets/FAdmin_MOTD.txt:
[code]"FAdmin_MOTD"
{
"Name" "FAdmin_MOTD"
"Width" "512"
"Height" "512"
}[/code]
I see a rendertarget on the top left of my screen, showing parts of the maps and props. My screen is mucked up too, I don't see any props/objects on my screen.
So looking at other people's code didn't work...
[highlight] Nevermind, I'm now using 2D3D which is better.[/highlight]
Sorry, you need to Log In to post a reply to this thread.