Rectangles, Lines, and Dots - Use primitives?

Started by
6 comments, last by stenny 15 years, 9 months ago
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
What do I expect? A young man's quest to defeat an evil sorceror while discovering the truth of his origins. A plucky youngster attended by her brutish guardian. A powerful artifact which has been broken into a small number of artifactlets distributed around the world.What do I want? Fewer damn cliches. - Sneftel
Advertisement
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.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

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.
Quote:Original post by Headkaze
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.


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
What do I expect? A young man's quest to defeat an evil sorceror while discovering the truth of his origins. A plucky youngster attended by her brutish guardian. A powerful artifact which has been broken into a small number of artifactlets distributed around the world.What do I want? Fewer damn cliches. - Sneftel
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.
Quote:Original post by Headkaze
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.


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 ^^!
What do I expect? A young man's quest to defeat an evil sorceror while discovering the truth of his origins. A plucky youngster attended by her brutish guardian. A powerful artifact which has been broken into a small number of artifactlets distributed around the world.What do I want? Fewer damn cliches. - Sneftel
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;};
Thanks! It seems that's what I'm indeed looking for. Thanks again, mate :)
What do I expect? A young man's quest to defeat an evil sorceror while discovering the truth of his origins. A plucky youngster attended by her brutish guardian. A powerful artifact which has been broken into a small number of artifactlets distributed around the world.What do I want? Fewer damn cliches. - Sneftel

This topic is closed to new replies.

Advertisement