The thing to keep in mind with texture mapping is that the uv coords of your vertices are completely independant of the actual position of the vertices in space. The uv coords are only used to determine what part of a texture appears on the triangle, regardless of where the triangle is located or how big it is.
Now, to actual code. Forget that loop, it is not helping you. It was only useful when you were assigning the same uv coords to each vertex, but since that is not what you want to do, you should abandon it and assign the coords by hand, like you did with the physical coords. For a single triangle, try something like this:
CUSTOMVERTEX g_Vertices[] = { { 0.5f, 0.0f, 0.0f, 0xff000fff, }, { 0.0f, 1.0f, 0.0, 0xff000fff, }, { -0.5f, 0.0f, 0.0f, 0xff0fffff, } };#ifndef TEXTUREg_Vertices[0].tu = 0.0f;g_Vertices[0].tv = 0.0f;g_Vertices[1].tu = 0.0f;g_Vertices[1].tv = 1.0f;g_Vertices[2].tu = 1.0f;g_Vertices[2].tv = 1.0f;#endif
Now, if you were using a texture like the smiley face in nik02''s post, your triangle will be covered by the bottom left half of the texture, showing most of the mouth and a little of the left eye. It will look a bit skewed, since the actual shape of the triangle does not exactly match the right-triangle traced by the uv coords. Once you have that working, play around with the shape of the triangle, and with the uv coords, and you will soon get the idea of how it works.
By the way, when posting code snippets, put them within "code" or "source" tags, which will prevent the strange formatting you''ve been getting in your posts, and make it more readable for the rest of us. Precede the code snippet with the word "code" or "source" inside square brackets, and finish it with the same word preceded by a forward slash, also inside square brackets. Code tags merely preserve your formatting, source tags create that nice little scrollable text box.