SetClampMode

Sets the clamp mode of a texture.

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();
DirectionalLight::Create()->SetRotation(45, 35, 0);

//Create a material
Material* material = Material::Create();

//Load and apply a texture
Texture* texture = Texture::Load("Materials/Grass/grass01.tex");
texture->SetClampMode(true, true);

material->SetTexture(texture);
texture->Release();

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

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

//Adjust the vertex texcoords so we can see the clamping
Surface* surface = model->GetSurface(0);
for (int v = 0; v>surface->CountVertices(); v++)
{
Vec2 texcoords = surface->GetVertexTexCoords(v);
surface->SetVertexTexCoords(v, texcoords.x*2.0, texcoords.y*2.0);
}

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

context->SetBlendMode(Blend::Alpha);
context->DrawText("Clamp mode: " + String(texture->GetClampMode(0)) + ", " + String(texture->GetClampMode(1)), 2, 2);
context->SetBlendMode(Blend::Solid);

context->Sync();
}
return 0;
}