本文整理汇总了C++中LPDIRECTDRAWSURFACE7::SetClipper方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECTDRAWSURFACE7::SetClipper方法的具体用法?C++ LPDIRECTDRAWSURFACE7::SetClipper怎么用?C++ LPDIRECTDRAWSURFACE7::SetClipper使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECTDRAWSURFACE7
的用法示例。
在下文中一共展示了LPDIRECTDRAWSURFACE7::SetClipper方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawOverlay
//! Load the bitmap and copy it to the overlay surface
bool DrawOverlay()
{
HRESULT hRet; // This is where we put return values from DirectDraw.
DDSURFACEDESC2 surfDesc;
// Setup structure
memset(&surfDesc, 0, sizeof(surfDesc)); surfDesc.dwSize = sizeof(surfDesc);
hRet = g_pDDSOverlay->Lock(NULL, &surfDesc, DDLOCK_SURFACEMEMORYPTR | DDLOCK_NOSYSLOCK | DDLOCK_WRITEONLY, NULL);
if (hRet != DD_OK || surfDesc.lpSurface == NULL)
return DisplayError("Can't lock overlay surface", hRet);
else {
g_pImg = (unsigned int *)surfDesc.lpSurface;
//g_pDDSOverlay->Unlock(NULL); is not needed?
}
// Setup effects structure
memset(&g_OverlayFX, 0, sizeof(g_OverlayFX)); g_OverlayFX.dwSize = sizeof(g_OverlayFX);
// Setup overlay flags.
g_OverlayFlags = DDOVER_SHOW;
// Check for destination color keying capability
if ((g_DDCaps.dwCKeyCaps & DDCKEYCAPS_DESTOVERLAY) && ((g_DDCaps.dwCaps & DDCAPS_OVERLAYCANTCLIP) || (g_DDCaps.dwCKeyCaps & DDCKEYCAPS_NOCOSTOVERLAY) ))
{
// If so, we'll use it to clip the bitmap when other windows go on top
// of us. Just for the record - this color range for color keying (the
// high/low values) are not heavily supported right now, so for almost
// all cards, just use the same color for both.
g_OverlayFX.dckDestColorkey.dwColorSpaceLowValue =
g_OverlayFX.dckDestColorkey.dwColorSpaceHighValue = DDColorMatch(g_pDDSPrimary, RGBKEY);
g_OverlayFlags |= DDOVER_DDFX | DDOVER_KEYDESTOVERRIDE;
} else {
// If not, we'll setup a clipper for the window. This will fix the
// problem on a few video cards - but the ones that don't shouldn't care.
hRet = g_pDD->CreateClipper(0, &g_pClipper, NULL);
if (hRet != DD_OK)
return DisplayError("Can't create clipper", hRet);
hRet = g_pClipper->SetHWnd(0, g_hAppWnd);
if (hRet != DD_OK)
return DisplayError("Can't attach clipper", hRet);
hRet = g_pDDSPrimary->SetClipper(g_pClipper);
if (hRet != DD_OK)
return DisplayError("Can't set clipper", hRet);
}
return true;
}
示例2: AttachClipper
//-----------------------------------------------------------------------------
// Name: AttachClipper()
// Desc: creates and attaches a clipper to a surface
//-----------------------------------------------------------------------------
LPDIRECTDRAWCLIPPER AttachClipper(LPDIRECTDRAWSURFACE7 lpddsSurface, HWND hWnd)
{
LPDIRECTDRAWCLIPPER lpddClipper; //pointer to the newly created dd clipper
//first create the DD clipper
ddReturnVal = lpddObj->CreateClipper(0,&lpddClipper, NULL);
if (DDFailedCheck(ddReturnVal, "CreateClipper() failed", cpErrorBuf ))
{ MessageBox(main_window_handle, cpErrorBuf, "AttachClipper()", MB_ICONEXCLAMATION); return(NULL); }
ddReturnVal = lpddClipper->SetHWnd(NULL,hWnd);
if (DDFailedCheck(ddReturnVal, "lpddClipper->SetHWnd() failed", cpErrorBuf ))
{ MessageBox(main_window_handle, cpErrorBuf, "AttachClipper()", MB_ICONEXCLAMATION); return(NULL); }
// now attach the clipper to the surface
ddReturnVal = lpddsSurface->SetClipper(lpddClipper);
if (DDFailedCheck(ddReturnVal, "SetClipper() failed", cpErrorBuf ))
{
MessageBox(main_window_handle, cpErrorBuf, "AttachClipper()", MB_ICONEXCLAMATION);
// release memory and return error
return(NULL);
}
return(lpddClipper);
}
示例3: DDInit
int DDInit(void)
{
HRESULT hRet;
hWnd = Form1->Handle;
DDEnd();
hRet = DirectDrawCreateEx(NULL, (VOID**)&m_pDD, IID_IDirectDraw7, NULL);
if(DDError(hRet != DD_OK,"DDCreateEX")) return(false);
if (Form1->FullScreen)
{
hRet = m_pDD->SetCooperativeLevel(hWnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
hRet = m_pDD->SetDisplayMode(FScreen.Width, FScreen.Height, FScreen.Bpp,NULL,NULL);
}
else hRet = m_pDD->SetCooperativeLevel(hWnd, DDSCL_NORMAL);
if(DDError(hRet != DD_OK,"DDSetCoop")) return(false);
HRESULT hr;
DDSURFACEDESC2 ddsd;
ZeroMemory( &ddsd, sizeof( ddsd ) );
ddsd.dwSize = sizeof( ddsd );
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
if(DDError(hr = m_pDD->CreateSurface(&ddsd, &m_pddsFrontBuffer, NULL)
,"CreateFrontSurface")) return(false);
// Create the backbuffer surface
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
ddsd.dwWidth = 1024;
ddsd.dwHeight = 768;
hr = m_pDD->CreateSurface(&ddsd, &m_pddsFrame, NULL);
if (hr)
{
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
ddsd.dwWidth = 460;
ddsd.dwHeight = 400;
hr = m_pDD->CreateSurface(&ddsd, &m_pddsFrame, NULL);
if(DDError(hr,"CreateBackSurface")) return(false);
tv.DisableAdvanced=1;
}
if (!Form1->FullScreen)
{
if(DDError(hr = m_pDD->CreateClipper(0, &pcClipper, NULL)
,"CreateClipper")) return(false);
if(DDError(hr = pcClipper->SetHWnd(0, hWnd)
,"SetClipperHwnd"))
{
pcClipper->Release();
return(false);
}
if(DDError(hr = m_pddsFrontBuffer->SetClipper(pcClipper)
,"SetClipperSurface"))
{
pcClipper->Release();
return(false);
}
}
return(true);
}
示例4: jcdd_createClipper
BOOL jcdd_createClipper(LPDIRECTDRAW7 lpdd, LPDIRECTDRAWSURFACE7 lpdds, LPDIRECTDRAWCLIPPER* lplpddc, INT numRect, LPRECT rectList)
{
if(lpdd == NULL)
{
return FALSE;
}
if(lpdds == NULL)
{
return FALSE;
}
if(FAILED(lpdd->CreateClipper(0, lplpddc, NULL)))
{
return FALSE;
}
LPRGNDATA regionData;
regionData = (LPRGNDATA)malloc(sizeof(RGNDATAHEADER) + numRect * sizeof(RECT));
memcpy(regionData->Buffer, rectList, numRect * sizeof(RECT));
regionData->rdh.dwSize = sizeof(RGNDATAHEADER);
regionData->rdh.iType = RDH_RECTANGLES;
regionData->rdh.nCount = numRect;
regionData->rdh.nRgnSize = sizeof(RECT) * numRect;
regionData->rdh.rcBound.left = LONG_MAX;
regionData->rdh.rcBound.top = LONG_MAX;
regionData->rdh.rcBound.right = LONG_MIN;
regionData->rdh.rcBound.bottom = LONG_MIN;
for (INT i = 0; i < numRect; ++i)
{
if(rectList[i].left < regionData->rdh.rcBound.left)
{
regionData->rdh.rcBound.left = rectList[i].left;
}
if(rectList[i].top < regionData->rdh.rcBound.top)
{
regionData->rdh.rcBound.top = rectList[i].top;
}
if(rectList[i].right > regionData->rdh.rcBound.right)
{
regionData->rdh.rcBound.right = rectList[i].right;
}
if(rectList[i].bottom > regionData->rdh.rcBound.bottom)
{
regionData->rdh.rcBound.bottom = rectList[i].bottom;
}
}
if(FAILED((*lplpddc)->SetClipList(regionData, 0)))
{
free(regionData);
return NULL;
}
if(FAILED(lpdds->SetClipper(*lplpddc)))
{
free(regionData);
return NULL;
}
free(regionData);
return TRUE;
}
示例5: DDraw_Attach_Clipper
LPDIRECTDRAWCLIPPER DDraw_Attach_Clipper(LPDIRECTDRAWSURFACE7 lpdds,
int num_rects,
LPRECT clip_list)
{
// this function creates a clipper from the sent clip list and attaches
// it to the sent surface
int index; // looping var
LPDIRECTDRAWCLIPPER lpddclipper; // pointer to the newly created dd clipper
LPRGNDATA region_data; // pointer to the region data that contains
// the header and clip list
// first create the direct draw clipper
if (FAILED(lpdd->CreateClipper(0,&lpddclipper,NULL)))
return(NULL);
// now create the clip list from the sent data
// first allocate memory for region data
region_data = (LPRGNDATA)malloc(sizeof(RGNDATAHEADER)+num_rects*sizeof(RECT));
// now copy the rects into region data
memcpy(region_data->Buffer, clip_list, sizeof(RECT)*num_rects);
// set up fields of header
region_data->rdh.dwSize = sizeof(RGNDATAHEADER);
region_data->rdh.iType = RDH_RECTANGLES;
region_data->rdh.nCount = num_rects;
region_data->rdh.nRgnSize = num_rects*sizeof(RECT);
region_data->rdh.rcBound.left = 64000;
region_data->rdh.rcBound.top = 64000;
region_data->rdh.rcBound.right = -64000;
region_data->rdh.rcBound.bottom = -64000;
// find bounds of all clipping regions
for (index=0; index<num_rects; index++)
{
// test if the next rectangle unioned with the current bound is larger
if (clip_list[index].left < region_data->rdh.rcBound.left)
region_data->rdh.rcBound.left = clip_list[index].left;
if (clip_list[index].right > region_data->rdh.rcBound.right)
region_data->rdh.rcBound.right = clip_list[index].right;
if (clip_list[index].top < region_data->rdh.rcBound.top)
region_data->rdh.rcBound.top = clip_list[index].top;
if (clip_list[index].bottom > region_data->rdh.rcBound.bottom)
region_data->rdh.rcBound.bottom = clip_list[index].bottom;
} // end for index
// now we have computed the bounding rectangle region and set up the data
// now let's set the clipping list
if (FAILED(lpddclipper->SetClipList(region_data, 0)))
{
// release memory and return error
free(region_data);
return(NULL);
} // end if
// now attach the clipper to the surface
if (FAILED(lpdds->SetClipper(lpddclipper)))
{
// release memory and return error
free(region_data);
return(NULL);
} // end if
// all is well, so release memory and send back the pointer to the new clipper
free(region_data);
return(lpddclipper);
} // end DDraw_Attach_Clipper
示例6: CreateWindowedDisplay
static HRESULT CreateWindowedDisplay(HWND hWnd, DWORD dwWidth, DWORD dwHeight)
{
// Set cooperative level
if (FAILED(lpdd->SetCooperativeLevel(hWnd, DDSCL_NORMAL)))
{
return E_FAIL;
}
RECT rcWork;
RECT rc;
DWORD dwStyle;
// If we are still a WS_POPUP window
// We should convert to a normal app window so we look like a windows app.
dwStyle = GetWindowLong(hWnd, GWL_STYLE);
dwStyle &= ~WS_POPUP;
dwStyle |= WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;
SetWindowLong(hWnd, GWL_STYLE, dwStyle);
// Adapt window size
SetRect(&rc, 0, 0, dwWidth, dwHeight);
AdjustWindowRectEx(&rc, GetWindowStyle(hWnd), GetMenu(hWnd) != NULL, GetWindowExStyle(hWnd));
SetWindowPos(hWnd, NULL, 0, 0, rc.right - rc.left, rc.bottom - rc.top, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
// Make sure our window does not hang outside of the work area
SystemParametersInfo(SPI_GETWORKAREA, 0, &rcWork, 0);
GetWindowRect(hWnd, &rc);
if (rc.left < rcWork.left) rc.left = rcWork.left;
if (rc.top < rcWork.top) rc.top = rcWork.top;
SetWindowPos(hWnd, NULL, rc.left, rc.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
// Create the primary surface
DDSURFACEDESC2 ddsd;
DDRAW_INIT_STRUCT(ddsd);
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
if (FAILED(lpdd->CreateSurface(&ddsd, &lpddsMain, NULL)))
{
return E_FAIL;
}
// Create the backbuffer surface
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_CKSRCBLT;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
ddsd.dwWidth = dwWidth;
ddsd.dwHeight = dwHeight;
if (FAILED(lpdd->CreateSurface(&ddsd, &lpddsBack, NULL)))
{
return E_FAIL;
}
// Set surface color key
DDCOLORKEY ddCK;
ddCK.dwColorSpaceLowValue = 0;
ddCK.dwColorSpaceHighValue = 0;
if (lpddsBack->SetColorKey(DDCKEY_SRCBLT, &ddCK))
{
return E_FAIL;
}
// Create clipper for the primary surface
LPDIRECTDRAWCLIPPER lpClipper;
if (FAILED(lpdd->CreateClipper(0, &lpClipper, NULL)))
{
return E_FAIL;
}
if (FAILED(lpClipper->SetHWnd(0, hWnd)))
{
lpClipper->Release();
return E_FAIL;
}
if (FAILED(lpddsMain->SetClipper(lpClipper)))
{
lpClipper->Release();
return E_FAIL;
}
lpClipper->Release();
lpClipper = NULL;
// Update window flag
SetClassLong(hWnd, GCL_HICONSM, (LONG)LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICONSM)));
SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LONG)LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICONSM)));
UpdateWindow(hWnd);
return S_OK;
}
示例7: vdraw_ddraw_init
//.........这里部分代码省略.........
vdraw_ddraw_free_all(false);
LOG_MSG(video, LOG_MSG_LEVEL_ERROR,
"lpDDS_Primary->GetAttachSurface() failed: 0x%08X", rval);
return -6;
}
lpDDS_Blit = lpDDS_Flip;
}
else
{
lpDDS_Blit = lpDDS_Primary;
}
}
else
{
rval = lpDD->CreateClipper(0, &lpDDC_Clipper, NULL);
if (FAILED(rval))
{
vdraw_ddraw_free_all(false);
LOG_MSG(video, LOG_MSG_LEVEL_ERROR,
"lpDD->CreateClipper() failed: 0x%08X", rval);
return -7;
}
rval = lpDDC_Clipper->SetHWnd(0, gens_window);
if (FAILED(rval))
{
vdraw_ddraw_free_all(false);
LOG_MSG(video, LOG_MSG_LEVEL_ERROR,
"lpDDC_Clipper->SetHWnd() failed: 0x%08X", rval);
return -8;
}
rval = lpDDS_Primary->SetClipper(lpDDC_Clipper);
if (FAILED(rval))
{
vdraw_ddraw_free_all(false);
LOG_MSG(video, LOG_MSG_LEVEL_ERROR,
"lpDDC_Primary->SetClipper() failed: 0x%08X", rval);
return -9;
}
}
// Clear ddsd again.
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
// Determine the width and height.
// NOTE: For DirectDraw, the actual 336 width is used.
if (vdraw_ddraw_is_hw_render())
{
// Normal render mode. 320x240 [336x240]
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
ddsd.dwWidth = 336;
ddsd.dwHeight = 240;
}
else
{
// Larger than 1x.
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY;
ddsd.dwWidth = w;
ddsd.dwHeight = h;
}
// Set the pixel format.
示例8: dx_Initialise
//.........这里部分代码省略.........
Surfaces = new LPDIRECTDRAWSURFACE7[NombreSurfaces];
// Initialisation de directdraw
ErrDd = DirectDrawCreateEx (0,(LPVOID*)&DirectDraw7,IID_IDirectDraw7,0);
if (ErrDd != DD_OK) return dx_Finalise (ERR_NO_CREATION);
ModeCoop = PleinEcran ? COOP_PLEIN_ECRAN : COOP_FENETRE;
// Utilisation de la résolution active ou donnée
if (ResolutionX == 0 || ResolutionY == 0 ||
BitsParPixel == 0 || Frequence == 0)
{
DDSURFACEDESC2 ModeActif;
ZeroMemory (&ModeActif, sizeof(ModeActif));
ModeActif.dwSize = sizeof(ModeActif);
ErrDd = DirectDraw7->GetDisplayMode (&ModeActif);
if (ErrDd != DD_OK) return dx_Finalise (ERR_NO_MODE_ACTIF);
if (ResolutionX == 0) ResolutionX = ModeActif.dwWidth;
if (ResolutionY == 0) ResolutionY = ModeActif.dwHeight;
if (BitsParPixel == 0) BitsParPixel = ModeActif.
ddpfPixelFormat.dwRGBBitCount;
if (Frequence == 0) Frequence = ModeActif.dwRefreshRate;
}
// Sélection du mode de coopération
ErrDd = DirectDraw7->SetCooperativeLevel (Fenetre, ModeCoop);
if (ErrDd != DD_OK) return dx_Finalise (ERR_NO_COOPERATION);
ErrDd = DirectDraw7->SetDisplayMode (ResolutionX,
ResolutionY,BitsParPixel,0,0);
if (ErrDd != DD_OK) return dx_Finalise (ERR_NO_MODE_AFFICHAGE);
// Création des surfaces d'affichage
SurfaceDesc.dwFlags = DDSD_CAPS;
SurfaceDesc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
if (PleinEcran)
{ // Surface avec backbuffer
SurfaceDesc.dwFlags |= DDSD_BACKBUFFERCOUNT;
SurfaceDesc.ddsCaps.dwCaps |= DDSCAPS_FLIP | DDSCAPS_COMPLEX;
SurfaceDesc.dwBackBufferCount = 1;
}
ErrDd = DirectDraw7->CreateSurface (&SurfaceDesc,&SurfacePrimaire,NULL);
if (ErrDd != DD_OK) return dx_Finalise (ERR_NO_PRIMAIRE);
if (PleinEcran)
{
SurfaceCaps.dwCaps = DDSCAPS_BACKBUFFER;
ErrDd = SurfacePrimaire->GetAttachedSurface (&SurfaceCaps,&SurfaceBack);
if (ErrDd != DD_OK) return dx_Finalise (ERR_NO_BACKBUFFER);
}
else
{
// Surface avec clipper pour dessiner que dans la fenêtre
ErrDd = DirectDraw7->CreateClipper (0, &SurfaceClipper, NULL);
if (ErrDd != DD_OK) return dx_Finalise (ERR_NO_CLIPPER);
// Coordonnées de la fenêtre dans le clipper
ErrDd = SurfaceClipper->SetHWnd (0, Fenetre);
if (ErrDd != DD_OK) return dx_Finalise (ERR_NO_CLIPPER_HWND);
// Attache le clipper à la surface primaire
ErrDd = SurfacePrimaire->SetClipper (SurfaceClipper);
if (ErrDd != DD_OK) return dx_Finalise (ERR_NO_CLIPPER_PRIMAIRE);
ZeroMemory (&SurfaceDesc, sizeof(SurfaceDesc));
SurfaceDesc.dwSize = sizeof(SurfaceDesc);
SurfaceDesc.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
SurfaceDesc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
SurfaceDesc.dwWidth = ResolutionX;
SurfaceDesc.dwHeight = ResolutionY;
// Création du backbuffer séparément
ErrDd = DirectDraw7->CreateSurface (&SurfaceDesc,&SurfaceBack,NULL);
if (ErrDd != DD_OK) return dx_Finalise (ERR_NO_BACKBUFFER);
}
if (PleinEcran) ShowCursor (false);
return true;
}