Jump to content
  • Advertisement
Sign in to follow this  
streamer

Icon drawing

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

Hi all, I have a little "tricky" question. Is there any way to draw windows system icons in directx, assuming that program have handle of the icon? Or any thoughts of how can be this done? I have googled but didn't find nothing useful, so I don't have a clue. Any information will be appreciate. thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
You could draw the icon to a IDirectDrawSurface9 of an IDirect3DTexture9 using the DrawIcon function, and using the HDC from the GetDC() method. So long as the texture is in one of the required GDI formats (See the docs for GetDC() for information).

Share this post


Link to post
Share on other sites
Ok Steve, thank you for the tip, I got it to work


HICON hic = LoadIcon( g_hInstance, MAKEINTRESOURCE(IDI_DIRECTX_ICON));

HDC cdc;

LPDIRECT3DSURFACE9 pIconSurface = NULL;

if(SUCCEEDED(m_pd3dDevice->CreateTexture(32, 32, 1, 0, D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &pTex,0)))
{

if(SUCCEEDED(pTex->GetSurfaceLevel(0, &pIconSurface)))//
{
if(SUCCEEDED(pIconSurface->GetDC(&cdc)))
{
DrawIcon(cdc,0,0,hic);

}
pIconSurface->ReleaseDC(cdc);

}
}
}

SAFE_RELEASE( pIconSurface );






One more question. How can I transparent pixels put to another color, because transparent pixels look black?

[Edited by - streamer on July 11, 2008 1:22:32 PM]

Share this post


Link to post
Share on other sites
Uhh...this is what you're doing here:

-creating an offscreen surface
-drawing an icon to that surface
-creating an unrelated texture
-storing a pointer to the texture's surface in the pointer previously used for the offscreen surface (memory leak)
-storing a pointer to the backbuffer in the pointer previously used for the texture's surface (another memory leak)
-releasing the pointer to the backbuffer

You should be doing this:

-create a regular texture in D3DPOOL_MANAGED, with R8G8B8 format
-get the texture's top-level surface
-Get the DC
-Draw the icon
-Release the DC
-All done!

EDIT: looks like you fixed it. [smile]

Share this post


Link to post
Share on other sites
Yes :)

I noticed that I made a big stupidity [smile] and I rewrited it.

Also I got alpha color key working too, so now it is all fixed, and working.

Thank you all!

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!