Jump to content
  • Advertisement

Archived

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

Militia

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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 coordinates


D3DTLVERTEX vertices[4]; // 4 vertices

vertices[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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!