EN | RU
< Back | Index | Next > |
---|---|---|
Not available | Tutorials | 02. Mouse |
In this tutorial we start education by learning to set background color.
Estimated completion time: 5 minutes.
Here's the line of code to set background color to red:
main.application.camera.clearColor = {1, 0, 0}
Note: either paste this code yourself to ogse
, or simply click Run in ogse
.
Let's see into API we used:
main
namespace hostsapplication
instancemain.application
instance hosts subsystems likecamera
,mouse
, etc.main.application.camera
instance is a viewport into application's scenemain.application.camera.clearColor
property is a clearing color (effectively background color) of the camera- accepts array of color components in RGB format
main.application.camera.clearColor = {1, 0, 0}
- returns array of color components in RGB format
local color = main.application.camera.clearColor print("background color:", color[1], color[2], color[3])
- accepts array of color components in RGB format
It was fairly easy to set background color, right? Now let's find out what color is used by default:
local color = main.application.camera.clearColor
print("Default background color:", color[1], color[2], color[3])
Notes:
local
keyword means that declared variable is local to current scope and will be garbage collected upon the scope's exitLua
indexes arrays starting from1
, unlikeC
that does so from0
Have a look at the debug console. You should see the following line:
Default background color: 0.200000 0.200000 0.400000
Thus, default background color is 0.2, 0.2, 0.4
. Why that specific color,
you ask? Because 0.2, 0.2, 0.4
is default background color of
OpenSceneGraph
used by ogs
.
You have successfully set background color to red and then printed default background color.
< Back | Index | Next > |
---|---|---|
Not available | Tutorials | 02. Mouse |