Direct3D question...

Started by
2 comments, last by new_man 22 years, 1 month ago
Can I assign not whole texture, but only some square part of it to a Direct3D Primitive (e.g. TRIANGLE_STRIP)? If so - tell give me an advice how to do it better.. I''ve tried to load a bitmap from a file to an array, and then copy only part of this array, but this doen''t seem to work - my application fails... so what should I do? Anyway thanks a lot to everyone!
Advertisement
Try looking at some of the tutorials in ''Articles & Resources'', they will have what you want.

,Jay
Keep the original whole texture, but change the u,v texture co-ords in the vertices of the primitive. The scale is from 0 to 1 ie. for a 256x256 texture, a u,v co-ordinate of 0.5,0.5 means 128,128 on the texture.

Hope you figure it out,
Frank
Yes, you can. There are two ways.

1.

Load the entire texture as if you were going to use the whole thing on the primitive. Then, instead of assigning 0.0fs and 1.0fs to the UV coordinates, use the UV coordinates that specify the rectanglular area of the texture that you want to use.

If you go this route, you usually can''t tile the texture unless your primitive''s vertices are set up to match the size of the texture''s rectangle.

2.

Load a bitmap and blit only the rectangle that you want to the D3D texture. It''s slightly more difficult to blit only a portion of a bitmap because you will need to get all of your offsets for both the source and destination surfaces just right. If any of them are off, you''ll probably crash. It''s certainly possible, and not very difficult to do, so if this is where your program is crashing, just look at it some more.

If you use this method, you can wrap the texture, and use 0.0 and 1.0 for the UV coordinates.

This topic is closed to new replies.

Advertisement