Jump to content
  • Advertisement


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


Direct Draw Tile Blitting Problem

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

What I am trying to put together is a simplified version of the templated tileset idea used in the book "Isometric Game Programming with DirectX7". The following error message is generated whenever I try to blit a tile onto a back buffer: "Access to the surface is refused because the surface is locked by another thread." The app isn't multi-threaded and DirectX is running in fullscreen mode anyway. The LoadTileset() routine simply reads in the specified bitmap and works out the source rectangles for each tile in the bitmap which it then stores in an array e.g. for a set of 48 x 48 tiles, it stores the top left and bottom right coordinates as POINTs. For example, Tile 0 = (1,1)-(48,48), Tile 2 = (50,1)-(97,48). I have verified with a paint program that it reads the tile coordinates correctly. When attempting to blit a tile I do this:
// Note: only basic error checking is left in

typedef struct sTileInfo
	RECT rcSrc;												// Source rectangle 

	RECT rcDst;												// Destination rectangle

} tileInfo, *tileInfoPtr;

tileInfoPtr tileList;

void GameLoop(void)
 	// Assume everything is set up 

	// Blit background 

	if((hRes = lpddsBack->Blt(NULL, lpddsBackground, NULL, DDBLT_WAIT, NULL)) != DD_OK)
		return false;
	// (Surface buffer, x, y, tile #

	tsTile.PutTile(lpddsBackground, 200, 400, 1);
bool CTile::PutTile(LPDIRECTDRAWSURFACE7 lpddsDst, int destX, int destY, int tileCnt)
	// Set the destination rectangle 

	SetRect(&tileList[tileCnt].rcDst, destX, destY, destX + GetTileWidth(), destY + GetTileHeight());

	// Blit the tile	** This is the call that results in DDERR_SURFACEBUSY

	if((hRes = lpddsDst->Blt(&tileList[tileCnt].rcDst, lpddsTileSet, &tileList[tileCnt].rcSrc, DDBLT_WAIT | DDBLT_KEYSRC, NULL)) != DD_OK)
		return false;

	return true;
I just cannot see what is causing the surface to be busy. I originally thought it might be something to do with DDBLT_WAIT but according to the DX SDK docs, all that does is makes the Blt call wait until the blit can be set up or some error that isn't DDERR_WASSTILLDRAWING occurs I really don't want to have hundreds of little bitmaps cluttering up the project :-) [edited by - Malice on September 10, 2002 8:02:51 AM]

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!