Jump to content
  • Advertisement
Sign in to follow this  
tokaplan

Special primitive types

This topic is 4850 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

Rendering with DrawPrimitive or DrawPrimitiveUP I can specify one of D3DPRIMITIVETYPE values - such as D3DPT_POINTLIST or D3DPT_TRIANGLESTRIP. Is there any way of specifying my own custom primitives - for example rendering every four vertices as isolated triangle strip?

Share this post


Link to post
Share on other sites
Advertisement
Hi there tokaplan,
How are you doing?

[The problem]
Specifying your own primitive types?

[The solution]
Tokaplan, as far as that goes. You don't need to.
The six primitive types given to you are all you need to create any primitive.
Let's say you want to draw a quad(Square)
You define it as the following...

[source lang = c++]
//Creation

struct VERTEX
{
float x, y, z,
u, v;
enum
{
FVF = D3DFVF_XYZ | D3DFVF_TEX1
};
};
VERTEX data[] = {
{-1.0f,-1.0f, 0.0, 0.0f, 1.0f},
{-1.0f, 1.0f, 0.0, 0.0f, 0.0f},
{ 1.0f,-1.0f, 0.0, 1.0f, 1.0f},
{ 1.0f, 1.0f, 0.0, 1.0f, 0.0f}};

//rendering
pDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);



This is the code for a simple quad.

I hope this helps a bit.
Keep cool

Share this post


Link to post
Share on other sites
D3D also provides a system called Higher Order Primitives. I have not worked with it myself, but it provides support for various sorts of patches in hardware. Although it doesn't sound like these are what you're looking for.

The thing you described can be done by stitching triangle strips via degenerate triangles. Basically, these are triangles where two vertices are the same, so that the triangle has no actual surface area. This article discusses attaching triangle strips together in some detail.

Another option is to use triangle lists. Indexed triangle lists that are oredered as if they were made of strips are the most optimal geometry format these days, and highly recommended.

[Edited by - Promit on August 7, 2005 1:06:48 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!