本文整理汇总了C++中LPDIRECT3DDEVICE7::SetViewport方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECT3DDEVICE7::SetViewport方法的具体用法?C++ LPDIRECT3DDEVICE7::SetViewport怎么用?C++ LPDIRECT3DDEVICE7::SetViewport使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECT3DDEVICE7
的用法示例。
在下文中一共展示了LPDIRECT3DDEVICE7::SetViewport方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wSetViewport
/// <summary>
/// <c>wSetViewport</c>
/// </summary>
/// <remarks>
/// </remarks>
/// <param name="d3dDevice7"></param>
/// <param name="lpViewport"></param>
/// <returns></returns>
HRESULT __stdcall wSetViewport(
LPDIRECT3DDEVICE7 d3dDevice7, LPD3DVIEWPORT7 lpViewport)
{
PSTR pszErrorMessage;
HRESULT hResult;
InternalFunctionSpew("GameOS_Direct3D", "SetViewport()");
hResult = d3dDevice7->SetViewport(lpViewport);
if (FAILED(hResult))
{
pszErrorMessage = ErrorNumberToMessage(hResult);
if ( InternalFunctionPause("FAILED (0x%x - %s) - SetViewport()", hResult, pszErrorMessage) )
ENTER_DEBUGGER;
}
return hResult;
}
示例2: 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
}