Jump to content
  • Advertisement
Sign in to follow this  
sansured

UI Sprite

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

I am trying to open a sprite in UI.

// in init function


g_SampleUI.SetCallback( OnGUIEvent ); int iY = 5;
g_SampleUI.AddButton( IDC_BUTTN, L"Button", 400, iY, 70, 22 );
    

int nSprite = g_DialogResourceManager.AddTexture(L"Masa.jpg");
CDXUTElement element;
RECT r;
SetRect(&r, 0, 0, 200, 200);
element.SetTexture(nSprite, &r);
g_SampleUI.DrawSprite(&element,&r);


IDC_BUTTN is working well but i can't see the sprinte in the window.Where am i doing wrong ? Do you have any idea about it ?

Share this post


Link to post
Share on other sites
Advertisement
debug step by step, and you'll notive that if the alpha of the element's texture color is 0, the sprite is not rendered.

so

element.TextureColor.Current.a = 1.0f
element.TextureColor.Current.r = 1.0f
...

should help.

Share this post


Link to post
Share on other sites
Oh, I didn't fully understand what you wrote.

It won't work because the sprite starts on the beginning of the Render method of the CDXUTDialog, and ends at the end of the same method.

So when you call CDXUTDialog::DrawSprite from anywhere but inside the Render method of the dialog, it's not inside the ID3DXSprite::Begin / ID3DXSprite::end pair, and it won't draw (turning DirectX runtime to Debug would show a waring / error in the Visual output)

If you want to add a sprite, one solution that I would recommend is to create a new control. You can take the CDXUTStatic class as an example. Duplicate it, change its name, get rid of all the stuff you don't need, and add the AddSprite(), GetSprite(), etc. method to the CDXUTDialog.

And then, in the CDXUTSprite::Render() method, you will be able to draw a sprite with "m_pDialog->DrawSprite(...);"

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!