Archived

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

Problem with D3DXSprite::Draw()

This topic is 6012 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
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
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