Ask Your Question
3

When scaling a mesh in Monogame, how can the texture be repeated?

asked 2023-05-03 19:50:07 +0000

lakamha gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-05-03 20:00:01 +0000

bukephalos gravatar image

To repeat a texture when scaling a mesh in Monogame, you can modify the Texture Address Mode property in the SamplerState object. Specifically, you can set the Wrap property to TextureAddressMode.Wrap for both the U and V coordinates.

Here's an example code snippet:

GraphicsDevice.SamplerStates[0] = new SamplerState
{
    Filter = TextureFilter.Linear,
    AddressU = TextureAddressMode.Wrap,
    AddressV = TextureAddressMode.Wrap
};

// Draw your mesh here...

This will repeat the texture along both the U and V axes when scaling the mesh. Note that this will only work if your original texture has non-zero dimensions in both U and V axes.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-05-03 19:50:07 +0000

Seen: 12 times

Last updated: May 03 '23