Problem with D3DXSprite::Draw()

Started by
2 comments, last by Alload 22 years, 9 months ago
I tried to draw a bitmap file onto a window by using the D3DX librairy. But nothing is drawn. Could anyone tell me what''s wrong with my code? LPDIRECT3D8 lpD3D = NULL; LPDIRECT3DDEVICE8 lpDevice = NULL; LPDIRECT3DTEXTURE8 lpTexture = NULL; LPD3DXSPRITE lpSprite = NULL; /////////////////////////////////////////////////////////////////// int Direct3DInit() { lpD3D = Direct3DCreate8(D3D_SDK_VERSION); D3DDISPLAYMODE d3ddm; lpD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm); D3DPRESENT_PARAMETERS d3dpp; ZeroMemory(&d3dpp, sizeof(d3dpp)); d3dpp.Windowed = true; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferFormat = d3ddm.Format; lpD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &lpDevice); D3DXCreateTextureFromFile(lpDevice, "image.bmp", &lpTexture); D3DXCreateSprite(lpDevice, &lpSprite); return 0; } /////////////////////////////////////////////////////////////////// int Direct3DRender() { lpDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0); lpDevice->BeginScene(); RECT rect; rect.left = 0; rect.right = 99; rect.top = 0; rect.bottom = 99; lpSprite->Draw(lpTexture, &rect, NULL, NULL, 0, NULL, 32); lpDevice->EndScene(); lpDevice->Present(NULL, NULL, NULL, NULL); return 0; }
Advertisement
Try...

lpSprite->Draw(lpTexture, &rect, NULL, NULL, 0, NULL, D3DCOLOR_ARGB(255, 255, 255, 255);
To ''Anonymous Poster'' just wanted to say i was about to ask the same question and that worked for me, Thanks.
We are here just like this,It really doesn't matter why.The world is here like it is,'We could laugh we could cry.Is it good or is it bad,Wright or maybe wrong?There's no use of being sad,Without a purpose within a song.
If you like you may download my D3DXSprite wrapper and source from my site (link is below). It has mirroring and positioning corrections that may help you get D3DXSprite up and running properly.

  Game Download  ZeroOne Realm

  Downloads:  ZeroOne Realm

This topic is closed to new replies.

Advertisement