Exemplo n.º 1
0
void dd_Window::flip_fullscreen()
{
	int i=0;
	HRESULT hr;

	//hack for 320x200 letterboxing
	if(xres == 320 && yres == 200)
	{
		hr = dx_bs->BltFast(0,20,dx_os,NULL,DDBLTFAST_WAIT | DDBLTFAST_NOCOLORKEY);
		DDBLTFX ddbltfx;
		memset(&ddbltfx, 0, sizeof(DDBLTFX));
		ddbltfx.dwSize = sizeof(DDBLTFX);
		ddbltfx.dwFillColor = 0;
		RECT rBlit;
		rBlit.left = 0; rBlit.top = 0; rBlit.right = 320; rBlit.bottom = 20;
		dx_bs->Blt(&rBlit, 0, 0, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);
		rBlit.left = 0; rBlit.top = 220; rBlit.right = 320; rBlit.bottom = 240;
		dx_bs->Blt(&rBlit, 0, 0, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);
	}
	//regular case
	else
		hr = dx_bs->BltFast(0,0,dx_os,NULL,DDBLTFAST_WAIT | DDBLTFAST_NOCOLORKEY);


	if(hr==DDERR_SURFACELOST)
	{
		dx_bs->Restore();
		dx_os->Restore();
		dx_bs->BltFast(0,0,dx_os,NULL,DDBLTFAST_WAIT | DDBLTFAST_NOCOLORKEY);
	}

	hr=dx_ps->Flip(0,DDFLIP_WAIT | DDFLIP_NOVSYNC);
	//dx_ps->Flip(0,0);

	if(hr==DDERR_SURFACELOST)
	{
		dx_ps->Restore();
		hr=dx_ps->Flip(0,DDFLIP_WAIT | DDFLIP_NOVSYNC);
	}


	hr=dx_os->Lock(0,&dx_osd,DDLOCK_SURFACEMEMORYPTR | DDLOCK_WRITEONLY | DDLOCK_WAIT,0);
	if(hr==DDERR_SURFACELOST)
	{
		dx_os->Restore();
		hr=dx_os->Lock(0,&dx_osd,DDLOCK_SURFACEMEMORYPTR | DDLOCK_WRITEONLY | DDLOCK_WAIT,0);
	}
	dx_os->Unlock(0);

	img->data=(quad*)dx_osd.lpSurface;
	img->pitch=dx_osd.lPitch/vid_bytesperpixel;
}
Exemplo n.º 2
0
	bool flip(long bltWidth,long bltHeight){
        if (m_ddsback==0) return true;
		if (m_IS_USER_BACK_BUFFER){
			if ((bltWidth>0)&&(bltHeight>0)){
				RECT rt; rt.left=0; rt.top=0;
				rt.right=bltWidth; rt.bottom=bltHeight;
				#ifdef WINCE
					HRESULT ddrval=m_ddsprimary->Blt(&rt,m_ddsback, &rt,DDBLT_WAITNOTBUSY, NULL);
				#else
					HRESULT ddrval=m_ddsprimary->BltFast(0,0, m_ddsback, &rt, NULL);
				#endif
				return (ddrval == DD_OK);
			}else
				return true;
		}else{ //flip
			while( true ) {
				HRESULT ddrval= m_ddsprimary->Flip( NULL, DDFLIP_WAIT );// 交换表面
				if( ddrval == DD_OK )
					return true;
				if( ddrval == DDERR_SURFACELOST ) {
					ddrval = m_ddsprimary->Restore();
					if( ddrval!= DD_OK )
						return false;
				}
				if( ddrval != DDERR_WASSTILLDRAWING ){
					return false;
				}
				::Sleep(0);
			}	
		}
	}
Exemplo n.º 3
0
//-----------------------------------------------------------------------------
// Name: BltObject()
// Desc: 
//-----------------------------------------------------------------------------
HRESULT BltObject( int x, int y, LPDIRECTDRAWSURFACE pdds, RECT* prc,
                   DWORD flags )
{
	if( NULL == pdds )
		return E_FAIL;
    
	while( 1 )
    {
        HRESULT hr = g_pddsBackBuffer->BltFast( x, y, pdds, prc, flags );
        if( FAILED(hr) )
        {
            if( hr == DDERR_WASSTILLDRAWING )
                continue;

            if( hr == DDERR_SURFACELOST )
                if( SUCCEEDED( RestoreSurfaces() ) )
                    continue;
            return E_FAIL;
        }

        return S_OK;
    }
}