Archived

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

BltFast Problem

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

Ok, here's a weird problem. I am trying to blit to a back buffer surface from an offscreen plain surface. It should be pretty straightforward. However, the BltFast doesn't seem to be working. I put in some statements to write out the error to a text file. Here's my code:
	//Compose a frame of animation--gBackground is an offscreen plain surface, gBackBuffer is a surface attached to a Primary surface
	result = gBackBuffer->BltFast(0,0,gBackground, NULL, DDBLTFAST_NOCOLORKEY|DDBLTFAST_WAIT);
	if(result!=DD_OK)
	{
		WriteLog("Failed to Blit Background\n");
		switch(result)
		{
		case DDERR_EXCEPTION:
			WriteLog("DDERR_EXCEPTION\n");
			break;
		case DDERR_GENERIC:
			WriteLog("DDERR_GENERIC\n");
			break;
		case DDERR_INVALIDOBJECT:
			WriteLog("DDERR_INVALIDOBJECT\n");
			break;
		case DDERR_INVALIDPARAMS:
			WriteLog("DDERR_INVALIDPARAMS\n");
			break;
		case DDERR_INVALIDRECT:
			WriteLog("DDERR_INVALIDRECT\n");
			break;
		case DDERR_NOBLTHW:
			WriteLog("DDERR_NOBLTHW\n");
			break;
		case DDERR_SURFACEBUSY:
			WriteLog("DDERR_SURFACEBUSY\n");
			break;
		case DDERR_SURFACELOST:
			WriteLog("DDERR_SURFACELOST\n");
			break;
		case DDERR_UNSUPPORTED:
			WriteLog("DDERR_UNSUPPORTED\n");
			break;
		case DDERR_WASSTILLDRAWING:
			WriteLog("DDERR_WASSTILLDRAWING\n");
			break;
		default:
			WriteLog("Was some weird error\n");
			break;
		}
		return FALSE;
	}
  
My error log file has nothing but 'Was some weird error'. I can't figure out where BltFast is failing. Any suggestions? Edited by - Teric on March 19, 2002 7:37:47 AM

Share this post


Link to post
Share on other sites
theres quite a few reasons which really depend on your level of skill.

I don''t want to offend but have you checked if the backbuffer is attached and the height and width in your surface description for the offscreen surface are <= screen res? And if its in fullscreen (i''m guessing so heh) check that your in exclusive mode as that can be a bit of a pain if you aren''t

Also a long shot but try removing the nocolorkey tag - maybe DD checks if there is a color key on there.. I''m not sure heh since I''ve never used the flag.

Philip Lutas
Optical Realities

Share this post


Link to post
Share on other sites
Exclusive mode: check. Full Screen: check.
gDDraw->SetCooperativeLevel(hwnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN) 


Screen Width: 640 Screen Height: 480
//From ''defines.h''
#define SCREEN_WIDTH 640
#define SCREEN_HEIGHT 480
#define COLOR_DEPTH 8

//From ''ddsetup.cpp''
gDDraw->SetDisplayMode(SCREEN_WIDTH, SCREEN_HEIGHT, COLOR_DEPTH)


Back buffer surface attached: check
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;

//Set the capabilities field to show that this will be the descriptor for the primary surface
//that is complex (i.e. having buffer surfaces attached) and flippable
ddsd.ddsCaps.dwCaps=DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX;

//Tell DirectX that there will only be one backbuffer
ddsd.dwBackBufferCount=1;

//Now use the descriptor to create a direct draw surface.
if(FAILED(gDDraw->CreateSurface(&ddsd, &gPrimary, NULL)))
return FALSE;

//Call the CreatePalette function to set up a palette for the primary surface
gPrimaryPalette = CreatePalette(gPrimary);

//Set up the back buffer surface and attach it to the primary surface
ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
if(FAILED(gPrimary->GetAttachedSurface(&ddscaps,&gBackBuffer)))
return FALSE;


Offscreen surface <= screen res: check.
//Set up the surface to hold the background image
ddsd.dwSize=sizeof(ddsd);
ddsd.dwFlags=DDSD_CAPS|DDSD_HEIGHT|DDSD_WIDTH;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
ddsd.dwHeight=SCREEN_HEIGHT;
ddsd.dwWidth=SCREEN_WIDTH;

//Create the background image surface
if(FAILED(gDDraw->CreateSurface(&ddsd, &gBackground, NULL)))
return FALSE;


I''ll try removing that nocolorkey flag, and see what it does. Any other suggestions?

Share this post


Link to post
Share on other sites
Well, I figured out my problem. I have a clipper attached to the BackBuffer surface, but I was using BltFast (which doesn''t use a clipper) instead of Blt, which does use a clipper. *bonk head* Thanks anyway!

Share this post


Link to post
Share on other sites