GetColor
This functions gets the material color.
Syntax
- Vec4 GetColor(int mode=Draw::DiffuseColor)
Parameters
- mode: the color to get. This can be Draw::DiffuseColor or Draw::SpecularColor.
Returns
Returns the material color.
Example
#include "Leadwerks.h"
using namespace Leadwerks;
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();
Light* light = DirectionalLight::Create();
light->SetRotation(45, 35, 0);
//Create a material
Material* material = Material::Create();
material->SetColor(0.33, 0.66, 0);
//Create a model and apply the material to it
Model* model = Model::Sphere();
model->SetPosition(0, 0, 2);
model->SetMaterial(material);
while (true)
{
if (window->Closed() || window->KeyDown(Key::Escape)) return false;
Vec4 color = material->GetColor();
//Modify and apply the color
color.r = Math::Mod(color.r + Leadwerks::Time::GetSpeed()*0.01, 1);
color.g = Math::Mod(color.g + Leadwerks::Time::GetSpeed()*0.015, 1);
color.b = Math::Mod(color.b + Leadwerks::Time::GetSpeed()*0.025, 1);
material->SetColor(color);
Leadwerks::Time::Update();
world->Update();
world->Render();
context->Sync();
}
return 0;
}