本文整理汇总了C++中LPDIRECTDRAW类的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECTDRAW类的具体用法?C++ LPDIRECTDRAW怎么用?C++ LPDIRECTDRAW使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LPDIRECTDRAW类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DDEnumDevCallback
BOOL WINAPI DDEnumDevCallback(GUID FAR *lpGUID, LPSTR lpDriverDescription, LPSTR lpDriverName, LPVOID lpContext, HMONITOR hm)
{
LPDIRECTDRAW ddp;
LPDIRECTDRAW4 dd4p;
DDDEVICEIDENTIFIER ddDev;
BOOL ret = FALSE;
if (DirectDrawCreate(lpGUID,&ddp,0) == DD_OK)
{
if(ddp->QueryInterface(IID_IDirectDraw4,(void **)&dd4p) == S_OK)
{
ZeroMemory(&ddDev,sizeof(ddDev));
if(GetDeviceIdentifierEx(dd4p,&ddDev, DDGDI_GETHOSTIDENTIFIER) == DD_OK)
{
// add to table
USES_CONVERSION;
CUtilGPU::AddDisplayDevice(A2CT(lpDriverName), ddDev.dwVendorId, ddDev.dwDeviceId, ddDev.szDescription, ddDev.szDriver);
ret = TRUE;
}
dd4p->Release();
}
ddp->Release();
}
return ret;
}
示例2: DirectDrawCreate
HRESULT CUtilGPU::QueryVideoMemorySize(DWORD dwCaps, DWORD* pdwTotalMem, DWORD* pdwFreeMem)
{
LPDIRECTDRAW lpdd = NULL;
HRESULT hr = DirectDrawCreate(NULL, &lpdd, NULL);
if(SUCCEEDED(hr))
{
LPDIRECTDRAW7 lpdd7 = NULL;
hr = lpdd->QueryInterface(IID_IDirectDraw7, (LPVOID*)&lpdd7);
if(SUCCEEDED(hr))
{
DDSCAPS2 ddsCaps2;
DWORD dwTotal=0, dwFree=0;
// Initialize the structure.
ZeroMemory(&ddsCaps2, sizeof(ddsCaps2));
ddsCaps2.dwCaps = dwCaps;
hr = lpdd7->GetAvailableVidMem(&ddsCaps2, &dwTotal, &dwFree);
if(SUCCEEDED(hr))
{
if(pdwTotalMem)
*pdwTotalMem =(dwTotal>>20); //rounded to MB
if(pdwFreeMem)
*pdwFreeMem = (dwFree>>20); //rounded to MB
}
lpdd7->Release();
}
lpdd->Release();
}
return hr;
}
示例3: win32ddraw_init
static vmResult win32ddraw_init(void)
{
LPDIRECTDRAW oldDraw;
int ret;
int x;
if (!win_registerDirectDrawWindowClass(myHInst, myHPreInst) ||
!win_createDirectDrawWindows(myHInst, mynCmdShow))
return vmInternalError;
// log("init\n");
for (x=0; x<16; x++)
win_rgbmap[x]=x;
win_rgbmap[16] = 15;
/* DirectDraw initialization */
ret = DirectDrawCreate((GUID *)NULL, &oldDraw, NULL);
if (ret != DD_OK)
DDFAIL("DirectDrawCreate", ret);
if (!SUCCEEDED(oldDraw->QueryInterface(IID_IDirectDraw2,
reinterpret_cast<void**>(&lpDD))))
DDFAIL("QueryInterface", -1);
// --
features|=FE_SHOWVIDEO|FE_VIDEO;
return vmOk;
}
示例4: 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;
}
示例5:
~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;
}
示例6: GetVideoMemoryViaDirectDraw
//-----------------------------------------------------------------------------
HRESULT GetVideoMemoryViaDirectDraw( HMONITOR hMonitor, DWORD* pdwAvailableVidMem )
{
LPDIRECTDRAW pDDraw = nullptr;
LPDIRECTDRAWENUMERATEEXA pDirectDrawEnumerateEx = nullptr;
HRESULT hr;
bool bGotMemory = false;
*pdwAvailableVidMem = 0;
HINSTANCE hInstDDraw;
LPDIRECTDRAWCREATE pDDCreate = nullptr;
hInstDDraw = LoadLibrary( L"ddraw.dll" );
if( hInstDDraw )
{
DDRAW_MATCH match = {};
match.hMonitor = hMonitor;
pDirectDrawEnumerateEx = ( LPDIRECTDRAWENUMERATEEXA )GetProcAddress( hInstDDraw, "DirectDrawEnumerateExA" );
if( pDirectDrawEnumerateEx )
{
hr = pDirectDrawEnumerateEx( DDEnumCallbackEx, ( VOID* )&match, DDENUM_ATTACHEDSECONDARYDEVICES );
}
pDDCreate = ( LPDIRECTDRAWCREATE )GetProcAddress( hInstDDraw, "DirectDrawCreate" );
if( pDDCreate )
{
pDDCreate( &match.guid, &pDDraw, nullptr );
LPDIRECTDRAW7 pDDraw7;
if( SUCCEEDED( pDDraw->QueryInterface( IID_IDirectDraw7, ( VOID** )&pDDraw7 ) ) )
{
DDSCAPS2 ddscaps = {};
ddscaps.dwCaps = DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM;
hr = pDDraw7->GetAvailableVidMem( &ddscaps, pdwAvailableVidMem, nullptr );
if( SUCCEEDED( hr ) )
bGotMemory = true;
pDDraw7->Release();
}
}
FreeLibrary( hInstDDraw );
}
if( bGotMemory )
return S_OK;
else
return E_FAIL;
}
示例7: DDCreateSurface
LPDIRECTDRAWSURFACE DDCreateSurface(int width, int height, int mem_flags)
{
DDSURFACEDESC ddsd; // working description
LPDIRECTDRAWSURFACE lpdds; // temporary surface
// set to access caps, width, and height
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
// set dimensions of the new bitmap surface
ddsd.dwWidth = width;
ddsd.dwHeight = height;
// set surface to offscreen plain
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | mem_flags;
// create the surface
if (lpDD->CreateSurface(&ddsd, &lpdds, NULL) != DD_OK) {
return(NULL);
}
// return surface
return(lpdds);
}
示例8: DDLoadBitmap
/*
* DDLoadBitmap:
* create a DirectDrawSurface from a bitmap resource.
*/
LPDIRECTDRAWSURFACE DDLoadBitmap(LPCSTR szBitmap, int dx, int dy)
{
HBITMAP hbm;
BITMAP bm;
DDSURFACEDESC ddsd;
IDirectDrawSurface *pdds;
hbm = (HBITMAP)LoadImage(NULL, szBitmap, IMAGE_BITMAP, dx, dy, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
if (hbm == NULL) {
return NULL;
}
// get size of the bitmap
GetObject(hbm, sizeof(bm), &bm); // get size of bitmap
// create a DirectDrawSurface for this bitmap
ZeroMemory(&ddsd, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
ddsd.dwWidth = bm.bmWidth;
ddsd.dwHeight = bm.bmHeight;
if (lpDD->CreateSurface(&ddsd, &pdds, NULL) != DD_OK) {
return NULL;
}
DDCopyBitmap(pdds, hbm, 0, 0, 0, 0);
DeleteObject(hbm);
return pdds;
}
示例9: memset
HRESULT
CVWRenderRoot::CreateBackBuffer(LPDIRECTDRAW pdd, int cx, int cy, VARIANT_BOOL bUseHWAcceleration, IDirectDrawSurface **ppddsBackBuffer)
{
DDSURFACEDESC ddsd;
// it would be bad to try and create a zero-sized backbuffer
if (cx <= 0)
cx = 1;
if (cy <= 0)
cy = 1;
// Create a back buffer.
HRESULT hRes;
memset(&ddsd,0,sizeof(DDSURFACEDESC));
ddsd.dwSize = sizeof( ddsd );
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.dwWidth = cx;
ddsd.dwHeight = cy;
if (bUseHWAcceleration)
ddsd.ddsCaps.dwCaps = DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY;
else
ddsd.ddsCaps.dwCaps = DDSCAPS_3DDEVICE | DDSCAPS_SYSTEMMEMORY;
hRes = pdd->CreateSurface( &ddsd, ppddsBackBuffer, NULL );
if (FAILED(hRes))
return hRes;
//
// attach the palette if one exists
//
if (m_pPalette && FAILED(hRes = (*ppddsBackBuffer)->SetPalette(m_pPalette)))
return hRes;
return S_OK;
}
示例10: CreateD3D
// Direct3D 생성
BOOL CreateD3D()
{
// DirectDraw 인터페이스 생성
LPDIRECTDRAW lpdd;
// 설정된 DirectDraw Device
HRESULT hresult = DirectDrawCreate( NULL, &lpdd, NULL );
if ( hresult != DD_OK )
{
MESSAGE( "DirectDrawCreate" );
return FALSE;
}
// DirectDraw2 인터페이스 얻기
hresult = lpdd->QueryInterface( IID_IDirectDraw4, (LPVOID*)&lpDD );
if ( hresult != DD_OK )
{
MESSAGE( "lpdd->QueryInterface" );
return FALSE;
}
// DirectDraw 인터페이스 제거
lpdd->Release();
// Direct3D 인터페이스 얻기
hresult = lpDD->QueryInterface( IID_IDirect3D3, (LPVOID*)&lpD3D );
if ( hresult != DD_OK )
{
MESSAGE( "lpDD3->QueryInterface" );
return FALSE;
}
// Direct3D Device 인터페이스 얻기
hresult = lpD3D->EnumDevices( DeviceEnumCallback, (LPVOID)&lpDeviceDesc );
if ( hresult != DD_OK )
{
MESSAGE( "lpD3D->EnumDevices" );
return FALSE;
}
lpD3DDeviceDesc = FindBestDevice( lpDeviceDesc );
if ( !lpD3DDeviceDesc )
return FALSE;
return TRUE;
}
示例11: Initiate
//------------------------------------------------------------
// Name: Initiate
// Desc: Init everything
//------------------------------------------------------------
int Initiate()
{
// create dd object and test for an error
hr = DirectDrawCreate(NULL,&lpdd,NULL);
if (DDFailedCheck(hr, "DirectDrawCreate failed", cpErrorBuf ))
return 0;
// set cooperation level to windowed mode normal
hr = lpdd->SetCooperativeLevel(main_window_handle, DDSCL_ALLOWMODEX | DDSCL_FULLSCREEN |
DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT );
if (DDFailedCheck(hr, "SetCooperativeLevel", cpErrorBuf ))
return 0;
// set the display mode. use this for full screen programs
hr = lpdd->SetDisplayMode(WINDOW_WIDTH ,WINDOW_HEIGHT,16);
if (DDFailedCheck(hr, "SetDisplayMode", cpErrorBuf ))
return 0;
// Create the primary surface
memset(&ddsd,0,sizeof(ddsd));//clear ddsd structure
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
hr = lpdd->CreateSurface(&ddsd,&lpddsprimary,NULL);
if (DDFailedCheck(hr, "CreateSurface", cpErrorBuf ))
return 0;
// return success
return(1);
}//End Initiate
示例12: rglDDrawActivate
extern "C" DLL void rglDDrawActivate(unsigned char active)
{
HRESULT rval;
if (WINDOWED || lpDD == NULL)
{
return;
}
if (active)
{
if (!bActive)
{
for (;;)
{
rval = lpDD->SetDisplayMode(SCRWIDTH, SCRHEIGHT, 16);
if (rval == DD_OK)
{
break;
}
if (rval == DDERR_SURFACELOST)
{
if (!restoreAll())
{
break;
}
}
}
bActive = TRUE;
}
}
else
{
if (bActive)
{
for (;;)
{
rval = lpDD->RestoreDisplayMode();
if (rval == DD_OK)
{
break;
}
if (rval == DDERR_SURFACELOST)
{
if (!restoreAll())
{
break;
}
}
}
bActive = FALSE;
}
}
}
示例13: DDInitFullscreen
int DDInitFullscreen(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_FULLSCREEN | DDSCL_EXCLUSIVE) != DD_OK) {
return(0);
}
// set the display mode
if (lpDD->SetDisplayMode(width, height, bpp) != 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 | DDSD_BACKBUFFERCOUNT;
// we need to let dd know that we want a complex
// flippable surface structure, set flags for that
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX;
// set the backbuffer count to 1
ddsd.dwBackBufferCount = 1;
// create the primary surface
ret = lpDD->CreateSurface(&ddsd, &lpDDSPrimary, NULL);
// query for the backbuffer i.e the secondary surface
ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
lpDDSPrimary->GetAttachedSurface(&ddscaps, &lpDDSBack);
// clear out both primary and secondary surfaces
DDFillSurface(lpDDSPrimary, 0);
DDFillSurface(lpDDSBack, 0);
DDGetRGB16();
return 1;
}
示例14: InitDDraw
BOOL InitDDraw()
{
DDSURFACEDESC ddsd;
HRESULT ddrval;
DirectDrawCreate(NULL, &lpDD, NULL);//产生一个DDRAW对象。
/*第一个参数是要创建的驱动类型,设为NULL,表示使用当前的显示驱动
第三个参数用于今后与COM对象兼容,目前都设为NULL*/
lpDD->SetCooperativeLevel (hWnd, DDSCL_NORMAL);//设置协作级别
ZeroMemory( &ddsd, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
/*主页面的大小和像素格式都是由当前的显示模式决定的,
所以不能指定,否则发生错误*/
ddsd.ddsCaps .dwCaps = DDSCAPS_PRIMARYSURFACE;
ddrval = lpDD->CreateSurface (&ddsd, &lpDDSPrimary, NULL);
/*第三个参数也是用于与COM对象兼容,目前只能设为NULL*/
if(ddrval != DD_OK)
{
return FALSE;
}
ZeroMemory( &ddsd, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS| DDSD_HEIGHT| DDSD_WIDTH;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
ddsd.dwHeight = 600;
ddsd.dwWidth = 800;
/*页面的大小可以和实际图片大小不一样,但会产生失真*/
RectTemp.left = 0;
RectTemp.top = 0;
RectTemp.right = ddsd.dwWidth;
RectTemp.bottom = ddsd.dwHeight;
lpDD->CreateSurface (&ddsd, &lpDDSTemp, NULL);
if(ddrval != DD_OK)
{
return FALSE;
}
DDReLoadBitmap( lpDDSTemp, "gameover.bmp");
return TRUE;
}
示例15: 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;
}
}