Jump to content
  • Advertisement

Archived

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

Tealc

Windows 2000, DX8 & PrimarySurface Problem

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

Hello, I''m just trying to get into directx programming and I ''ve a problem width initalizing the PrimarySurface under Windows 2000. There are no compile errors but I can''t clear the PrimarySurface (trying to make it black). Here''s the code I use to create a complex surface (PrimarySurface with one BackSurface) :
int InitDirectX() {
	HRESULT ddrval;
	
	ddrval = DirectDrawCreateEx(NULL, (LPVOID *)&lpDD, IID_IDirectDraw7, NULL);
	if (ddrval != DD_OK) {
		MessageBox(hWnd, "DDraw Fehler: DirectDrawCreateEx()", "DDRAW ERROR", MB_OK);
		return(-1);
	}
	
	ddrval = lpDD->SetCooperativeLevel(hWnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN );
	if (ddrval != DD_OK) {
		MessageBox(hWnd, "DDraw Fehler: SetCooperativeLevel()", "DDRAW ERROR", MB_OK);
		return(-1);
	}
	
	ddrval = lpDD->SetDisplayMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, 0, 0);	
	if (ddrval != DD_OK) 
		return(-1);


	
	// create Complex Surface 
	ZeroMemory(&ddsd, sizeof(ddsd));
	ddsd.dwSize = sizeof(ddsd);
	ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
	ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX;
	ddsd.dwBackBufferCount = 1;

	ddrval = lpDD->CreateSurface(&ddsd, &lpDDSPrimary, NULL);
	if (ddrval != DD_OK) {
		MessageBox(hWnd, "DDraw Error: CreateSurface()", "DDRAW ERROR", MB_OK);
		return(-1);
	}

	ZeroMemory(&ddscaps, sizeof(ddscaps));
	ddscaps.dwCaps = DDSCAPS_BACKBUFFER;

	ddrval = lpDDSPrimary->GetAttachedSurface(&ddscaps, &lpDDSBack);
	if (ddrval != DD_OK) {
		MessageBox(hWnd, "DDraw Error: GetAttachedSurface()", "DDRAW ERROR", MB_OK);
		return(-1);
	}

	ClearSurface(lpDDSPrimary, 0);
	ClearSurface(lpDDSBack, 0);

	return(1);
}
 
And here is my routine to clean the surfaces:
bool ClearSurface(LPDIRECTDRAWSURFACE7 lpDDSurf, UCHAR Farbe) {
	HRESULT ddrval;	
	DDBLTFX ddBltFx;

	ZeroMemory(&ddBltFx, sizeof(DDBLTFX));
	ddBltFx.dwSize = sizeof(DDBLTFX);
	ddBltFx.dwFillColor = Farbe;

	ddrval = lpDDSurf->Blt(NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddBltFx);

	if (ddrval != DD_OK) {
		MessageBox(hWnd, "DDraw Error: ClearSurface()","DDRAW ERROR", MB_OK);
		return(false);
	}

	return(true);
}
 
The Back Surface I can clear an set to black color by using ClearSurface(lpDDSBack, 0) - but that''s not working with the Primary Surface. Under Windows 98 it works fine. I only have problem under Windows 2000. What can I do to fix this ???

Share this post


Link to post
Share on other sites
Advertisement

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