Advertisement Jump to content
Sign in to follow this  

Multitexturing in d3d 9

This topic is 4986 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I try to get multitexturing working in my D3D 9 application (C#) and searched the web for good examples how to do that, but found nothing, so here is my question: I guess I have to define a new VertexFormat, because I need 2 sets of texture coordinates and CustomVertex doesn't provide it. Am I wrong here already? If not, how do I do that? Thanks, Constantin

Share this post

Link to post
Share on other sites
Basically, you need to do something like this:

1) Define a vertex format with more than one texture coordinate sets. Alternatively, you can make various texture stages use coordinate sets for other stages. For example, you can have 3 textures and make them all use only one set using something like:
device.SetTextureStageState(1, TextureStageStates.TextureCoordinateIndex, 0);

Makes the second texture - the one in stage 1, the second stage - use the texture coordinate set of index 0. You can have up to 8 texture coordinate sets per-vertex.

2) You need to call SetStreamSource with your buffer:
device.SetStreamSource(0, buffer, stride);

where stride is the size of your vertex.

3) Set the vertex format:
device.VertexFormat = VertexFormats.Position | VertexFormats.Texture2;

4) Adjust the texture stage states and sampler states to do what you want to do, using Device.SetTextureStageState and Device.SetSamplerStageState

5) Use Device.DrawPrimitives

I might've messed up some typenames, as well as forgotten a couple of steps. Truth is the managed docs aren't that good yet [smile]

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!