Skip to content

Tutorial 2. Textures

Timur Gafarov edited this page Oct 16, 2023 · 11 revisions

Dagon version: >=0.14

You'll definitely want to load some textures and apply them to materials. This is very easy. Add a TextureAsset to your scene:

class TestScene: Scene
{
    TextureAsset aTexGrass;

    // other stuff here...
}

Now load it in beforeLoad:

override void beforeLoad()
{    
    // other stuff here...
    aTexGrass = addTextureAsset("data/grass.png");
}

Create a material and apply the texture:

auto matGround = addMaterial();
matGround.baseColorTexture = aTexGrass.texture;

Now you can apply matGround to our plane object from previous tutorial:

ePlane.material = matGround;

And the result should be this:

Browse source code for this tutorial