Sign in to follow this  
aphelix

Sprite doesn't work

Recommended Posts

Hi! In my Sprite class
bool Sprite::Draw()
{
			if(S_OK != m_pSprite->Begin(D3DXSPRITE_ALPHABLEND))
				return 1;

			if(m_pSprite->Draw(m_Texture,NULL,&D3DXVECTOR3(50.0f, 50.0f, 0.0f),&D3DXVECTOR3(10.0f, 10.0f, 0.0f),0xFFFFFFFF) != S_OK)
				return 1;

			if(S_OK != m_pSprite->End())
				return 1;

				return 0;
}
exists. and i call this function in each loop(m_Texture have been initialized).All seems ok (m_Texture is valid when debugging). But Sprite doesn't work. why? Thanks.

Share this post


Link to post
Share on other sites
Rather than saying "if func() != S_OK", you should try something like:

HRESULT hr;
hr = func();
if (hr != S_OK)
{
Display error message with hr so you can look it up
...
}

That way, you can see the error code and find out which call failed and why.

Share this post


Link to post
Share on other sites
Define "doesn't work". Doesn't render?

Things to check:
  • Firstly, you should be using the SUCCEEDED macro, not testing against S_OK. In fact, it's D3D_OK (Which both just so happen to compile to the same thing). But using SUCCEEDED is the correct way to do it.
  • Are you using the debug runtimes? Any debug output?
  • m_Texture isn't NULL is it?
  • What version of DirectX, and what SDK? E.g. DX9, August 2006 SDK
  • Have you tried passing any other flags to ID3DXSprite::Begin()?
  • What does your texture contain? Does it have an alpha channel?
  • Have you tried passing NULL for the two D3DXVECTOR3 parameters?

    Share this post


    Link to post
    Share on other sites
    Things to check:
    # Firstly, you should be using the SUCCEEDED macro, not testing against S_OK. In fact, it's D3D_OK (Which both just so happen to compile to the same thing). But using SUCCEEDED is the correct way to do it.
    # Are you using the debug runtimes? Any debug output?
    Yes! and all values are OK and valid.
    # m_Texture isn't NULL is it?
    When i debug m_Texture,adress is valid(Not null = 0x0000000).So OK!
    # What version of DirectX, and what SDK? E.g. DX9, August 2006 SDK
    April 2006
    # Have you tried passing any other flags to ID3DXSprite::Begin()?
    No :) i try....But failed :(
    # What does your texture contain? Does it have an alpha channel?
    No. basic crate.jpg
    # Have you tried passing NULL for the two D3DXVECTOR3 parameters?
    Yes...But Sprite doesn't work..:(

    Share this post


    Link to post
    Share on other sites
    Quote:
    Original post by aphelix
    # Are you using the debug runtimes? Any debug output?
    Yes! and all values are OK and valid.
    The debug runtimes are different from the debug build in MSVC. The debug runtimes you select from the control pannel (Control pannel -> DirectX). That should give you output in MSVC's Debug Output window, telling you if anything is wrong.

    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