Jump to content
  • Advertisement
Sign in to follow this  
brwarner

Dynamic 2D Elements in DirectX

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

How can I draw 2D elements (boxes, circles, rounded boxed, etc.) using DirectX without having premade textures for them. I've seen this implemented in other games for UI and was wondering how without using any of the D3DX libraries.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by brwarner
How can I draw 2D elements (boxes, circles, rounded boxed, etc.) using DirectX without having premade textures for them. I've seen this implemented in other games for UI and was wondering how without using any of the D3DX libraries.
First, why don't you want to use D3DX? It's part of DirectX and the only reason you wouldn't want to use it is if you're doing XBox development or something where D3DX doesn't exist (Although there are alternatives). You might as well not use D3D and write your own device driver or something instead...

What other games have you seen that do this? And what makes you think they don't have premade textures? You don't have to have one texture for every shape; for instance a box is 4 lines.

And D3D itself doesn't have any support for that sort of stuff; it's not GDI. You'll either have to do something weird with GDI to use it to render shapes, or render them yourself using textures or something similar.

Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Steve
It's part of DirectX and the only reason you wouldn't want to use it is if you're doing XBox development or something where D3DX doesn't exist.


Even the original Xbox SDK had it's own version of D3DX. I dunno if the big games made heavy use of it, but it was definitely available.

Quote:
Original post by Evil Steve
And D3D itself doesn't have any support for that sort of stuff; it's not GDI. You'll either have to do something weird with GDI to use it to render shapes, or render them yourself using textures or something similar.


I suppose he could use GDI+ to render 2D primitives, and then make a texture from the DIB and use it as a sprite (like how D3DXFont renderes glyphs). Probably a better idea would be to render quads using a pixel shader that renders the desired primitive according to some relevent parameters. You could do some neat effects that way, too.

Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Steve
First, why don't you want to use D3DX? It's part of DirectX and the only reason you wouldn't want to use it is if you're doing XBox development or something where D3DX doesn't exist (Although there are alternatives). You might as well not use D3D and write your own device driver or something instead...


It's not that I don't use D3DX. I wrote a "wrapper" DLL for DirectX that isolates it from the application and does a lot of initialization behind the scenes so the application has less to do. If I used any part of D3DX it would have to be coded into the engine, which I didn't want to do.

I think I'll go with the pixel shader idea.

Quote:
Original post by Evil Steve
What other games have you seen that do this? And what makes you think they don't have premade textures? You don't have to have one texture for every shape; for instance a box is 4 lines.

Source Engine modding allowed drawing rounded boxes with variable degrees of roundness, I assumed that this was calculated in game unless they drew many many textures (or otherwise deformed one somehow..)

Share this post


Link to post
Share on other sites
I'm trying to go the GDI+ way, to see how it works out and I've learned some tutorials on how to draw things using GDI+ but how do I get the results data so I can use it as a texture?

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!