Advertisement Jump to content
Sign in to follow this  

Front buffer problems (solved)

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

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 )
	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;

	// 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,
		&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]

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!