Sign in to follow this  
Plasmarobo

Sprites and how to use them

Recommended Posts

Plasmarobo    100
I'm having a bit of an issue with sprites. I can draw quads and texture them fine. The textures work, the quads work (with or without lighting), but for some reason, sprites don't work at all. I have everything setup, but the sprite just doesn't render. No errors messages, and all the functions return true! Are there any render flags, or settings, FVFs, or anything that would make a sprite fail to render? I have used sprites in the past without any problems. I haven't upgraded anything (although I have made heavy changes to my controller classes) I have a wrapper class for sprites, but when that failed, I restorted to simply coding the sprite in my main file. Are sprites compatible with Z-buffering, or are they affected by it (Could I possibly be drawing it behind the camera? I just use a default projection matrix) Anyway, I'll post some specific code just in case there are some glaring errors
 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	Foundation::WinFnd::WinLayer iApp;
	Graphics::DirectX::DirectXLayer Direct3D;
	
	if(!iApp.Start(hInstance, "Core", "Core", 800, 600, nCmdShow))
	{
		iApp.End();
		return 0;
	}

	if(!Direct3D.Aquire())
		iApp.MBox("Aquisition failure");
	if(!Direct3D.CreateDevice_W(iApp.m_hWnd))
		iApp.MBox("Create Device failed");
	
	D3DXVECTOR3 vec;
	vec.x = 20.0f;
	vec.y = 20.0f;
	vec.z = 100.0f;


	ID3DXSprite *sprite;
	D3DXCreateSprite(Direct3D.Device(), &sprite);
	
        LPDIRECT3DTEXTURE9 tex;
	D3DXCreateTextureFromFile(Direct3D.Device(), "s1.png", &tex);
	
        iApp.Update();
	Direct3D.SetClearInfo();
	iApp.Done = false;
	
        while(!iApp.Done)
		{
			iApp.MsgLoop();	
			if(iApp.Active)
			{
				if(iApp.Done)
					break;
				
			Direct3D.Clear();
			Direct3D.StartRender();
			
                        sprite->Begin(NULL);
			sprite->Draw(tex, NULL, NULL, &vec, 0xFFFFFFFF);
			sprite->End();


                        Direct3D.EndRender();
                        Direct3D.Present();
		        }
  
  }


	Direct3D.End();
  iApp.End();
	return 0;
}

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