• ### Announcements

#### Archived

This topic is now archived and is closed to further replies.

# Initailization problem...help appreciated(D3D)

## Recommended Posts

KenshiX    122
ok I got my vertex defined as... struct my_vertex { FLOAT x, y, z; FLOAT tu, tv; }; then if I make a square and initailize it like this it works fine my_vertex square[4] = { { 1.0f, -1.0f, 0.0f, 1.0f, 1.0f }, //BR { 0.0f, -1.0f, 0.0f, 0.0f, 1.0f }, //BL { 1.0f, 0.0f, 0.0f, 1.0f, 0.0f }, //UR { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f } //UL }; but if I declare square in one line... my_vertex square[4]; then initalize all its veriables after like so... square[0].x = 1.0f; square[0].y = -1.0f; square[0].z = 0.0f; square[0].tu = 1.0f; square[0].tv = 1.0f; //bottom right square[1].x = 0.0f; square[1].y = -1.0f; square[1].z = 0.0f; square[1].tu = 0.0f; square[1].x = 1.0f; //bottom left square[2].x = 1.0f; square[2].y = 0.0f; square[2].z = 0.0f; square[2].tu = 1.0f; square[2].tv = 0.0f; //upper right square[3].x = 0.0f; square[3].y = 0.0f; square[3].z = 0.0f; square[3].tu = 0.0f; square[3].tv = 0.0f; //upper left the DrawPrimitive() function makes a Triangle instead of a square and the texture is all messed up. If anyone could help me it would be great. thanks

##### Share on other sites
DrunkenHyena    805
quote:
Original post by KenshiX
square[1].x = 0.0f;
square[1].y = -1.0f;
square[1].z = 0.0f;
square[1].tu = 0.0f;
square[1].x = 1.0f; //bottom left

G''day!

You have a typo here. That last line should be setting tv.

Stay Casual,

Ken
Drunken Hyena

##### Share on other sites
KenshiX    122
Thanks Drunken I shoulda seen that. Much obliged.
KenshiX (KenshiW) P)

##### Share on other sites
arunvb    147
I have got this problem earlier.

I guess it is the same backface culling problem. DrawPrimitive draws/culls a particular triangle depending upon the orientation its vertices. i.e if DrawPrimitive draws triangle which has vertices v1->v2->v3 as clockwise, it will cull those triangles with vertices anticlockwise. I am not sure which orientation draws and which one culls.

v1
/ \
/ \
v2--- v3

This is a clockwise orientation of the vertices.

BTW, what mode are you using TRIANGLESTRIP or TRIANGLEFAN.

But I am not sure why there should be a difference between intialization while declaring and initialization later.

Arun