SetSortMode
This function sets the material sort mode. Most materials with a blend mode other than Blend::Solid should use sorting to draw surfaces back to front.
Syntax
- void SetSortMode(bool mode)
Parameters
- mode: set this to true to enable sorting, otherwise use false.
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(1, 1, 1, 0.5);
material->SetBlendMode(Blend::Alpha);
material->SetSortMode(true);
//Load and apply a texture
Texture* texture = Texture::Load("Materials/Grass/grass01.tex");
material->SetTexture(texture);
texture->Release();
Model* model = NULL;
model = Model::Box();
model->SetMaterial(material);
model->SetPosition(1.5, 0, 3);
model = Model::Box();
model->SetMaterial(material);
model->SetPosition(1.5, 0, 5);
model = Model::Box();
model->SetMaterial(material);
model->SetPosition(1.5, 0, 7);
while (true)
{
if (window->Closed() || window->KeyDown(Key::Escape)) return false;
Leadwerks::Time::Update();
world->Update();
world->Render();
context->Sync();
}
return 0;
}