Let’s say I have a texture which is one file with separate 20 px by 20 px blocks. Within each of these blocks is a new character and I’d like to render different characters on screen as textures using these blocks. How can I use directx to render separate pieces of a texture file?
Share
You will need to render a quad (two triangles) with the UV coordinates mapped to the correct location in this texture for each letter you are rendering.
So if you had a quad like this:
and you wanted to draw the entire texture you would assign the vertices UV coordinates of:
If you wanted to assign the letter at 40,60 with a width and height of 20 and a texture width and height of 200 to this quad then the UV coordinates would be: