本文整理汇总了C++中LPDIRECT3D9类的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECT3D9类的具体用法?C++ LPDIRECT3D9怎么用?C++ LPDIRECT3D9使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LPDIRECT3D9类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateD3DDevice
void CreateD3DDevice()
{
ZeroMemory( &g_D3DParams, sizeof( g_D3DParams ) );
RECT ClientRect;
GetClientRect( g_pHWND, &ClientRect );
g_D3DParams.Windowed = TRUE;
g_D3DParams.SwapEffect = D3DSWAPEFFECT_DISCARD;
g_D3DParams.BackBufferWidth = ClientRect.right;
g_D3DParams.BackBufferHeight = ClientRect.bottom;
g_D3DParams.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
g_D3DParams.BackBufferFormat = D3DFMT_X8R8G8B8;
//g_D3DParams.EnableAutoDepthStencil = TRUE;
//g_D3DParams.AutoDepthStencilFormat = D3DFMT_D24S8;
g_D3DParams.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
HRESULT hr = g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, g_pHWND, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &g_D3DParams, &g_pD3DDevice );
if ( FAILED(hr) )
{
OutputDebugString( DXGetErrorDescription( hr ) );
return;
}
}
示例2: InitD3D
//-----------------------------------------------------------------------------
// Name: InitD3D()
// Desc: Initializes Direct3D
//-----------------------------------------------------------------------------
HRESULT InitD3D( HWND hWnd )
{
// Create the D3D object.
if( NULL == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
return E_FAIL;
// Set up the structure used to create the D3DDevice. Since we are now
// using more complex geometry, we will create a device with a zbuffer.
D3DPRESENT_PARAMETERS d3dpp;
//ZeroMemory( &d3dpp, sizeof( d3dpp ) );
vp_os_memset(&d3dpp, 0, sizeof( d3dpp ));
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
// Create the D3DDevice
if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp, &g_pd3dDevice ) ) )
{
return E_FAIL;
}
// Turn off culling
g_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
// Turn off D3D lighting
g_pd3dDevice->SetRenderState( D3DRS_LIGHTING, FALSE );
// Turn on the zbuffer
g_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
return S_OK;
}
示例3: InitD3D
HRESULT InitD3D( HWND hWnd )
{
// Create the D3D object, which is needed to create the D3DDevice.
if( NULL == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
{
MessageBoxA(NULL, "Create D3D9 object failed!", "Error", 0) ;
return E_FAIL;
}
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory( &d3dpp, sizeof(d3dpp) );
d3dpp.Windowed = TRUE; // use window mode, not full screen
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
// Create device
if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp, &g_pd3dDevice ) ) )
{
MessageBoxA(NULL, "Create D3D9 device failed!", "Error", 0) ;
return E_FAIL;
}
// Disable lighting, since we didn't specify color for vertex
g_pd3dDevice->SetRenderState( D3DRS_LIGHTING , FALSE );
// Create teapot
D3DXCreateTeapot(g_pd3dDevice, &g_pMesh, NULL) ;
// Create camera
g_Camera = new FirstPersonViewCamera() ;
return S_OK;
}
示例4: Cleanup
void Cleanup()
{
if (g_pMeshMaterials)
delete[] g_pMeshMaterials;
if (g_pMeshTextures)
{
for (DWORD i = 0; i < g_dwNumMaterials; i++)
{
if (g_pMeshTextures[i])
g_pMeshTextures[i]->Release();
}
delete[] g_pMeshTextures;
}
if (g_pMesh)
g_pMesh->Release();
if (g_pd3dDevice)
g_pd3dDevice->Release();
if (g_pD3D)
g_pD3D->Release();
}
示例5: initD3D
///Create Direct3D Device
HRESULT initD3D(HWND hWnd){
if(NULL == (g_pD3D = Direct3DCreate9(D3D_SDK_VERSION)))
return E_FAIL;
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory(&d3dpp, sizeof(D3DPRESENT_PARAMETERS));
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
D3DCREATE_HARDWARE_VERTEXPROCESSING,
&d3dpp, &g_pDevice ) ) ){
return E_FAIL;
}
g_pDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
g_pDevice->SetRenderState(D3DRS_ZENABLE, TRUE);//default is open
setupViewProjMatrix();
return S_OK;
}
示例6: initD3D
// this function initializes and prepares Direct3D for use
void initD3D(HWND hWnd)
{
d3d = Direct3DCreate9(D3D_SDK_VERSION);
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory(&d3dpp, sizeof(d3dpp));
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.hDeviceWindow = hWnd;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
d3dpp.BackBufferWidth = SCREEN_WIDTH;
d3dpp.BackBufferHeight = SCREEN_HEIGHT;
// create a device class using this information and the info from the d3dpp stuct
d3d->CreateDevice(D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
hWnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp,
&d3ddev);
init_graphics(); // call the function to initialize the triangle
}
示例7: Cleanup
//-----------------------------------------------------------------------------
// Name: Cleanup()
// Desc: Releases all previously initialized objects
//-----------------------------------------------------------------------------
VOID Cleanup()
{
// release all textures used
if ( g_pTexture != NULL )
g_pTexture->Release();
if ( g_pTexture2 != NULL )
g_pTexture2->Release();
if ( marbleTexture != NULL )
marbleTexture->Release();
if ( backgroundTexture != NULL )
backgroundTexture->Release();
if( g_pMeshMaterials != NULL )
delete[] g_pMeshMaterials;
if( g_pMeshTextures )
{
for( DWORD i = 0; i < g_dwNumMaterials; i++ )
{
if( g_pMeshTextures[i] )
g_pMeshTextures[i]->Release();
}
delete[] g_pMeshTextures;
}
if( g_pMesh != NULL )
g_pMesh->Release();
if( g_pd3dDevice != NULL )
g_pd3dDevice->Release();
if( g_pD3D != NULL )
g_pD3D->Release();
}
示例8: Direct3D_Init
bool Direct3D_Init(HWND window, int width, int height, bool fullscreen)
{
//initialize Direct3D
d3d = Direct3DCreate9(D3D_SDK_VERSION);
if (!d3d) return false;
//set Direct3D presentation parameters
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory(&d3dpp, sizeof(d3dpp));
d3dpp.hDeviceWindow = window;
d3dpp.Windowed = (!fullscreen);
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.EnableAutoDepthStencil = 1;
d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;
d3dpp.Flags = D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL;
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
d3dpp.BackBufferCount = 1;
d3dpp.BackBufferWidth = width;
d3dpp.BackBufferHeight = height;
//create Direct3D device
d3d->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, window,
D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &d3ddev);
if (!d3ddev) return false;
//get a pointer to the back buffer surface
d3ddev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
//create sprite object
D3DXCreateSprite(d3ddev, &spriteobj);
return 1;
}
示例9: cleanup
VOID cleanup(){
if(g_pMeshMaterials != NULL)
delete [] g_pMeshMaterials;
if(g_pMeshTextures){
for(DWORD i=0; i<g_dwNumMaterials; ++i){
if(g_pMeshTextures[i])
g_pMeshTextures[i]->Release();
}
delete [] g_pMeshTextures;
}
if(g_pMesh != NULL)
g_pMesh->Release();
if(g_pShutter != NULL)
g_pShutter->Release();
if(g_pDevice != NULL)
g_pDevice->Release();
if(g_pD3D != NULL)
g_pD3D->Release();
}
示例10: InitD3D
HRESULT InitD3D( HWND hWnd )
{
g_pD3D = Direct3DCreate9( D3D_SDK_VERSION );
if( !g_pD3D ) return E_FAIL;
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory( &d3dpp, sizeof(d3dpp) );
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
if( FAILED( g_pD3D->CreateDevice(
D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
hWnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp, &g_pd3dDevice ) ) )
{
return E_FAIL;
}
return S_OK;
}
示例11: Cleanup
//-----------------------------------------------------------------------------
// Name: Cleanup()
// Desc: Releases all previously initialized objects
//-----------------------------------------------------------------------------
VOID Cleanup()
{
if( g_pMeshMaterials != NULL )
delete[] g_pMeshMaterials;
if( g_pMeshMaterials2 != NULL )
delete[] g_pMeshMaterials2;
if( g_pMeshTextures )
{
for( DWORD i = 0; i < g_dwNumMaterials; i++ )
{
if( g_pMeshTextures[i] )
g_pMeshTextures[i]->Release();
}
delete[] g_pMeshTextures;
}
if( g_pMeshTextures2 )
{
for( DWORD i = 0; i < g_dwNumMaterials2; i++ )
{
if( g_pMeshTextures2[i] )
g_pMeshTextures2[i]->Release();
}
delete[] g_pMeshTextures2;
}
if( g_pMesh != NULL )
g_pMesh->Release();
if( g_pMesh2 != NULL )
g_pMesh2->Release();
if( g_pd3dDevice != NULL )
g_pd3dDevice->Release();
if( g_pD3D != NULL )
g_pD3D->Release();
}
示例12: sizeof
HRESULT HookIDirect3D9::CreateDevice(LPVOID _this, UINT Adapter,D3DDEVTYPE DeviceType,HWND hFocusWindow,DWORD BehaviorFlags,D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DDevice9** ppReturnedDeviceInterface)
{
LOG_API();
#if 1
HRESULT res = 0;
#if 0
if (configMgr.GetConfig(TTX_CONFIG_WINDOWED))
{
D3DPRESENT_PARAMETERS d3dpp;
RECT rect;
ShowWindow(hFocusWindow, SW_HIDE);
GetClientRect(hFocusWindow, &rect);
AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE);
SetWindowLong(hFocusWindow, GWL_STYLE, WS_OVERLAPPEDWINDOW);
SetWindowPos(hFocusWindow, HWND_TOPMOST, 100, 100, rect.right, rect.bottom, SWP_FRAMECHANGED | SWP_NOCOPYBITS);
ShowWindow(hFocusWindow, SW_SHOWNORMAL);
ShowCursor(TRUE);
InvalidateRect(hFocusWindow, NULL, TRUE);
logmsg("--%d,%d,%d,%d\n", rect.left,rect.top,rect.right,rect.bottom);
ZeroMemory(&d3dpp, sizeof(d3dpp));
GetClientRect(pPresentationParameters->hDeviceWindow, &rect);
logmsg("Area = %d,%d\n", pPresentationParameters->BackBufferWidth, pPresentationParameters->BackBufferHeight);
d3dpp.BackBufferHeight = pPresentationParameters->BackBufferHeight;
d3dpp.BackBufferWidth = pPresentationParameters->BackBufferWidth;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = pPresentationParameters->BackBufferFormat;
d3dpp.BackBufferCount = pPresentationParameters->BackBufferCount;
d3dpp.Windowed = TRUE;
d3dpp.hDeviceWindow = NULL;//pPresentationParameters->hDeviceWindow;
d3dpp.FullScreen_RefreshRateInHz = 0;
d3dpp.PresentationInterval = pPresentationParameters->PresentationInterval;
d3dpp.AutoDepthStencilFormat = pPresentationParameters->AutoDepthStencilFormat;
d3dpp.Flags = pPresentationParameters->Flags;
d3dpp.EnableAutoDepthStencil = TRUE;
res = pD3D->CreateDevice(Adapter, DeviceType, hFocusWindow, BehaviorFlags, &d3dpp, &pD3Dev);
} else
#endif
logmsg("RES %dx%d\n", pPresentationParameters->BackBufferWidth, pPresentationParameters->BackBufferHeight);
//pPresentationParameters->BackBufferWidth = 1920;
//pPresentationParameters->BackBufferHeight = 1080;
res = pD3D->CreateDevice(Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, &pD3Dev);
if (FAILED(res)) {
logmsg("Err = %X\n", res);
MessageBox(hFocusWindow, DXGetErrorDescriptionA(res), "Erro Direct3D", MB_OK);
*ppReturnedDeviceInterface = NULL;
} else {
*ppReturnedDeviceInterface = (IDirect3DDevice9*) pD3DevWrapper;
}
return res;
#else
return pD3D->CreateDevice(Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, ppReturnedDeviceInterface);
#endif
}
示例13:
HMONITOR HookIDirect3D9::GetAdapterMonitor(LPVOID _this, UINT Adapter)
{
LOG_API();
return pD3D->GetAdapterMonitor(Adapter);
}
示例14: GetAdapterModeCount
UINT HookIDirect3D9:: GetAdapterModeCount(LPVOID _this, UINT Adapter,D3DFORMAT Format)
{
LOG_API();
return pD3D->GetAdapterModeCount(Adapter, Format);
}
示例15: GetAdapterCount
UINT HookIDirect3D9:: GetAdapterCount(LPVOID _this)
{
LOG_API();
return pD3D->GetAdapterCount();
}