Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Alload

Problem with D3DXSprite::Draw()

This topic is 6230 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 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; }

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Try...

lpSprite->Draw(lpTexture, &rect, NULL, NULL, 0, NULL, D3DCOLOR_ARGB(255, 255, 255, 255);

Share this post


Link to post
Share on other sites
To ''Anonymous Poster'' just wanted to say i was about to ask the same question and that worked for me, Thanks.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • 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!