Front buffer problems (solved)

Started by
-1 comments, last by blueshogun96 17 years, 8 months ago
I have a problem trying to get a copy of the front surface via IDirect3DDevice9::GetFrontBufferData. I can't get this thing to work at all. I read the documentation on it, but it was rather vague and not very helpful. Are there certain things you need to do before calling it? I have no idea what the problem is, so if you want, you can see my initialization code here
[source lang=c++]
BOOL D3D_Init( HWND hEmuWindow, DWORD dwWidth, DWORD dwHeight, DWORD dwBpp, BOOL bFullscreen )
{
	HRESULT hr;
	D3DCAPS9 d3dcaps;

	// Get pointer to Direct3D9 interface
	if( !( lpD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
		return ErrorMsg( "Direct3D Init Failed!\n\n!Direct3DCreate9: Could not aquire pointer to Direct3D9 interface!" );

	// Get the current display settings
	hr = IDirect3D9_GetAdapterDisplayMode( lpD3D, D3DADAPTER_DEFAULT, &g_d3ddm );
	if( FAILED( hr ) )
		return ErrorMsg( "Direct3D Init Failed!\n\nIDirect3D9::GetAdapterDisplayMode: "
						 "Failed to retreive desktop current display settings." );

	// 
	ZeroMemory( &g_d3dpp, sizeof( D3DPRESENT_PARAMETERS ) );
	g_d3dpp.BackBufferWidth = dwWidth;
	g_d3dpp.BackBufferHeight = dwHeight;
	g_d3dpp.BackBufferCount = 1;
	g_d3dpp.BackBufferFormat = bFullscreen ? SurfaceFormat[dwBpp] : g_d3ddm.Format;
	g_d3dpp.SwapEffect = D3DSWAPEFFECT_FLIP;
	g_d3dpp.hDeviceWindow = hEmuWindow;
	g_d3dpp.Windowed = !bFullscreen;
	g_d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
	g_d3dpp.FullScreen_RefreshRateInHz = bFullscreen ? 60 : 0;
	g_d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
	g_d3dpp.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;


	// Retreive the host video card's capabilities
	hr = IDirect3D9_GetDeviceCaps( lpD3D, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &d3dcaps );
	if( FAILED( hr ) )
		return ErrorMsg( "Direct3D Init Failed!\n\nIDirect3D9::GetDeviceCaps: "
						 "Unable to retreive device capabilities." );

	// Create Direct3D device
	hr = IDirect3D9_CreateDevice( lpD3D, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hEmuWindow,
		d3dcaps.VertexProcessingCaps != 0 ? D3DCREATE_HARDWARE_VERTEXPROCESSING : D3DCREATE_SOFTWARE_VERTEXPROCESSING,
		&g_d3dpp, &lpD3DDevice );
	if( FAILED( hr ) )
		return ErrorMsg( "Direct3D Init Failed!\n\nIDirect3D9::CreateDevice: "
						 "Failed to create Direct3D device." );

	// Retreive front and back surfaces
	hr = IDirect3DDevice9_GetBackBuffer( lpD3DDevice, 0, 0, D3DBACKBUFFER_TYPE_MONO, &lpD3DSBack );
	if( FAILED( hr ) )
		return ErrorMsg( "Direct3D Init Failed!\n\nIDirect3DDevice9::GetBackBuffer: "
						 "Failed to retreive back surface." );

	hr = IDirect3DDevice9_CreateOffscreenPlainSurface( lpD3DDevice, dwWidth, dwHeight, D3DFMT_A8R8G8B8,
														D3DPOOL_SCRATCH, &lpD3DSFront, NULL );
	if( FAILED( hr ) )
		return ErrorMsg( "Direct3D Init Failed!\n\nIDirect3DDevice9::CreateOffscreenPlainSurface: "
						 "Failed to create offscreen plain surface." );

	hr = IDirect3DDevice9_GetFrontBufferData( lpD3DDevice, 0, lpD3DSFront );
	if( FAILED( hr ) )
		return ErrorMsg( "Direct3D Init Failed!\n\nIDirect3DDevice9::GetFrontBufferData: "
						 "Failed to retreive front surface." );


	return TRUE;
}


I've been at this for months now, and Dx9 is just adding to my big list of reasons to hate it. Any help/suggestions are appreciated, thanks. EDIT: never mind, fixed it. :P [Edited by - blueshogun96 on July 29, 2006 1:13:26 PM]

This topic is closed to new replies.

Advertisement