Jump to content
  • Advertisement
Sign in to follow this  

Bitmap Animation in DirectX

This topic is 5176 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've been having this Zen of Direct3D game programming book for awhile and I finally got the bitmaps to work (stumbled across the solution in these forums YAY!) but now im trying to get them to move, not even alot just a couple hundred pixels but all i end up with is a line...like its not redrawing the scene, just adding on to it ... here is my Render() code: int Render() { HRESULT r; D3DLOCKED_RECT LockedRect; LPDIRECT3DSURFACE8 pBackSurf = 0; if(!g_pDevice) { SetError("No deivce to render to...faggot"); return E_FAIL; } g_pDevice->Clear(0,0,D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,255,0),1.0f,0); r = g_pDevice->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &pBackSurf); if(FAILED(r)) { SetError("Could not get the backbuffer."); return E_FAIL; } //Drawing goes here bizatch LPDIRECT3DSURFACE8 pSurface = 0; LoadBitmapToSurface("fishy.bmp", &pSurface, g_pDevice); D3DSURFACE_DESC d3dsd; if(FAILED(pSurface->GetDesc(&d3dsd))) { SetError("Could not get pSurface Description"); return E_FAIL; } for(int x = 1;x<350;x++){ POINT DestPoint = {x,0}; RECT rect = {0,0,d3dsd.Width,d3dsd.Height}; CopySurfaceToSurface(&rect, pSurface,&DestPoint,pBackSurf,TRUE, D3DCOLOR_ARGB(0,255,0,255)); } pSurface->Release(); pSurface = 0; //////////////////////////////// r = pBackSurf->LockRect(&LockedRect,NULL,0); if(FAILED(r)) { SetError("Could not lock the back buffer...faggot"); return E_FAIL; } DWORD* pData = (DWORD*)(LockedRect.pBits); pBackSurf->UnlockRect(); pData= 0; pBackSurf->Release(); pBackSurf = 0; g_pDevice->Present(NULL,NULL,NULL,NULL); return S_OK; }

Share this post

Link to post
Share on other sites
Original post by nickbird
for(int x = 1;x<350;x++){
POINT DestPoint = {x,0};
RECT rect = {0,0,d3dsd.Width,d3dsd.Height};

CopySurfaceToSurface(&rect, pSurface, &DestPoint,
pBackSurf, TRUE, D3DCOLOR_ARGB(0,255,0,255));

Well, it appears you're drawing them each 350 times or something. I'm not exactly sure why you have the loop here.

I can kinda see how you're doing it, but wouldn't it be a lot easier to use point sprites or quads? (though you're using a book, but whatever)

Oh - and don't forget to use [code] tags to denote code, and [source] for lots of code! (and don't forget to close your tags, for that matter, either!)

Share this post

Link to post
Share on other sites
Sign in to follow this  

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