Jump to content
  • Advertisement
Sign in to follow this  
metalmidget

why does D3DXSprite render my textures upside down!?!?

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

Here are some snippets of my code:
//texture loading
IDirect3DTexture9* temptex;
D3DXCreateTextureFromFile(gD3DDevice, "Images\\frames.bmp", &temptex);
mTextures.push_back(temptex); //pointer to texture is now stored in a vector

//rendering
//(HR() is a debugging macro that handles return values of HRESULT functions
HR(gD3DDevice->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(255, 255, 255), 1.0f, 0));
HR(gD3DDevice->BeginScene());
	HR(mSprite->Begin(D3DXSPRITE_OBJECTSPACE | D3DXSPRITE_DONOTMODIFY_RENDERSTATE));
		HR(gD3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, true));
		mSprite->Draw(mpResourceManager->GetTexture(TEX_FRAMES), NULL, NULL, NULL, 0xFFFFFFFF);
		mSprite->Draw(/*other stuff*/)
		mSprite->Draw(/*other stuff*/)
		HR(mSprite->Flush()); //stick them all on the buffer
		HR(gD3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, false));
	HR(mSprite->End());
HR(gD3DDevice->EndScene());
HR(gD3DDevice->Present(0, 0, 0, 0));

Everything seems to work fine except that my sprites all come out upside down :( I guess I could just use a transformation matrix to flip everything back the way it should be, but I'd rather know why stuff is coming out upside down in the first place... cheers, metal

Share this post


Link to post
Share on other sites
Advertisement
As a random guess, it probably has something to do with using the D3DXSPRITE_OBJECTSPACE flag on Sprite->Begin() and not setting up any object space -> screen space transforms, nor supplying any object space info in the first place as far as I can tell.

It depends on what you need, but if you just want to render textures to the screen you could try removing this flag and see if it works like you expected.

Share this post


Link to post
Share on other sites
According to a book I have, that flag "means the sprite's coordinates are relative to its own local coordinate system. Omitting this flag means the sprite's coordinates are specified in screen space (ie, in units of pixels with the positive y-axis going down and the positive x-axis going to the right)."
I already tried taking out the flag, but that just makes nothing at all show on the screen. I'll wait for more responses but in the meantime I guess I'll read what the SDK says about the flags for ID3DXSprite::Begin().

cheers,
metal

Share this post


Link to post
Share on other sites
OK, the problem was the D3DXSPRITE_DONOTMODIFY_RENDERSTATE flag. It's gone now and my sprites are the right way up.

cheers,
metal

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!