本文整理汇总了C++中LPDIRECTDRAW7::QueryInterface方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECTDRAW7::QueryInterface方法的具体用法?C++ LPDIRECTDRAW7::QueryInterface怎么用?C++ LPDIRECTDRAW7::QueryInterface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECTDRAW7
的用法示例。
在下文中一共展示了LPDIRECTDRAW7::QueryInterface方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FindDevice
LPGUID CRMEngine::FindDevice(int BPP, LPGUID OUT guid)
{
#if DIRECTDRAW_VERSION >= CDX_DDVER
LPDIRECTDRAW7 lpDD;
#else
LPDIRECTDRAW lpDD;
#endif
LPDIRECT3D lpD3D;
D3DFINDDEVICESEARCH devSearch;
static D3DFINDDEVICERESULT devResult;
HRESULT error;
CDXLOG("START: CRMEngine::FindDevice");
CDXLOG("Get the DirectDraw Object from the Screen");
// get the DirectDraw object
lpDD = m_Screen->GetDD();
if (lpDD==NULL) return NULL;
CDXLOG("QueryInterface for a IDirect3D interface");
if(lpDD->QueryInterface(IID_IDirect3D, (void**)&lpD3D)) {
return NULL;
}
ZeroMemory(&devSearch, sizeof(devSearch));
devSearch.dwSize = sizeof(devSearch);
devSearch.dwFlags = D3DFDS_COLORMODEL;
devSearch.dcmColorModel = D3DCOLOR_RGB;
// Julien Cugniere reported we needed this line to enable hardware support for the engine
// added by: MICHAELR
devSearch.bHardware = TRUE;
devSearch.dwFlags |= D3DFDS_HARDWARE;
ZeroMemory(&devResult, sizeof(devResult));
devResult.dwSize = sizeof(devResult);
CDXLOG("Attempt to FindDevice");
error = lpD3D->FindDevice(&devSearch, &devResult);
if(error != DD_OK) {
CDXLOG("FindDevice Failed");
if(devResult.ddHwDesc.dwFlags &&
!(devResult.ddHwDesc.dwDeviceRenderBitDepth & bppToDbd(BPP))) {
devSearch.dwFlags |= D3DFDS_HARDWARE;
devSearch.bHardware = FALSE;
ZeroMemory(&devResult, sizeof(devResult));
devResult.dwSize = sizeof(devResult);
CDXLOG("Do a software FindDevice search");
// do a software search now
error = lpD3D->FindDevice(&devSearch, &devResult);
}
}
CDXLOG("Release the IDirect3D interface");
lpD3D->Release();
CDXLOG("END: CRMEngine::FindDevice");
if(error==DD_OK)
{
CDXLOG("Copy Device GUID into Out Buffer");
// copy the guid into the out buffer
memcpy(guid, &devResult.guid, sizeof(GUID));
return guid;
}
else
return NULL;
}
示例2: 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;
}
示例3: Prog_Init
//////////////////////////////////////////////////////////////////////////////
//INITIALIZATION
//////////////////////////////////////////////////////////////////////////////
bool Prog_Init()
{
lpdd=LPDD_Create(hWndMain,DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_ALLOWREBOOT);
//set the display mode
lpdd->SetDisplayMode(SCREENWIDTH,SCREENHEIGHT,SCREENBPP,0,0);
//create primary surface
DDSURFACEDESC2 ddsd;
memset(&ddsd,0,sizeof(DDSURFACEDESC2));
ddsd.dwSize=sizeof(DDSURFACEDESC2);
ddsd.dwFlags=DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.dwBackBufferCount=1;
ddsd.ddsCaps.dwCaps=DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX | DDSCAPS_3DDEVICE;
lpdd->CreateSurface(&ddsd,&lpddsPrime,NULL);
//create back buffer
DDSCAPS2 ddscaps;
memset(&ddscaps,0,sizeof(DDSCAPS2));
ddscaps.dwCaps=DDSCAPS_BACKBUFFER | DDSCAPS_3DDEVICE;
lpddsPrime->GetAttachedSurface(&ddscaps,&lpddsBack);
//create the texture surface
memset(&ddsd,0,sizeof(DDSURFACEDESC2));
ddsd.dwSize=sizeof(DDSURFACEDESC2);
ddsd.dwFlags=DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.dwWidth=64;
ddsd.dwHeight=64;
ddsd.ddsCaps.dwCaps=DDSCAPS_TEXTURE;
lpdd->CreateSurface(&ddsd,&lpddsTex,NULL);
//used ddfuncs to load a bitmap onto the texture
LPDDS_ReloadFromFile(lpddsTex,"texture.bmp");
//get the idirect3d pointer
lpdd->QueryInterface(IID_IDirect3D7,(void**)&lpd3d);//ICKY COM STUFF!
//create the idirect3ddevice(hack method)
if(FAILED(lpd3d->CreateDevice(IID_IDirect3DTnLHalDevice,lpddsBack,&lpd3ddev)))//try tnl
if(FAILED(lpd3d->CreateDevice(IID_IDirect3DHALDevice,lpddsBack,&lpd3ddev)))//no tnl, try hal
if(FAILED(lpd3d->CreateDevice(IID_IDirect3DMMXDevice,lpddsBack,&lpd3ddev)))//no hal, try mmp
if(FAILED(lpd3d->CreateDevice(IID_IDirect3DRGBDevice,lpddsBack,&lpd3ddev)))//no mmx, resort to rgb
return(false);//problem, return false
//set up viewport
D3DVIEWPORT7 vp;
vp.dwX=0;
vp.dwY=0;
vp.dwWidth=SCREENWIDTH;
vp.dwHeight=SCREENHEIGHT;
vp.dvMinZ=0.0;
vp.dvMaxZ=1.0;
//set viewport for device
lpd3ddev->SetViewport(&vp);
//initialize the vertices(partially, anyway)
vert[0].color=D3DRGB(0.25,0.25,0.25);//set the color for this vertex
vert[0].specular=0;//zero for specular
vert[0].rhw=1.0;//rhw is 1.0
vert[0].tu=0.0;//0.0 for both texture coordinates
vert[0].tv=0.0;
vert[0].sz=0.5;//static z value
vert[1].color=D3DRGB(0.5,0.5,0.5);//set the color for this vertex
vert[1].specular=0;//zero for specular
vert[1].rhw=1.0;//rhw is 1.0
vert[1].tu=1.0;//0.0 for both texture coordinates
vert[1].tv=0.0;
vert[1].sz=0.5;//static z value
vert[2].color=D3DRGB(0.5,0.5,0.5);//set the color for this vertex
vert[2].specular=0;//zero for specular
vert[2].rhw=1.0;//rhw is 1.0
vert[2].tu=0.0;//0.0 for both texture coordinates
vert[2].tv=1.0;
vert[2].sz=0.5;//static z value
vert[3].color=D3DRGB(1.0,1.0,1.0);//set the color for this vertex
vert[3].specular=0;//zero for specular
vert[3].rhw=1.0;//rhw is 1.0
vert[3].tu=1.0;//0.0 for both texture coordinates
vert[3].tv=1.0;
vert[3].sz=0.5;//static z value
//set the texture
lpd3ddev->SetTexture(0,lpddsTex);
return(true);//return success
}