Jump to content

Why my HUD is shown in ingame screen


Core
 Share

Recommended Posts

I downloaded XBOCT's Monitor from workshop. I got it working, but I wonder why it shows my HUD elements in the upper left corner of the "virtual" screen? What am I missing?

20170922184436_1.jpg

 

Edit. Added code from the monitor

---------------------------------------------------------------------------
-- Film Grain (Monitor) by Igor Katrich 28/02/20015
-- Email: igorbgz@outlook.com
---------------------------------------------------------------------------
Script.camera=""--entity "Camera"
Script.border_radius=2.0--float "Border Radius"
Script.inflate_rect=50.0--float "Inflate Rect"

function Script:Start()
	--Material
	self.material = Material:Load("Materials/Monitor/monitor.mat")
	self.entity:SetMaterial(self.material)
	--Context
	self.context = Context:GetCurrent()
	--Media
	self.defaultfont = self.context:GetFont()
	self.recellipse = Texture:Load("Materials/Monitor/Media/ellipse.tex")
	self.recblend = 0.0
	self.digitalfont = Font:Load("Materials/Monitor/Media/digital.ttf",30)
	self.context:SetFont(self.digitalfont)
	self.digitalfont:Release()
	--Buffer
    self.buffer = Buffer:Create(128,128,1,0);
    local color = Texture:Create(context:GetWidth(),context:GetHeight())
    self.buffer:SetColorTexture(color)
    self.buffer:Disable();
end

function Script:UpdateWorld()
    self.buffer:Enable()
	self.camera:Show()
    --world:Render()
	self.camera:Hide()
    self.buffer:Disable()

	self.context:SetBlendMode(Blend.Alpha)
	--Border
	self.context:SetColor(1,1,1,0.2)
	self.context:DrawRect(self.inflate_rect,self.inflate_rect,self.border_radius,self.context:GetHeight()-self.inflate_rect*2.0)
	self.context:DrawRect(self.context:GetWidth()-self.inflate_rect-self.border_radius,self.inflate_rect,self.border_radius,self.context:GetHeight()-self.inflate_rect*2.0)
	self.context:DrawRect(self.inflate_rect+self.border_radius,self.inflate_rect,self.context:GetWidth()-(self.inflate_rect*2.0)-self.border_radius*2.0,self.border_radius)
	self.context:DrawRect(self.inflate_rect+self.border_radius,self.context:GetHeight()-self.inflate_rect-self.border_radius,self.context:GetWidth()-(self.inflate_rect*2.0)-self.border_radius*2.0,self.border_radius)
	--Rec
	self.recblend = Math:Sin(Time:GetCurrent()*.4)-0.2
	self.context:SetColor(1,1,1,self.recblend)
	self.context:DrawImage(self.recellipse,self.context:GetWidth()-26-48-self.inflate_rect-self.border_radius-10,self.inflate_rect+self.border_radius+10,26,26)
	self.context:SetColor(1,1,1,0.5)
	--Text
	self.context:DrawText("REC",self.context:GetWidth()-45-self.inflate_rect-self.border_radius-10,self.inflate_rect+self.border_radius+10+1)
	self.context:DrawText(self.camera:GetKeyValue("name"),self.inflate_rect+self.border_radius+10,self.context:GetHeight()-self.inflate_rect-self.border_radius-10-25)
	self.context:SetBlendMode(Blend.Solid)
	
    Context:SetCurrent(context)
	
    local color = self.buffer:GetColorTexture()
    self.material:SetTexture(color,0)
end

function Script:Cleanup()
	self.digitalfont:Release()	
	self.defaultfont:Release()
end

I also have another question. If I want to show text, graphics etc on the wall, I just remove world:render() from the monitor script and use it to draw text etc.? What I mean to ask, is this the "right" way, or is there a better way to show text and graphics on wall, like a screen or maybe even a poster, sign etc.

Edited by Core
added question
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...