# Rectangles, Lines, and Dots - Use primitives?

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

## Recommended Posts

Hey there, I'm making a very basic graphics engine (just something that wraps up DirectX), nothing fancy. I was thinking about supporting functions that draw coloured rectangles, lines or dots on the screen. It would appear the best way to do this, is to use primitives. But then a problem arises. What should the z-index be? 0? And then what if there's a 3d scene rendered in 'the background'. If it stretches into the negative z, the rectangle's are 'overrendered'. What do other people suggest? Is there a solution/workaround to this? Or are primitives not the way to go in the first place? Help appreciated, -Stijn

##### Share on other sites
Quote:
 What should the z-index be? 0? .. If it stretches into the negative z,..

What do you mean by "z-index?" The z coordinate of the vertices? The value in the z-buffer?

In any case, it sounds like using primitives is your best starting place.

##### Share on other sites
Check out D3DXLINE for lines.

A z value of 0 is fine if you using untransformed verticies. You could use transformed verticies so objects will appear 2d and right in front of the screen. Transformed verticies are often used for UI.

##### Share on other sites
Quote:
 Original post by HeadkazeCheck out D3DXLINE for lines.A z value of 0 is fine if you using untransformed verticies. You could use transformed verticies so objects will appear 2d and right in front of the screen. Transformed verticies are often used for UI.

I guess you meant either:

Quote:
 A z value of 0 is fine if you using transformed verticies. You could use transformed verticies so objects will appear 2d and right in front of the screen. Transformed verticies are often used for UI.

or
Quote:
 A z value of 0 is fine if you using untransformed verticies. You could use untransformed verticies so objects will appear 2d and right in front of the screen. Untransformed verticies are often used for UI.

...right? I'm a bit confused here :s

So as long as I don't transform the vertices, they won't interfere with 3d rendered stuff? Please elaborate ^_^. Anyway, thanks for pointing me to ID3DXSPRITE. I'll be sure to have a look at that.

- Stijn

##### Share on other sites
I wasn't pointing to the sprite class but to D3DXLINE, but I guess that was just a typo.

As for transformed and untransformed verticies which ones you use depends on what you want to do. You can use transformed verticies so they are forced into screen coordinates or you can used untransformed verticies so you have z coordinate and the graphics can interact with the 3d elements of your application. That just means you use different vertex format's, the transformed one will probably have position, color, rhw, tu and tv. The untransformed vertex format will use position, normal, color, tu and tv.

##### Share on other sites
Quote:
 Original post by HeadkazeI wasn't pointing to the sprite class but to D3DXLINE, but I guess that was just a typo.As for transformed and untransformed verticies which ones you use depends on what you want to do. You can use transformed verticies so they are forced into screen coordinates or you can used untransformed verticies so you have z coordinate and the graphics can interact with the 3d elements of your application. That just means you use different vertex format's, the transformed one will probably have position, color, rhw, tu and tv. The untransformed vertex format will use position, normal, color, tu and tv.

Hehe...Yeah, that was a typo from my side. So transformed vertices can't interact with the 3d scenes? Then I guess I'll have to go with those right? This is indeed for UI type of stuff.

It's been a long time since I've done any 3d stuff with DirectX. I was planning on making this a 2D 'engine', but it seems I'll have to freshen up my 3dknowledge anyway ^^!

##### Share on other sites
If it's for a UI then you probably should go for transformed then

Your vertex format would look something like this

struct CustomVertex{    float x;    float y;    float z;    float rhw;    D3DCOLOR diffuse;    float tu;    float tv;};

##### Share on other sites
Thanks! It seems that's what I'm indeed looking for. Thanks again, mate :)

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 26
• 11
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633704
• Total Posts
3013460
×