Sign in to follow this  

it's killing me. how to use mouse to draw curves above a directX windows

Recommended Posts

hi, I have tried some time already, just can't get it done. I have render a 2D graphcs with direct3d graphics, it's a coordinating transformed 2d graphic.(3d -> 2d). since it's done with directx, the Present(...) make the front surface and the back one flip constantly. but the rendering ok and stable. now I want to draw some curves with mouse above the directX, basically, i think i can render another transparent surface to cover the whole screen.(plain 2d surface), then using mouse to draw. so i use
g_pd3dDevice->SetStreamSource(0,g_pVB2, 0, sizeof(SQUARE_CUSTOMVERTEX)); g_pd3dDevice->SetFVF(D3DFVF_SQUAREVERTEX); g_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP,0, 2);
to draw another texture (surface). but it's not transparent, so it totally opaqually cover the original 2d graphics. which is not what I want. so my idea is not right? then how can I draw a graphic on the screen? (not above the original 2d texture).. I really need to harry up my project. it's killing me. please give me some idea. somebody say, it's very simple, but I am just get my hands on this directX thing. i don't know how to do it.. thank you .

Share this post

Link to post
Share on other sites
Mostly because you haven't given enough information.

One possible method is to, once you've rendered the rest of your scene, render the curves with the depth test off and blending enabled. If your curves are not transparent, you probably have not enabled blending properly. Consult the documentation.

Share this post

Link to post
Share on other sites
What is your approach right now? What do you mean by drawing curves with the mouse? Are you already rendering curves to the second texture? When you create the second texture or erase it, you need to set all of its alpha values to 0. Then call the following to throw out the 0 alpha values:

d3dDevice->SetRenderState(D3DRS_ALPHATESTENABLE, true);
d3dDevice->SetRenderState(D3DRS_ALPHAREF, 0);
d3dDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_NOTEQUAL);
// The MSDN documentation isn't completely clear on how the test passes
// with alpha testing, but I believe this is the correct setup. I usually
// get it backward though, so if this doesn't work, then try D3DCMP_EQUAL.

This will test the alpha value in the texture that is being applied to the quad and fail any with alpha of 0, leaving the pixel alone. Make sure that you render non-zero alpha curves to the texture.


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