Sprite doesn't work

Started by
5 comments, last by Evil Steve 17 years, 6 months ago
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.
Advertisement
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.
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?
  • But hr == S_OK :(
    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..:(

    Is your Draw call between a BeginScene/EndScene pair with a closing Present call?
    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.

    This topic is closed to new replies.

    Advertisement