• 3d2d. Why wrong textures drawing in my rendering context?
    3 replies, posted
I can not understand, why screen of tool gun drawn over one of my entity? https://files.facepunch.com/forum/upload/269653/128dcb51-5be6-4e09-83a9-7b2889187172/image.png Code: (Maybe I use a strange way to create new 3d2d. But nonetheless...) function ENT:Initialize() local evidence = { } hook.Add( "PostDrawOpaqueRenderables", tostring(self), function() local dist = self:GetPos():Distance(LocalPlayer():GetPos()) --if dist > 10000 then return end local anim = 0.3 + math.abs(math.sin(CurTime() * 1)) * 0.1 local fade = math.max((150 - dist) / 100, 0) * 255 evidence.Pos = self:LocalToWorld( self:OBBCenter() ) angle = ( evidence.Pos - LocalPlayer():EyePos() ):Angle() angle:RotateAroundAxis( angle:Right(), 90 ) cam.Start3D2D( evidence.Pos, angle, anim ) surface.SetDrawColor( 255, 255, 255, fade ) surface.DrawTexturedRectRotated( 0, 0, 10, 10, -90 ) surface.SetMaterial( material ) cam.End3D2D() end) function self:OnRemove() hook.Remove("PostDrawOpaqueRenderables", tostring(self)) end     end
surface.DrawTexturedRectRotated( 0, 0, 10, 10, -90 ) surface.SetMaterial( material ) >Draw Texture on surface >Set texture for next drawing operations >-Frame ends- >-Irrelevant functions- >Set toolgun texture for next drawing operations >Draw toolgun screen >-your code run once again- You have to set the material/texture BEFORE drawing it
I tried it, but then the surface just assumed the color of 'SetDrawColor'. And after that I can't use 'Set Material'
Just so you know, the wiki explains that surface.SetMaterial "Sets the material to be used in all upcoming draw operations using the surface library."
Sorry, you need to Log In to post a reply to this thread.