Sign in to follow this  

Bitmap Animation in DirectX

This topic is 4841 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
Quote:
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

This topic is 4841 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this