Archived

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

mattd

clippers are driving me nuts!

Recommended Posts

some questions for directX7 clippers (LPDIRECTDRAWCLIPPER) before I go insane, which is not preferable... 1) Do i attach a clipper to the primary or back surface? 2) what code do i use to create a clipper?
  
HRESULT CVideo::CreateWindowedClipper(CSurface *dest)
{
    HRESULT result;

    LPDIRECTDRAWCLIPPER pClip;

    if(FAILED(result = m_pDD->CreateClipper(0, &pClip, NULL)))
        return result;

    if(FAILED(result = pClip->SetHWnd(0, m_hWnd)))
    {
        pClip->Release();
		return result;
    }

    if(FAILED(result = dest->SetClipper(pClip)))
    {
        pClip->Release();
        return result;
    }

    if(FAILED(result = pClip->Release()))
        return result;

    return S_OK;
}
/* --------------------- or this ... ----------------------- */
HRESULT CVideo::CreateClipper(CSurface *dest, LPRECT pBound)
{
    HRESULT result;

    LPDIRECTDRAWCLIPPER pClip;

    if(FAILED(result = m_pDD->CreateClipper(0, &pClip, NULL)))
        return result;

	LPRGNDATA lpClipList = (LPRGNDATA)malloc(sizeof(RGNDATAHEADER) +
										     sizeof(RECT));
	memcpy(lpClipList->Buffer, pBound, sizeof(RECT));
	lpClipList->rdh.dwSize = sizeof(RGNDATAHEADER);
	lpClipList->rdh.iType = RDH_RECTANGLES;
	lpClipList->rdh.nCount = 1;
	lpClipList->rdh.nRgnSize = sizeof(RECT);
	lpClipList->rdh.rcBound = *pBound;

	if(FAILED(result = pClip->SetClipList(lpClipList, 0)))
	{	
		free(lpClipList);
        pClip->Release();
		return result;
	}

    free(lpClipList);
    pClip->Release();

    return S_OK;
}
  
i see different code in different examples - and both don''t seem to work... thanks for helping, -- mattd

Share this post


Link to post
Share on other sites
oh, and by the way, i want to be able to do clipping in both windowed and fullscreen modes.

thanks again,
--mattd

Share this post


Link to post
Share on other sites
DirectDrawCLipper only works for windowed mode. for full screen you need to write you own clipping routine. This is done buy RECT manipulation. you will figure out how to do alot of tutorials out there for it.

I AM ALPHA & OMEGA

Share this post


Link to post
Share on other sites