SetTexture

This function sets the material texture. If the texture is not NULL, this function will increment the texture reference count. If the previously set texture is not NULL, this function will decrement the previously set texture's reference count.

Syntax

Parameters

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();

//Load and apply a texture
Texture* texture = Texture::Load("Materials/Grass/grass01.tex");
material->SetTexture(texture);
texture->Release();

//Load and apply a shader
Shader* shader = Shader::Load("Shaders/Drawing/blitcolor.shader");
material->SetShader(shader);
shader->Release();

//Create a model and apply the material
Model* model = Model::Sphere();
model->SetMaterial(material);
model->SetPosition(0, 0, 2);

while (true)
{
if (window->Closed() || window->KeyDown(Key::Escape)) return false;
Leadwerks::Time::Update();
world->Update();
world->Render();
context->Sync();
}
return 0;
}