Advertisement

Windows 2000, DX8 & PrimarySurface Problem

Started by February 17, 2001 04:54 PM
-1 comments, last by Tealc 23 years, 11 months ago
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 ???

This topic is closed to new replies.

Advertisement