本文整理汇总了C++中LPDIRECTDRAWCLIPPER类的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECTDRAWCLIPPER类的具体用法?C++ LPDIRECTDRAWCLIPPER怎么用?C++ LPDIRECTDRAWCLIPPER使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LPDIRECTDRAWCLIPPER类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadLibrary
HRESULT DDVideo::InitDirectDraw()
{
DDSURFACEDESC2 ddsd;
DDSCAPS2 ddscaps;
HRESULT hRet;
//Create the main DirectDraw object - updated to do it the hard way.... 7/10
LPDIRECTDRAW pDD;
HINSTANCE hInstDDraw;
LPDIRECTDRAWCREATE pDDCreate = NULL;
hInstDDraw = LoadLibrary("ddraw.dll");
pDDCreate = ( LPDIRECTDRAWCREATE )GetProcAddress( hInstDDraw, "DirectDrawCreate" );
pDDCreate( NULL, &pDD, NULL );
//hRet = DirectDrawCreate(NULL,&pDD, NULL);
hRet = pDD->QueryInterface(IID_IDirectDraw7, (LPVOID *) & m_lpDD);
//Set cooperative level
if (m_bWindowed) { //#112
m_lpDD->SetCooperativeLevel(m_hWnd, DDSCL_ALLOWREBOOT | DDSCL_NORMAL | DDSCL_MULTITHREADED);
} else {
hRet = m_lpDD->SetCooperativeLevel(m_hWnd,DDSCL_EXCLUSIVE |DDSCL_ALLOWREBOOT| DDSCL_ALLOWMODEX | DDSCL_FULLSCREEN | DDSCL_MULTITHREADED);
m_lpDD->SetDisplayMode(800,600,16,g_DX9Settings.m_refreshrate,0);
}
ZeroMemory(&ddsd, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
//#112
ddsd.dwFlags = (m_bWindowed) ? DDSD_CAPS : DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps = (m_bWindowed) ? DDSCAPS_PRIMARYSURFACE : DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX;
if (m_bWindowed) {
LPDIRECTDRAWCLIPPER lpClipper;
hRet = m_lpDD->CreateSurface(&ddsd, &m_lpDDSPrimary, NULL);
hRet = m_lpDD->CreateClipper( 0, &lpClipper, NULL );
hRet = lpClipper->SetHWnd( 0, m_hWnd );
hRet = m_lpDDSPrimary->SetClipper( lpClipper );
ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
ddsd.dwWidth = 800;
ddsd.dwHeight = 600;
hRet = m_lpDD->CreateSurface(&ddsd, &m_lpDDSBack, NULL);
} else {
ddsd.dwBackBufferCount = 1;
hRet = m_lpDD->CreateSurface(&ddsd, &m_lpDDSPrimary, NULL);
ZeroMemory( &ddscaps, sizeof( ddscaps ) );
ddscaps.dwCaps=DDSCAPS_BACKBUFFER;
hRet = m_lpDDSPrimary->GetAttachedSurface(&ddscaps,&m_lpDDSBack);
}
pDD->Release();
return hRet;
}
示例2: InitClipper
//-----------------------------------------------------------------------------
// Name: CDisplay::InitClipper
// Desc:
//-----------------------------------------------------------------------------
HRESULT CDisplay::InitClipper()
{
LPDIRECTDRAWCLIPPER pClipper;
HRESULT hr;
// Create a clipper when using GDI to draw on the primary surface
if( FAILED( hr = m_pDD->CreateClipper( 0, &pClipper, NULL ) ) )
return hr;
pClipper->SetHWnd( 0, m_hWnd );
if( FAILED( hr = m_pddsFrontBuffer->SetClipper( pClipper ) ) )
return hr;
// We can release the clipper now since g_pDDSPrimary
// now maintains a ref count on the clipper
SAFE_RELEASE( pClipper );
return S_OK;
}
示例3: 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);
}
示例4: DDRAW4_HOOK_CreateSurface
//.........这里部分代码省略.........
{
char dwFlags_buffer[LOGBUFFER_MAX], ddscaps1_buffer[LOGBUFFER_MAX], ddpf_buffer[LOGBUFFER_MAX];
FlagsToString(FLAGS_DDSD, CFLAGS_DDSD, lpDDSurfaceDesc->dwFlags, (char *)&dwFlags_buffer, LOGBUFFER_MAX);
FlagsToString(FLAGS_DDSCAPS1, CFLAGS_DDSCAPS1, lpDDSurfaceDesc->ddsCaps.dwCaps, (char *)&ddscaps1_buffer, LOGBUFFER_MAX);
FlagsToString(FLAGS_DDPF, CFLAGS_DDPF, lpDDSurfaceDesc->ddpfPixelFormat.dwFlags, (char *)&ddpf_buffer, LOGBUFFER_MAX);
Log("->lpDDSurfaceDesc { dwSize=%#010lx, dwFlags=%#010lx (%s), dwWidth=%#010lx (%d), dwHeight=%#010lx (%d), lPitch=%#010lx , dwLinearSize=%#010lx, dwBackBufferCount=%#010lx, dwMipMapCount=%#010lx, dwRefreshRate=%#010lx, dwAlphaBitDepth=%#010lx, dwReserved=%#010lx,\n"
" lpSurface=%#010lx, ddckCKDestOverlay={ %#010lx, %#010lx }, ddckCKDestBlt={ %#010lx, %#010lx }, ddckCKSrcOverlay={ %#010lx, %#010lx }, ddckCKSrcBlt={ %#010lx, %#010lx },\n"
" ddpfPixelFormat={ dwSize=%#010lx, dwFlags=%#010lx (%s), dwFourCC=%#010lx, dwRGBBitCount=%#010lx, dwYUVBitCount=%#010lx, dwZBufferBitDepth=%#010lx, dwAlphaBitDepth=%#010lx, dwLuminanceBitCount=%#010lx, dwBumpBitCount=%#010lx, dwRBitMask=%#010lx,\n"
" dwYBitMask=%#010lx, dwStencilBitDepth=%#010lx, dwLuminanceBitMask=%#010lx, dwBumpDuBitMask=%#010lx, dwGBitMask=%#010lx, dwUBitMask=%#010lx, dwZBitMask=%#010lx, dwBumpDvBitMask=%#010lx, dwBBitMask=%#010lx, dwVBitMask=%#010lx, dwStencilBitMask=%#010lx,\n"
" dwBumpLuminanceBitMask=%#010lx, dwRGBAlphaBitMask=%#010lx, dwYUVAlphaBitMask=%#010lx, dwLuminanceAlphaBitMask=%#010lx, dwRGBZBitMask=%#010lx, dwYUVZBitMask=%#010lx },\n"
" ddsCaps={ %#010lx (%s), %#010lx, %#010lx, %#010lx }, dwTextureStage=%#010lx }\n",
lpDDSurfaceDesc->dwSize, lpDDSurfaceDesc->dwFlags, dwFlags_buffer, lpDDSurfaceDesc->dwWidth, (unsigned int)lpDDSurfaceDesc->dwWidth, lpDDSurfaceDesc->dwHeight, (unsigned int)lpDDSurfaceDesc->dwHeight, lpDDSurfaceDesc->lPitch,
lpDDSurfaceDesc->dwLinearSize, lpDDSurfaceDesc->dwBackBufferCount, lpDDSurfaceDesc->dwMipMapCount, lpDDSurfaceDesc->dwRefreshRate, lpDDSurfaceDesc->dwAlphaBitDepth, lpDDSurfaceDesc->dwReserved, lpDDSurfaceDesc->lpSurface,
lpDDSurfaceDesc->ddckCKDestOverlay.dwColorSpaceLowValue, lpDDSurfaceDesc->ddckCKDestOverlay.dwColorSpaceHighValue, lpDDSurfaceDesc->ddckCKDestBlt.dwColorSpaceLowValue, lpDDSurfaceDesc->ddckCKDestBlt.dwColorSpaceHighValue,
lpDDSurfaceDesc->ddckCKSrcOverlay.dwColorSpaceLowValue, lpDDSurfaceDesc->ddckCKSrcOverlay.dwColorSpaceHighValue, lpDDSurfaceDesc->ddckCKSrcBlt.dwColorSpaceLowValue, lpDDSurfaceDesc->ddckCKSrcBlt.dwColorSpaceHighValue,
lpDDSurfaceDesc->ddpfPixelFormat.dwSize, lpDDSurfaceDesc->ddpfPixelFormat.dwFlags, ddpf_buffer, lpDDSurfaceDesc->ddpfPixelFormat.dwFourCC, lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount, lpDDSurfaceDesc->ddpfPixelFormat.dwYUVBitCount,
lpDDSurfaceDesc->ddpfPixelFormat.dwZBufferBitDepth, lpDDSurfaceDesc->ddpfPixelFormat.dwAlphaBitDepth, lpDDSurfaceDesc->ddpfPixelFormat.dwLuminanceBitCount, lpDDSurfaceDesc->ddpfPixelFormat.dwBumpBitCount,
lpDDSurfaceDesc->ddpfPixelFormat.dwRBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwYBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwStencilBitDepth, lpDDSurfaceDesc->ddpfPixelFormat.dwLuminanceBitMask,
lpDDSurfaceDesc->ddpfPixelFormat.dwBumpDuBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwGBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwUBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwZBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwBumpDvBitMask,
lpDDSurfaceDesc->ddpfPixelFormat.dwBBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwVBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwStencilBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwBumpLuminanceBitMask,
lpDDSurfaceDesc->ddpfPixelFormat.dwRGBAlphaBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwYUVAlphaBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwLuminanceAlphaBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwRGBZBitMask,
lpDDSurfaceDesc->ddpfPixelFormat.dwYUVZBitMask,
lpDDSurfaceDesc->ddsCaps.dwCaps, ddscaps1_buffer, lpDDSurfaceDesc->ddsCaps.dwCaps2, lpDDSurfaceDesc->ddsCaps.dwCaps3, lpDDSurfaceDesc->ddsCaps.dwCaps4, lpDDSurfaceDesc->dwTextureStage
);
}
if(ishooked_ddrawsurface4_hooks == false)
{
HookVTBLCalls((LPVOID *)lplpDDSurface4, ddrawsurface4_hooks, count_ddrawsurface4_hooks, "IDirectDrawSurface4");
ishooked_ddrawsurface4_hooks = true;
}
// ------------------------------------------------------------------
// Create a DirectX window
// ----------------------------
#ifdef FF8_WINDOWED
if((void *)lpDDSurfaceDesc == (void *)0x00134658)
{
Log("IF[lpDDSurfaceDesc == 0x00134658] THEN\n");
if(SUCCEEDED(ret))
{
LPDIRECTDRAWCLIPPER pcClipper;
if(FAILED(((LPDIRECTDRAW4)ppvOut)->CreateClipper(0, &pcClipper, NULL)))
{
Log("ERROR: Couldn't create clipper\n");
}
// Associate the clipper with the window
Log("g_hwnd=%#01lx\n", g_hwnd);
pcClipper->SetHWnd(0, g_hwnd);
(*lplpDDSurface4)->SetClipper(pcClipper);
//SAFE_RELEASE(pcClipper);
HRESULT hr = 0;
LPDIRECTDRAWSURFACE4 lpddsB = NULL;
LPDIRECTDRAWSURFACE4 lpddsZ = NULL;
DDSURFACEDESC2 ddsd;
ZeroMemory(&ddsd, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = (DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT);
ddsd.ddsCaps.dwCaps = (lpDDSurfaceDesc->ddsCaps.dwCaps);
ddsd.ddsCaps.dwCaps &= ~(DDSCAPS_PRIMARYSURFACE);
ddsd.ddsCaps.dwCaps |= (DDSCAPS_OFFSCREENPLAIN);
ddsd.dwWidth = 640;
ddsd.dwHeight = 480;
//hRes = lpdd->lpVtbl->CreateSurface(lpdd, &ddsd, &lpddZBuffer,NULL);
hr = ((LPDIRECTDRAW4)ppvOut)->CreateSurface(&ddsd, &lpddsB, NULL);
if(FAILED(hr))
{
Log("ERROR: Failed to create WINDOWED backbuffer!");
} else {
//hr = (*lplpDDSurface4)->AddAttachedSurface(lpddsB);
//if(FAILED(hr)) {
// Log("ERROR: Failed to attach WINDOWED backbuffer to frontbuffer!");
//} else {
g_frontbuffer = (*lplpDDSurface4);
g_backbuffer = lpddsB;
/*hr = ((LPDIRECTDRAW4)ppvOut)->CreateSurface(&ddsd, &lpddsZ, NULL);
if(FAILED(hr)) {
Log("ERROR: Failed to create WINDOWED z-buffer!");
} else {
hr = lpddsB->AddAttachedSurface(lpddsZ);
if(FAILED(hr)) {
Log("ERROR: Failed to attach WINDOWED z-buffer to backbuffer!");
} else {
}
}*/
//}
}
}
}
#endif
// ----------------------------------
return ret;
}
示例5: 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;
}
示例6: 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
示例7: DDShutdown
void DDShutdown(void)
{
// release clipper
if (lpDDClipper) {
lpDDClipper->Release();
lpDDClipper = NULL;
}
// release the secondary surface
if (lpDDSBack) {
lpDDSBack->Release();
lpDDSBack = NULL;
}
// release the primary surface
if (lpDDSPrimary) {
lpDDSPrimary->Release();
lpDDSPrimary = NULL;
}
// finally, the main dd object
if (lpDD) {
lpDD->Release();
lpDD = NULL;
}
}
示例8: DD_Shutdown
int DD_Shutdown(void)
{
// this function release all the resources directdraw
// allocated, mainly to com objects
// release the clipper first
if (lpddclipper)
lpddclipper->Release();
// release the palette
if (lpddpal)
lpddpal->Release();
// release the secondary surface
if (lpddsback)
lpddsback->Release();
// release the primary surface
if (lpddsprimary)
lpddsprimary->Release();
// finally, the main dd object
if (lpdd)
lpdd->Release();
// return success
return(1);
} // end DD_Shutdown
示例9: cleanup
void DirectDrawDisplay::cleanup()
{
if(pDirectDraw != NULL) {
if(ddsClipper != NULL) {
ddsClipper->Release();
ddsClipper = NULL;
}
if(ddsFlip != NULL) {
ddsFlip->Release();
ddsFlip = NULL;
}
if(ddsOffscreen != NULL) {
ddsOffscreen->Release();
ddsOffscreen = NULL;
}
if(ddsPrimary != NULL) {
ddsPrimary->Release();
ddsPrimary = NULL;
}
pDirectDraw->Release();
pDirectDraw = NULL;
}
if(ddrawDLL != NULL) {
AfxFreeLibrary(ddrawDLL);
ddrawDLL = NULL;
}
width = 0;
height = 0;
}
示例10: DestroyOverlay
//! Releases the overlay surface
void DestroyOverlay()
{
if (g_pClipper)
g_pClipper->Release();
if (g_pDDSOverlay) {
g_pImg = 0; LPDIRECTDRAWSURFACE7 pDDSOverlay(g_pDDSOverlay);
g_pDDSOverlay = NULL;
YIELD_TO_THREAD();
pDDSOverlay->Release(); // be sure nobody uses old value
}
}
示例11:
~WSurfaceData() {
if (clipper) clipper->Release();
if (LeftBuffer) ((LPDIRECTDRAWSURFACE)LeftBuffer)->Release();
if (RightBuffer) ((LPDIRECTDRAWSURFACE)RightBuffer)->Release();
if (screen) screen->Release();
if (ddraw) {
if (!window_mode)
ddraw->RestoreDisplayMode();
ddraw->Release();
}
LeftBuffer=RightBuffer=0;
ddraw=0,screen=0;
}
示例12: DDInitWindowed
int DDInitWindowed(int width, int height, int bpp, HWND hwnd)
{
HRESULT ret;
// create object and test for error
if (DirectDrawCreate(NULL, &lpDD, NULL) != DD_OK) {
return(0);
}
// set cooperation level to windowed mode normal
if (lpDD->SetCooperativeLevel(hwnd, DDSCL_NORMAL) != DD_OK) {
return(0);
}
// set globals
screen_height = height;
screen_width = width;
screen_bpp = bpp;
// Create the primary surface
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
// all we need for windowed mode is access to the primary surface
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
// create the primary surface
ret = lpDD->CreateSurface(&ddsd, &lpDDSPrimary, NULL);
// create an offscreen and system mem back surface
lpDDSBack = DDCreateSurface(width, height, NULL);
lpDD->CreateClipper(0, &lpDDClipper, NULL);
lpDDClipper->SetHWnd(0, hwnd);
lpDDSPrimary->SetClipper(lpDDClipper);
// clear out both primary and secondary surfaces
DDFillSurface(lpDDSPrimary, 0);
DDFillSurface(lpDDSBack, 0);
DDGetRGB16();
return 1;
}
示例13: DDEnd
void DDEnd(void)
{
if (m_pDD)
{
if (m_pddsFrontBuffer != NULL)
{
if (m_pddsFrame) m_pddsFrame->Release();
m_pddsFrame = NULL;
if (pcClipper) pcClipper->Release();
pcClipper = NULL;
if (m_pddsFrontBuffer) m_pddsFrontBuffer->Release();
m_pddsFrontBuffer = NULL;
}
m_pDD->Release();
m_pDD = NULL;
}
}
示例14: 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;
}
示例15:
/**
* vdraw_ddraw_free_all(): Free all DirectDraw objects.
* @param scl If true, sets the cooperative level of lpDD before freeing it.
*/
static void WINAPI vdraw_ddraw_free_all(bool scl)
{
if (lpDDC_Clipper)
{
lpDDC_Clipper->Release();
lpDDC_Clipper = NULL;
}
if (lpDDS_Back)
{
lpDDS_Back->Release();
lpDDS_Back = NULL;
}
if (lpDDS_Flip)
{
lpDDS_Flip->Release();
lpDDS_Flip = NULL;
}
if (lpDDS_Primary)
{
lpDDS_Primary->Release();
lpDDS_Primary = NULL;
}
if (lpDD)
{
if (scl)
lpDD->SetCooperativeLevel(gens_window, DDSCL_NORMAL);
lpDD->Release();
lpDD = NULL;
}
lpDDS_Blit = NULL;
}