Jump to content
  • Advertisement
Sign in to follow this  
Plasmarobo

Sprites and how to use them

This topic is 4060 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'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
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!