• RenderView does not seem to work?
    2 replies, posted
Hey I was trying to create something like the RT Camera in the sandbox pretty much just render another view and put it on a TV. Sadly the view keeps rendering on my entire screen, any ideas? [lua] local rtMaterial = Material("RTMaterial") local customRT = GetRenderTarget("RTTexture",512,512) function ENT:Draw() self:DrawModel() local w, h = 935, 554 local ang = self:GetAngles() local pos = self:GetPos() + ang:Up() * 36 + ang:Right() * 28 + ang:Forward() * 6.9 ang:RotateAroundAxis( ang:Up(), 90 ) ang:RotateAroundAxis( ang:Forward(), 90 ) local CamData = {} CamData.angles = Angle(0, 0, 0) CamData.origin = self:GetPos(); CamData.x = 0 CamData.y = 0 CamData.w = w CamData.h = h local OldRT = render.GetRenderTarget() rtMaterial:SetTexture( "$basetexture", customRT ) render.SetRenderTarget(customRT) render.ClearDepth() render.RenderView( CamData ) render.SetRenderTarget( OldRT ) cam.Start3D2D(pos, ang, 0.06) surface.SetDrawColor(255,255,255,100) surface.SetMaterial(rtMaterial) surface.DrawTexturedRect(0, 0,w,h) cam.End3D2D() end [/lua]
[QUOTE=Crapy;42390260]Hey I was trying to create something like the RT Camera in the sandbox pretty much just render another view and put it on a TV. Sadly the view keeps rendering on my entire screen, any ideas? [lua] local rtMaterial = Material("RTMaterial") local customRT = GetRenderTarget("RTTexture",512,512) function ENT:Draw() self:DrawModel() local CamData = {} CamData.angles = Angle(0, 0, 0) CamData.origin = self:GetPos(); CamData.x = 0 CamData.y = 0 CamData.w = w CamData.h = h local OldRT = render.GetRenderTarget() rtMaterial:SetTexture( "$basetexture", customRT ) render.SetRenderTarget(customRT) render.ClearDepth() render.RenderView( CamData ) render.SetRenderTarget( OldRT ) cam.Start3D2D(pos, ang, 0.06) surface.SetDrawColor(255,255,255,100) surface.SetMaterial(rtMaterial) surface.DrawTexturedRect(0, 0, CamData.w, CamData.h) cam.End3D2D() end [/lua][/QUOTE] One thing that stands out is you are calling [lua]cam.Start3D2D(pos, ang, 0.06)[/lua] but [B]pos [/B]and [B]ang [/B]are not defined in the code you pasted.
[QUOTE=wh1t3rabbit;42390316]One thing that stands out is you are calling cam.Start3D2D(pos, ang, 0.06) but [B]pos [/B]and [B]ang [/B]are not defined in the code you pasted.[/QUOTE] I have cleaned the code for you guys so you only focus on what the real problem is, some parts are missing indeed but they are in my code. EDIT: I have edited the code so you will have the full one.
Sorry, you need to Log In to post a reply to this thread.