本文整理汇总了C++中LPDIRECTDRAW7::Release方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECTDRAW7::Release方法的具体用法?C++ LPDIRECTDRAW7::Release怎么用?C++ LPDIRECTDRAW7::Release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECTDRAW7
的用法示例。
在下文中一共展示了LPDIRECTDRAW7::Release方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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
示例3: Game_Shutdown
int Game_Shutdown(void *parms = NULL, int num_parms = 0)
{
// this is called after the game is exited and the main event
// loop while is exited, do all you cleanup and shutdown here
// kill all the surfaces
// first the palette
if (lpddpal)
{
lpddpal->Release();
lpddpal = NULL;
} // end if
// now the primary surface
if (lpddsprimary)
{
lpddsprimary->Release();
lpddsprimary = NULL;
} // end if
// now blow away the IDirectDraw4 interface
if (lpdd)
{
lpdd->Release();
lpdd = NULL;
} // end if
// return success or failure or your own return code here
return(1);
} // end Game_Shutdown
示例4: DDEnumCallback
BOOL WINAPI DDEnumCallback( GUID *pGUID, LPSTR pDescription, LPSTR strName,
LPVOID pContext )
{
LPDIRECTDRAW7 pDD = NULL;
HRESULT hr;
if( FAILED( hr = DirectDrawCreateEx( pGUID, (VOID**)&pDD,
IID_IDirectDraw7, NULL ) ) )
return DDENUMRET_CANCEL;
pDD->GetDeviceIdentifier( &DeviceInfo[g_iMaxDevices], 0 );
if(pDD) {
pDD->Release();
pDD = NULL;
}
if( g_iMaxDevices < MAX_DEVICES )
g_iMaxDevices++;
else
return DDENUMRET_CANCEL;
return DDENUMRET_OK;
}
示例5: ShutDown
//-----------------------------------------------------------------------------
// Name: ShutDown()
// Desc: cleans up evreything. releases mem used
//-----------------------------------------------------------------------------
int ShutDown()
{
// now release the primary surface
if (lpddsPrimary!=NULL)
lpddsPrimary->Release();
// release the directdraw object
if (lpddObj!=NULL)
lpddObj->Release();
return(1);
}
示例6: CleanUp
void CleanUp()
{
g_surfCar.Destroy();
if(g_pDDSBack)
g_pDDSBack->Release();
if(g_pDDSFront)
g_pDDSFront->Release();
if(g_pDD)
g_pDD->Release();
}
示例7: Game_Shutdown
int Game_Shutdown(void *parms = NULL, int num_parms = 0)
{
// this is called after the game is exited and the main event
// loop while is exited, do all you cleanup and shutdown here
// first the palette
if (lpddpal)
{
lpddpal->Release();
lpddpal = NULL;
} // end if
// now the lpddsbackground surface
if (lpddsbackground)
{
lpddsbackground->Release();
lpddsbackground = NULL;
} // end if
// now the lpddsback surface
if (lpddsback)
{
lpddsback->Release();
lpddsback = NULL;
} // end if
// now the primary surface
if (lpddsprimary)
{
lpddsprimary->Release();
lpddsprimary = NULL;
} // end if
// now blow away the IDirectDraw4 interface
if (lpdd)
{
lpdd->Release();
lpdd = NULL;
} // end if
// unload the bitmap file, we no longer need it
Unload_Bitmap_File(&bitmap);
// return success or failure or your own return code here
return(1);
} // end Game_Shutdown
示例8: Game_Shutdown
int Game_Shutdown(void *parms = NULL, int num_parms = 0)
{
// this is called after the game is exited and the main event
// loop while is exited, do all you cleanup and shutdown here
// simply blow away the IDirectDraw4 interface
if (lpdd)
{
lpdd->Release();
lpdd = NULL;
} // end if
// return success or failure or your own return code here
return(1);
} // end Game_Shutdown
示例9: 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;
}
}
示例10:
/**
* 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;
}
示例11: Game_Shutdown
int Game_Shutdown(void *parms = NULL, int num_parms = 0)
{
// this is called after the game is exited and the main event
// loop while is exited, do all you cleanup and shutdown here
MessageBox(main_window_handle,
"game shutdown...",
"game shutdown...",
MB_OK | MB_ICONEXCLAMATION );
if (lpddsprimary)
{
lpddsprimary->Release();
lpddsprimary = NULL;
}
// simply blow away the IDirectDraw4 interface
if (lpdd)
{
lpdd->Release();
lpdd = NULL;
} // end if
if (g_ddStepFailure != DDSF_OK)
{
ostrstream txtout;
txtout << "Critical Error in DirectX initialization!"
<< "(";
switch (g_ddStepFailure)
{
case DDSF_DDACCESS:
{
txtout <<"DDSF_DDACCESS";
}
break;
case DDSF_DDPALETTECREATE:
{
txtout <<"DDSF_DDPALETTECREATE";
}
break;
case DDSF_DDPALETTEATTACH:
{
txtout <<"DDSF_DDPALETTEATTACH";
}
break;
case DDSF_SURFACECREATE:
{
txtout <<"DDSF_SURFACECREATE";
}
break;
case DDSF_CLIPPERCREATE:
{
txtout <<"DDSF_CLIPPERCREATE";
}
break;
case DDSF_SETDISPLAYMODE:
{
txtout <<"DDSF_SETDISPLAYMODE";
}
break;
default:
{
txtout <<"DDSF_UNKNOWN";
}
break;
}
txtout << ")"
<< ends;
MessageBox(main_window_handle,
txtout.str(),
"Critical Error in DirectX initialization, application is now ending!",
MB_OK | MB_ICONEXCLAMATION );
txtout.freeze(0);
}
delete [] colors16;
// return success or failure or your own return code here
return(1);
} // end Game_Shutdown
示例12: DriverEnumCallback
//************************************************************************************
// DriverEnumCallback()
// Callback function for enumerating drivers.
//************************************************************************************
static BOOL WINAPI DriverEnumCallback(GUID * pGUID, TCHAR * strDesc,
TCHAR * strName, VOID *, HMONITOR)
{
D3DEnum_DeviceInfo d3dDeviceInfo;
LPDIRECTDRAW7 pDD;
LPDIRECT3D7 pD3D;
HRESULT hr;
// Use the GUID to create the DirectDraw object
hr = DirectDrawCreateEx(pGUID, (VOID **)&pDD, IID_IDirectDraw7, NULL);
if (FAILED(hr))
{
DEBUG_MSG(_T("Can't create DDraw during enumeration!"));
return D3DENUMRET_OK;
}
// Create a D3D object, to enumerate the d3d devices
hr = pDD->QueryInterface(IID_IDirect3D7, (VOID **)&pD3D);
if (FAILED(hr))
{
pDD->Release();
DEBUG_MSG(_T("Can't query IDirect3D7 during enumeration!"));
return D3DENUMRET_OK;
}
// Copy data to a device info structure
ZeroMemory(&d3dDeviceInfo, sizeof(d3dDeviceInfo));
lstrcpyn(d3dDeviceInfo.strDesc, strDesc, 39);
d3dDeviceInfo.ddDriverCaps.dwSize = sizeof(DDCAPS);
d3dDeviceInfo.ddHELCaps.dwSize = sizeof(DDCAPS);
pDD->GetCaps(&d3dDeviceInfo.ddDriverCaps, &d3dDeviceInfo.ddHELCaps);
if (pGUID)
{
d3dDeviceInfo.guidDriver = (*pGUID);
d3dDeviceInfo.pDriverGUID = &d3dDeviceInfo.guidDriver;
}
// Record whether the device can render into a desktop window
if (d3dDeviceInfo.ddDriverCaps.dwCaps2 & DDCAPS2_CANRENDERWINDOWED)
if (NULL == d3dDeviceInfo.pDriverGUID)
d3dDeviceInfo.bDesktopCompatible = TRUE;
// Enumerate the fullscreen display modes.
pDD->EnumDisplayModes(0, NULL, &d3dDeviceInfo, ModeEnumCallback);
// Sort list of display modes
qsort(d3dDeviceInfo.pddsdModes, d3dDeviceInfo.dwNumModes,
sizeof(DDSURFACEDESC2), SortModesCallback);
// Now, enumerate all the 3D devices
pD3D->EnumDevices(DeviceEnumCallback, &d3dDeviceInfo);
// Clean up and return
SAFE_DELETE(d3dDeviceInfo.pddsdModes);
pD3D->Release();
pDD->Release();
return DDENUMRET_OK;
}
示例13: CleanUpDDraw
void CleanUpDDraw()
{
logOutput << CurrentTimeString() << "Cleaning up" << endl;
if (copyData)
copyData->lastRendered = -1;
if (hCopyThread)
{
bKillThread = true;
SetEvent(hCopyEvent);
if (WaitForSingleObject(hCopyThread, 500) != WAIT_OBJECT_0)
TerminateThread(hCopyThread, -1);
CloseHandle(hCopyThread);
CloseHandle(hCopyEvent);
hCopyThread = NULL;
hCopyEvent = NULL;
}
ddrawSurfaceRelease.Unhook();
for (int i = 0; i < NUM_BUFFERS; i++)
{
if (ddCaptures[i])
{
ddCaptures[i]->Release();
ddCaptures[i] = NULL;
}
}
ddrawSurfaceRelease.Rehook();
DestroySharedMemory();
bHasTextures = false;
curCapture = 0;
curCPUTexture = 0;
keepAliveTime = 0;
resetCount++;
copyWait = 0;
lastTime = 0;
g_frontSurface = NULL;
g_bUseFlipMethod = false;
bTargetAcquired = false;
g_dwSize = 0;
g_bUse32bitCapture = false;
g_bConvert16to32 = false;
g_bUsePalette = false;
g_dwCaptureSize = 0;
if (g_ddInterface)
{
g_ddInterface->Release();
g_ddInterface = NULL;
}
g_CurrentPalette.Free();
if (g_surfaceDesc)
delete g_surfaceDesc;
g_surfaceDesc = NULL;
if (ddUnlockFctMutex)
{
CloseHandle(ddUnlockFctMutex);
ddUnlockFctMutex = 0;
}
//UnhookAll();
logOutput << CurrentTimeString() << "---------------------- Cleared DirectDraw Capture ----------------------" << endl;
}
示例14: CopyBitmapToSurface
HRESULT CTextureHolder::CopyBitmapToSurface(){
// Get a DDraw object to create a temporary surface
LPDIRECTDRAW7 pDD;
m_pddsSurface->GetDDInterface( (VOID**)&pDD );
// Get the bitmap structure (to extract width, height, and bpp)
BITMAP bm;
GetObject( m_hbmBitmap, sizeof(BITMAP), &bm );
// Setup the new surface desc
DDSURFACEDESC2 ddsd;
ddsd.dwSize = sizeof(ddsd);
m_pddsSurface->GetSurfaceDesc( &ddsd );
ddsd.dwFlags = DDSD_CAPS|DDSD_HEIGHT|DDSD_WIDTH|DDSD_PIXELFORMAT|
DDSD_TEXTURESTAGE;
ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE|DDSCAPS_SYSTEMMEMORY;
ddsd.ddsCaps.dwCaps2 = 0L;
ddsd.dwWidth = bm.bmWidth;
ddsd.dwHeight = bm.bmHeight;
// Create a new surface for the texture
LPDIRECTDRAWSURFACE7 pddsTempSurface;
HRESULT hr;
if( FAILED( hr = pDD->CreateSurface( &ddsd, &pddsTempSurface, NULL ) ) )
{
pDD->Release();
return hr;
}
// Get a DC for the bitmap
HDC hdcBitmap = CreateCompatibleDC( NULL );
if( NULL == hdcBitmap )
{
pddsTempSurface->Release();
pDD->Release();
return hr; // bug? return E_FAIL?
}
SelectObject( hdcBitmap, m_hbmBitmap );
// Handle palettized textures. Need to attach a palette
if( ddsd.ddpfPixelFormat.dwRGBBitCount == 8 )
{
LPDIRECTDRAWPALETTE pPalette;
DWORD dwPaletteFlags = DDPCAPS_8BIT|DDPCAPS_ALLOW256;
DWORD pe[256];
WORD wNumColors = GetDIBColorTable( hdcBitmap, 0, 256, (RGBQUAD*)pe );
// Create the color table
for( WORD i=0; i<wNumColors; i++ )
{
pe[i] = RGB( GetBValue(pe[i]), GetGValue(pe[i]), GetRValue(pe[i]) );
// Handle textures with transparent pixels
if( m_dwFlags & (D3DTEXTR_TRANSPARENTWHITE|D3DTEXTR_TRANSPARENTBLACK) )
{
// Set alpha for opaque pixels
if( m_dwFlags & D3DTEXTR_TRANSPARENTBLACK )
{
if( pe[i] != 0x00000000 )
pe[i] |= 0xff000000;
}
else if( m_dwFlags & D3DTEXTR_TRANSPARENTWHITE )
{
if( pe[i] != 0x00ffffff )
pe[i] |= 0xff000000;
}
}
}
// Add DDPCAPS_ALPHA flag for textures with transparent pixels
if( m_dwFlags & (D3DTEXTR_TRANSPARENTWHITE|D3DTEXTR_TRANSPARENTBLACK) )
dwPaletteFlags |= DDPCAPS_ALPHA;
// Create & attach a palette
pDD->CreatePalette( dwPaletteFlags, (PALETTEENTRY*)pe, &pPalette, NULL );
pddsTempSurface->SetPalette( pPalette );
m_pddsSurface->SetPalette( pPalette );
SAFE_RELEASE( pPalette );
}
// Copy the bitmap image to the surface.
HDC hdcSurface;
if( SUCCEEDED( pddsTempSurface->GetDC( &hdcSurface ) ) )
{
BitBlt( hdcSurface, 0, 0, bm.bmWidth, bm.bmHeight, hdcBitmap, 0, 0,
SRCCOPY );
pddsTempSurface->ReleaseDC( hdcSurface );
}
DeleteDC( hdcBitmap );
// Copy the temp surface to the real texture surface
m_pddsSurface->Blt( NULL, pddsTempSurface, NULL, DDBLT_WAIT, NULL );
// Done with the temp surface
pddsTempSurface->Release();
// For textures with real alpha (not palettized), set transparent bits
if( ddsd.ddpfPixelFormat.dwRGBAlphaBitMask )
{
if( m_dwFlags & (D3DTEXTR_TRANSPARENTWHITE|D3DTEXTR_TRANSPARENTBLACK) )
//.........这里部分代码省略.........
示例15: D3DM_InitDevices
int D3DM_InitDevices( HWND hwnd, int w, int h, int full, HMENU menu )
{
char buf[256];
int i,j;
LPDIRECTDRAW7 pDD = NULL;
HRESULT hr;
if( FAILED( hr = DirectDrawCreateEx( NULL, (VOID**)&pDD, IID_IDirectDraw7, NULL ) ) )
return DDENUMRET_CANCEL;
D3DCapsStruct.m_ddCaps.dwSize = sizeof(DDCAPS);
pDD->GetCaps( &D3DCapsStruct.m_ddCaps, NULL );
if(pDD) {
pDD->Release();
pDD = NULL;
}
ZeroMemory( d3dTexture, sizeof(D3DD_TEXTURE)*D3DD_MAX_TEXTURE_AMOUNT );
ZeroMemory( d3dText, sizeof(D3DD_TEXT)*D3DD_MAX_TEXT_AMOUNT );
ZeroMemory( d3dDisp, sizeof(D3DD_DISP)*D3DD_MAX_DISP_AMOUNT );
pD3D = Direct3DCreate8(D3D_SDK_VERSION);
if(pD3D == NULL){
MessageBox(NULL,"Direct3Dオブジェクトの生成に失敗しました。[DirectX8.1が入っていない?]","致命的なエラー", MB_OK | MB_ICONSTOP);
return FALSE;
}
if( FAILED(pD3D->GetDeviceCaps( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &D3DCapsStruct.m_d3dCaps)) ){
MessageBox(NULL,"デバイス能力の取得に失敗しました","致命的なエラー", MB_OK | MB_ICONSTOP);
return FALSE;
}
EnumAdapters(D3DADAPTER_DEFAULT);
if( (int)D3DCapsStruct.m_d3dCaps.MaxTextureWidth < D3DD_TEXTURE_CONTROL_SIZE ){
DebugBox( NULL, "このビデオカードは、幅 %d pixel 以上のサイズのテクスチャを生成できません。[%s]", D3DD_TEXTURE_CONTROL_SIZE);
return FALSE;
}else if( (int)D3DCapsStruct.m_d3dCaps.MaxTextureHeight < D3DD_TEXTURE_CONTROL_SIZE ){
DebugBox( NULL, "このビデオカードは、高さ %d pixel 以上のサイズのテクスチャを生成できません。[%s]", D3DD_TEXTURE_CONTROL_SIZE );
return FALSE;
}
if( !(D3DCapsStruct.m_d3dCaps.ShadeCaps&D3DPSHADECAPS_ALPHAGOURAUDBLEND) ){
MessageBox(NULL,"このビデオデバイスはグーロブレンディングに対応していません。\nゲームの画像が乱れることがあります","警告", MB_OK | MB_ICONSTOP);
}
if( !(D3DCapsStruct.m_d3dCaps.ShadeCaps&D3DPSHADECAPS_COLORGOURAUDRGB) ){
MessageBox(NULL,"このビデオデバイスはグーロシェーディングに対応していません。\nゲームの画像が乱れることがあります","警告", MB_OK | MB_ICONSTOP);
}
if( D3DCapsStruct.m_d3dCaps.TextureCaps&D3DPTEXTURECAPS_SQUAREONLY ){
DebugBox( NULL, "このビデオカードは長方形テクスチャを生成できません。[デバッグ用ダイアログ]" );
}
if( FAILED(pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT,&D3DCapsStruct.m_NowDisplayMode)) ){
MessageBox(NULL,"ディスプレイモードの取得に失敗しました。[なにゆえ?]","致命的なエラー", MB_OK | MB_ICONSTOP);
return FALSE;
}
D3DCapsStruct.m_WindowDisplayMode = D3DCapsStruct.m_NowDisplayMode;
D3DMain.m_DrawHwnd = hwnd;
D3DMain.m_MenuHwnd = menu;
if( GetSystemMetrics(SM_CXFULLSCREEN)<=800 || GetSystemMetrics(SM_CYFULLSCREEN)<=600){
D3DMain.m_FullScreenOnly = TRUE;
D3DMain.m_WindowMode = FALSE;
}else{
D3DMain.m_FullScreenOnly = FALSE;
D3DMain.m_WindowMode = !full;
}
ZeroMemory(&d3dppApp,sizeof(d3dppApp));
WinWidth = w;
WinHeight = h;
d3dppApp.SwapEffect = D3DSWAPEFFECT_COPY;
d3dppApp.BackBufferFormat = D3DCapsStruct.m_NowDisplayMode.Format;
d3dppApp.BackBufferCount = 1;
d3dppApp.BackBufferWidth = WinWidth;
d3dppApp.BackBufferHeight = WinHeight;
d3dppApp.Windowed = TRUE;
d3dppApp.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
HRESULT ret;
ret = pD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hwnd,D3DCREATE_HARDWARE_VERTEXPROCESSING,&d3dppApp,&pD3DDevice);
if( FAILED(ret) ){
ret = pD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hwnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&d3dppApp,&pD3DDevice);
//.........这里部分代码省略.........