#### Archived

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

# D3D, vertices, triangles, oh my

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

## Recommended Posts

Alright, in the end all I''m trying to do is create some vertices and make a 2d square (we dont need no stinking z plane) and apply a texture to it. So far all I can do is create a triangle and apply a texture to it. I can''t get anything other then DrawPrimitive(D3DPT_TRIANGLELIST, etc to work, and that of course, makes these god damn trangles. Anyone have any ideas? It looks like the other constants is what I need to use but all I ever manage to do is crash the app. All I wanna do is create 4 vertices and have it make a frickin square. Quick, someone call me on the clue phone. - Militia

##### Share on other sites
create 2 triangles ?!?! that makes up a rectangle ?!?
:|

##### Share on other sites
Yes, 2 triangles make a square, no I don''t want to do that if theres a better way. From what I''ve seen in the docs it would appear there is, I just can''t get it to work.

##### Share on other sites
Trust us, make 2 triangles that look like a square.
You still only need 4 verticies, because the triangles can share verticies if you use something like a "triangle strip".

Just because the church was wrong doesn''t mean Galileo wasn''t a heretic.
It just means he was a heretic who was right.

##### Share on other sites
As Atavist said, if you use a Triangle Strip instead of a Triangle List you can save on vertices since they will be shared among the 2 triangles.
This will draw a square: (DX7 code -> D3DTLVERTEX)

  // Remember btw that these are transformed vertices, so X and Y are in screen coordinatesD3DTLVERTEX vertices[4]; // 4 verticesvertices[0]=D3DTLVERTEX(D3DVECTOR(100,100,0.0),1.0,RGBA_MAKE(255,255,255,255),0,0,0);vertices[1]=D3DTLVERTEX(D3DVECTOR(200,100,0.0),1.0,RGBA_MAKE(255,255,255,255),0,1,0);vertices[2]=D3DTLVERTEX(D3DVECTOR(100,200,0.0),1.0,RGBA_MAKE(255,255,255,255),0,0,1);vertices[3]=D3DTLVERTEX(D3DVECTOR(200,200,0.0),1.0,RGBA_MAKE(255,255,255,255),0,1,1);

The square will be drawn from [100,100] to [200,200].

- Goblineye Entertainment
The road to success is always under construction

##### Share on other sites
There is a better way, I believe, in Dx8. Using high-order primitives, you can render with a quad, but this needs a VERY good graphics card. Else just use OGL, because I _think_ it supports quads.

Else, just use a tri strip, it''s the best there is

-TF

##### Share on other sites
Ya, I tried the triangle strip/etc but I could never get it to display anything. Anyone have any compilable cheeze code laying around that demonstrates this?

##### Share on other sites
G''day!

http://www.drunkenhyena.com/docs/d3d_tutorial.phtml

Lesson 2a renders a triangle as a TRIANGLELIST & a square as a TRIANGLESTRIP.

Stay Casual,

Ken
Drunken Hyena

1. 1
2. 2
3. 3
Rutin
18
4. 4
5. 5
JoeJ
13

• 14
• 10
• 23
• 9
• 50
• ### Forum Statistics

• Total Topics
632639
• Total Posts
3007592
• ### Who's Online (See full list)

There are no registered users currently online

×