Archived

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

DirectDraw getting a bitmap from a surface prob.

This topic is 5984 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'm writing a mouse interface for ddraw, only one surface so theres no flipping. my prob, is that something in the getting the background of the mouse sprite is wrong. i use standard API functions in the mean time and i thought that will make it easier...
    
void CSprite::Get(IDirectDrawSurface *pdds, int x, int y, int gwidth, int gheight)
{
	HDC                 hdcImage;
	HDC                 hdc;

	pdds->GetDC(&hdc);          //getting surface dc

	DeleteObject(bitmap);       //deleting old background


	bitmap = CreateCompatibleBitmap(hdc, gwidth, gheight);
	hdcImage = CreateCompatibleDC(hdc);
	SelectObject(hdcImage,bitmap);

	BitBlt(hdcImage, 0, 0, gwidth, gheight, hdc, x, y, SRCCOPY);
		
	pdds->ReleaseDC(hdc);	
	DeleteDC(hdcImage); 
};
    
and it doesnt seem to put the area inside "bitmap". every other method in the Sprite class seem to work but this doesnt. anyone? Gil Edited by - gilzu on July 28, 2001 10:35:16 PM

Share this post


Link to post
Share on other sites
C''mon people...
i know you can help me, i''m desparate here.
i''ve already designed a small RTS unit where
i have 2 units battling eachother and doing
whatever youll tell them to do, but,

this small thingy prevents me from using mouse
or putting it all to more speed.



help?

Gil

Share this post


Link to post
Share on other sites
Im not exatly sure what u are trying to do, maybe u should dump the hdc and just use lpDDS->Blt() in your CSprite class.

Also I noticed u do not have any error checking - this could lead to unexpected crashing later on, if you check the return values of GetDC, CreateCompatibleDC, and BltBit for errors u could pinpoint the problem.

  Downloads:  ZeroOne Realm

Share this post


Link to post
Share on other sites