SetFilter

Sets the filter 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();

//Load a texture
Texture* texture1 = Texture::Load("Materials/Grass/grass01.tex");
texture1->SetFilter(Texture::Smooth);

//Load a new unique copy of the same texture
Texture* texture2 = Texture::Load("Materials/Grass/grass01.tex", Asset::Unmanaged);
texture2->SetFilter(Texture::Pixel);


while (true)
{
if (window->Closed() || window->KeyDown(Key::Escape)) return false;
context->SetColor(0, 0, 0, 0);
context->Clear();

//Display the textures on screen so we can compare the difference
context->SetColor(1, 1, 1, 0);
context->DrawImage(texture1, 0, 0, 4096, 4096);
context->DrawImage(texture2, 256, 256, 4096, 4096);

context->SetBlendMode(Blend::Alpha);
context->DrawText("Smooth filter (" + String(texture1->GetFilter()) + ")", 0, 0);
context->DrawText("Pixel filter (" + String(texture2->GetFilter()) + ")", 256, 256);
context->SetBlendMode(Blend::Solid);

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