SetMaterial

This function sets an entity's material.

Syntax

Parameters

Remarks

This function will increment the reference count of the new material and decrement the reference count of the old material (if they exist).

Example

#include "Leadwerks.h"

using namespace Leadwerks;
Entity* entity = 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();
DirectionalLight::Create()->SetRotation(45, 35, 0);

//Create a material
Material* material = Material::Create();
material->SetColor(1, 0, 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;

Leadwerks::Time::Update();
world->Update();
world->Render();
context->Sync();
}
return 0;
}