SetAmbientLight
This function sets a world's ambient light level. This is the minimum light level a surface will be rendered with when no other lights are present.
Syntax
- void SetAmbientLight(float l)
- void SetAmbientLight(float r, float g, float b )
- void SetAmbientLight(float r, float g, float b, float a)
Parameters
- i: a uniform light level that will be used for all channels.
- r: red light level.
- g: green light level.
- b: blue light level.
- a: alpha light level (unused).
Example
#include "Leadwerks.h"
using namespace Leadwerks;
Model* model = NULL;
int main(int argc, const char *argv[])
{
Leadwerks::Window* window = Leadwerks::Window::Create();
Context* context = Context::Create(window);
World* world = World::Create();
Camera* camera = Camera::Create();
camera->Turn(35,0,0);
camera->Move(0,0,-3);
//Create a directional light with an orange tint
Light* light = DirectionalLight::Create();
light->SetRotation(35,45,0);
light->SetColor(1.5,1.3,0.6);
//Set the ambient light level to dark blue
world->SetAmbientLight(0.08,0.08,0.18);
//Create a model
model = Model::Box();
while (true)
{
if (window->Closed() || window->KeyDown(Key::Escape)) return false;
model->Turn(0,Leadwerks::Time::GetSpeed(),0);
Leadwerks::Time::Update();
world->Update();
world->Render();
context->Sync(false);
}
return 0;
}