Original Post
Hello, I'm converting my C# Managed DirectX 2D game to C++ DirectX (DirectX 9.0c) and I've run into some problems with sprites. I just want to load a "texture" and render it to the scene. I'm not going to use any 3D anywhere in this game, so I guess/hope I can use screen coordinates and don't have to set up a camera? This works in my C# project. My C++ code compiles but doesn't render anything, I only see the "clear color". What do I have to do to make this work? I've tried alot of the suggestions found in other posts about this problem but I can't seem to find the right solution for me. Or I'm just doing that wrong too =) I hope there's nothing special about the image-format? I saved it as a 24 bits/pixel targa. Thanks in advance, Mattias [Edited by - rms on November 19, 2004 1:19:16 PM]
//Initialization
Sprite sprite;
Texture spriteTexture;
Rectangle textureSize;
spriteTexture = TextureLoader.FromFile(device, "sprite.tga");
Surface s = spriteTexture.GetSurfaceLevel(0);
SurfaceDescription sd = s.Description;
textureSize = new Rectangle(0, 0, sd.Width, sd.Height);
sprite = new Sprite(device);
//Rendering
sprite.Begin(SpriteFlags.AlphaBlend);
sprite.Draw(spriteTexture, textureSize, new Vector3(0.0f, 0.0f, 0.0f), new Vector3(100.0f, 150.0f, 1.0f), Color.White);
sprite.End();
//Initialization
ID3DXSprite* sprite = NULL;
IDirect3DTexture9* spriteTexture = NULL;
D3DXCreateTextureFromFile(shared.g_device, "sprite.tga", &spriteTexture);
RECT textureSize = {0, 0, 256, 256};
D3DXCreateSprite(shared.g_device, &sprite);
//Rendering
sprite->Begin(D3DXSPRITE_ALPHABLEND);
sprite->Draw(spriteTexture, &textureSize, &D3DXVECTOR3(0.0f, 0.0f, 0.0f), &D3DXVECTOR3(100.0f, 150.0f, 1.0f), 0xFFFFFFFF);
sprite->End();