Jump to content
Leadwerks Community

setClearColor Camera?


Go to solution Solved by GorzenDev,

Recommended Posts

Posted
self.entity:SetClearColor(12, 183, 242, 1 )  -- Color white. Error. Color Sky Blue not render.
self.entity:SetClearColor(255, 0, 0, 1 ) -- Ok, Color Red.

I'm trying to set the background color of the camera, but it doesn't work, what am I doing wrong?

Mars.jpg.89ab63a64eebc1f5ada0ab82b66a1f8c.jpg

 

 

  • Solution
Posted

make sure your entity is actually a camera.

tolua.cast(self.entity,"Camera")

as gamecreator said color in code always use normalized values 0-1
if thats a problem you can always do sometihng like

self.entity:SetClearColor(12 / 255, 183 / 255, 242 / 255, 1.0)
self.entity:SetClearColor(255 / 255, 0.0, 0.0, 1.0)

 

  • Thanks 1
Posted

You can create a simple function which helps you to convert 0-255 to 0-1

function rgba(r,g,b,a) --red green blue alpha, it is like CSS
	local rgba_value = Vec4(r/255,g/255,b/255,a)
	return rgba_value
end

--make this function global then you can use entity:SetColor(rgba(142,36,64,0.8))

 

 

  • Upvote 1

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.

×
×
  • Create New...