Sign in to follow this  
winston123

mouse drawing above the direct3D

Recommended Posts

I am a newbie, I just complete show a texture on a block, the texture data are changing, so the outcoming 3d graph is ok. But, now i need to use mouse the draw some line or ellipse or any graphics on the surface . is it possible? usually, if without directx, I can easily draw by : CDC *pDC = GetDC(); pDC->MoveTo(x,y); pDC->LineTo(x2,y2); ReleaseDC(pDC); but now with the directx graphics changing constantly, i cannot draw my graphics by mouse above the directx surface. anybody can give me some help? thanks alot winston.

Share this post


Link to post
Share on other sites
On important distinction I couldn't make out in your post is whether you want to draw onto the texture displayed on the block or, instead, want to draw in 2D as an overlay over the 3D scene.

In the first case you will have to reckon with some transforms to unproject the texture or project the scribbles you make using the mouse. You would have to lock the texture and draw into its surface, then release the lock and use it for drawing.

In the second case life is easier. You'd lock the screen buffer after rendering and add the drawings to it or store the drawings on a secondary buffer and blend it over the scene buffer.

Now here is the really good part for you: you can actually obtain a device context on Direct3DSurface's -- that means you can use your knowledge from DC drawing using the Win32 API. After obtaining the top surface from a texture using GetSurfaceLevel() you can call GetDC() to get a device context for drawing.

Greetz,

illco

Share this post


Link to post
Share on other sites
Quote:
Original post by Illco
After obtaining the top surface from a texture using GetSurfaceLevel() you can call GetDC() to get a device context for drawing

But, note that this method is much slower than somehow rendering your lines/etc. from some sort of source texture into a render target using geometry and then blending with the backbuffer via a fullscreen quad.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this