DirectX from GDI+


I'm making an application in which I want to display some waveforms. I know how to do this in GDI+, but thought that because sometimes the GDI+ is slow and because I need to display the waves in realtime, I should use managed DirectX. I don't need to use fancy 3D graphics just 2D with a bit of zoom in and zoom out.

So I've started out drawing my grid. The grid will be an outline of the window with 10 horizontal and vertical lines intersecting the window.

DirectX doesn't make it easy drawing lines and such. I miss the ease of the DrawLine method of the GDI+.

Anyway to draw the grid I'm using a VertexBuffer and some CustomVertex objects in which i define my grid points.Then I use DrawPrimitives i.e PrimitiveType.LineStrip to draw the outline of my grid.

After all that I got a rectangle drawn and some lines intersecting it along the horizontal and vertical.

But how do I change the line thickness? Is there an easier way to go about this? Any suggestions on the overall implementation using DirectX and some general advise on  how to go about it.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hmmm... it's been a while since I've tried to do something at the level you describe.  And DX9 changes things a bit.

I believe DX doesn't support varying line thicknesses (but I don't use lines ever). If you want real control, you can implement lines using stretched quads to have complete control.

Alternate approaches:

It used to be you could create a texture surface and get a GDI DC to the surface, use GDI calls, unlock/release the DC, and then render the texture to the 3D scene.  I'd have to dig deeper into DX9 to see if that's all still available.

If not, at the least you could still use GDI with a compatible pixel format, and lock a texture and memcpy the pixels into the texture.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
auk_ieAuthor Commented:
Took me a while to explore into your suggestions
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Game Programming

From novice to tech pro — start learning today.