本文整理汇总了C++中InitD3D函数的典型用法代码示例。如果您正苦于以下问题:C++ InitD3D函数的具体用法?C++ InitD3D怎么用?C++ InitD3D使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了InitD3D函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InitD3D
BOOL C3d::SubclassWindow(HWND hWnd)
{
BOOL bRet = CWindowImpl<C3d>::SubclassWindow(hWnd);
if(bRet)
InitD3D();
return bRet;
}
示例2: MsgProc
//-----------------------------------------------------------------------------
// Name: MsgProc()
// Desc: The window's message handler
//-----------------------------------------------------------------------------
LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
switch( msg )
{
case WM_DESTROY:
PostQuitMessage( 0 );
return 0;
case WM_TIMER:
case WM_PAINT:
Render(); // Update the main window when needed
break;
// If the display mode changes, tear down the graph and rebuild it.
// The resolution may have changed or we may have lost surfaces due to
// a transition from another application's full screen exclusive mode.
case WM_DISPLAYCHANGE:
Cleanup();
InitD3D(hWnd);
InitGeometry();
break;
case WM_CHAR:
{
// Close the app if the ESC key is pressed
if (wParam == VK_ESCAPE)
{
PostMessage(hWnd, WM_CLOSE, 0, 0);
}
// else maybe background color change by space
else if(wParam == VK_SPACE)
{
bkRed = (BYTE)(rand()%0xFF);
bkGrn = (BYTE)(rand()%0xFF);
bkBlu = (BYTE)(rand()%0xFF);
}
// else if 'enter' return to black
else if(wParam == VK_RETURN )
{
bkRed = bkGrn = bkBlu = 0x0;
}
}
break;
case WM_SYSCOMMAND:
{
switch (wParam)
{
case ID_HELP_ABOUT:
// Create a modeless dialog to prevent rendering interruptions
CreateDialog(hInstance, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd,
(DLGPROC) AboutDlgProc);
return 0;
}
}
break;
}
return DefWindowProc( hWnd, msg, wParam, lParam );
}
示例3: InitEverything
//------------------------------------------------------------
// Initialization code
//------------------------------------------------------------
bool InitEverything(HWND hWnd)
{
// init D3D
if (!InitD3D(hWnd))
{
return false;
}
// create a fullscreen quad
InitFullScreenQuad();
// create a render target
if (FAILED(gpD3DDevice->CreateTexture(WIN_WIDTH, WIN_HEIGHT,
1, D3DUSAGE_RENDERTARGET, D3DFMT_X8R8G8B8,
D3DPOOL_DEFAULT, &gpSceneRenderTarget, NULL)))
{
return false;
}
// loading models, shaders and textures
if (!LoadAssets())
{
return false;
}
// load fonts
if (FAILED(D3DXCreateFont(gpD3DDevice, 20, 10, FW_BOLD, 1, FALSE, DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, (DEFAULT_PITCH | FF_DONTCARE),
"Arial", &gpFont)))
{
return false;
}
return true;
}
示例4: DoInit
BOOL DoInit(HWND hWnd)
{
// Initialize Direct3D
InitD3D(&g_pD3D, &g_pD3DDevice, hWnd);
// Load a skeletal mesh
LoadMesh(&g_Mesh, &g_Frame, g_pD3DDevice, "..\\Data\\tiny.x", "..\\Data\\");
// Get the bounding radius of the object
g_MeshRadius = 0.0f;
D3DXMESHCONTAINER_EX *pMesh = g_Mesh;
while(pMesh) {
// Lock the vertex buffer, get its radius, and unlock buffer
if(pMesh->MeshData.pMesh) {
D3DXVECTOR3 *pVertices, vecCenter;
float Radius;
pMesh->MeshData.pMesh->LockVertexBuffer(D3DLOCK_READONLY, (void**)&pVertices);
D3DXComputeBoundingSphere(pVertices,
pMesh->MeshData.pMesh->GetNumVertices(),
D3DXGetFVFVertexSize(pMesh->MeshData.pMesh->GetFVF()),
&vecCenter, &Radius);
pMesh->MeshData.pMesh->UnlockVertexBuffer();
// Update radius
if(Radius > g_MeshRadius)
g_MeshRadius = Radius;
}
// Go to next mesh
pMesh = (D3DXMESHCONTAINER_EX*)pMesh->pNextMeshContainer;
}
return TRUE;
}
示例5: LOG_MSG
HRESULT CDirect3D::InitializeDX(HWND wnd, bool triplebuf)
{
#if LOG_D3D
LOG_MSG("D3D:Starting Direct3D");
#endif
backbuffer_clear_countdown = 0;
// Check for display window
if(!wnd) {
LOG_MSG("Error: No display window set!");
return E_FAIL;
}
hwnd = wnd;
if (mhmodDX9 == NULL)
mhmodDX9 = LoadLibrary("d3d9.dll");
if (mhmodDX9 == NULL)
return E_FAIL;
// Set the presentation parameters
ZeroMemory(&d3dpp, sizeof(d3dpp));
d3dpp.BackBufferWidth = dwWidth;
d3dpp.BackBufferHeight = dwHeight;
d3dpp.BackBufferCount = 1;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.Windowed = true;
d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
Section_prop * sec=static_cast<Section_prop *>(control->GetSection("vsync"));
if(sec) {
d3dpp.PresentationInterval = (!strcmp(sec->Get_string("vsyncmode"),"host"))?D3DPRESENT_INTERVAL_DEFAULT:D3DPRESENT_INTERVAL_IMMEDIATE;
}
if(triplebuf) {
LOG_MSG("D3D:Using triple buffering");
d3dpp.BackBufferCount = 2;
}
// Init Direct3D
if(FAILED(InitD3D())) {
DestroyD3D();
LOG_MSG("Error: Unable to initialize DirectX9!");
return E_FAIL;
}
#if D3D_THREAD
#if LOG_D3D
LOG_MSG("D3D:Starting worker thread from thread: %u", SDL_ThreadID());
#endif
thread_run = true;
thread_command = D3D_IDLE;
thread = SDL_CreateThread(EntryPoint, this);
SDL_SemWait(thread_ack);
#endif
return S_OK;
}
示例6: _tWinMain
int WINAPI _tWinMain(HINSTANCE hInstance,
HINSTANCE hPreInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
if (!InitD3D(hInstance)) //初始化D3D
{
MessageBox(NULL, _T("InitD3D Failed"), NULL, MB_OK);
return FALSE;
}
MSG msg;
while (true) //开始消息循环
{
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
Render();
}
}
Cleanup();
return msg.wParam;
}
示例7: WinMain
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT )
{
WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L,
GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
"D3D Tutorial", NULL };
RegisterClassEx( &wc );
HWND hWnd = CreateWindow( "D3D Tutorial", "D3D Tutorial 04",
WS_OVERLAPPEDWINDOW,
100, 100, 300, 300,
GetDesktopWindow(), NULL, wc.hInstance, NULL );
if (FAILED( InitD3D(hWnd) )) goto MAIN_END;
if (FAILED( init_geometry() )) goto MAIN_END;
ShowWindow( hWnd, SW_SHOWDEFAULT );
UpdateWindow( hWnd );
MSG msg;
ZeroMemory( &msg, sizeof(msg) );
while ( msg.message != WM_QUIT ) {
if ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) {
TranslateMessage( &msg );
DispatchMessage( &msg );
}
else {
Render();
}
}
MAIN_END:
UnregisterClass( "D3D Tutorial", wc.hInstance );
return 0;
}
示例8: WinMain
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT )
{
// Register the window class
WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L,
GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
"D3D Tutorial", NULL };
RegisterClassEx( &wc );
// Create the application's window
HWND hWnd = CreateWindow( "D3D Tutorial", "D3D_EulerAngle",
WS_OVERLAPPEDWINDOW, 100, 100, 400, 400,
GetDesktopWindow(), NULL, wc.hInstance, NULL );
// Initialize Direct3D
if( SUCCEEDED( InitD3D( hWnd ) ) )
{
// Show the window
ShowWindow( hWnd, SW_SHOWDEFAULT );
UpdateWindow( hWnd );
// Enter the message loop
MSG msg;
ZeroMemory( &msg, sizeof(msg) );
while( msg.message!=WM_QUIT )
{
if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
else
Render();
}
}
UnregisterClass( "D3D Tutorial", wc.hInstance );
return 0;
}
示例9: DoResize
void DoResize()
{
AppPreResize();
InitD3D();
AppPostResize();
CallAppRender( true );
}
示例10: DbgLog
// ILAVDecoder
STDMETHODIMP CDecDXVA2::Init()
{
DbgLog((LOG_TRACE, 10, L"CDecDXVA2::Init(): Trying to open DXVA2 decoder"));
HRESULT hr = S_OK;
// Initialize all D3D interfaces in non-native mode
if (!m_bNative) {
hr = InitD3D();
if (FAILED(hr)) {
DbgLog((LOG_TRACE, 10, L"-> D3D Initialization failed with hr: %X", hr));
return hr;
}
if (CopyFrameNV12 == NULL) {
int cpu_flags = av_get_cpu_flags();
if (cpu_flags & AV_CPU_FLAG_SSE4) {
DbgLog((LOG_TRACE, 10, L"-> Using SSE4 frame copy"));
CopyFrameNV12 = CopyFrameNV12_SSE4;
} else {
DbgLog((LOG_TRACE, 10, L"-> Using fallback frame copy"));
CopyFrameNV12 = CopyFrameNV12_fallback;
}
}
}
// Init the ffmpeg parts
// This is our main software decoder, unable to fail!
CDecAvcodec::Init();
return S_OK;
}
示例11: WinMain
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE PrevInstance,
PSTR cmdLine,
int showCmd)
{
if(!InitD3D(hInstance, Width, Height, Windowed, D3DDEVTYPE_HAL, &Device))
{
::MessageBox(0, "InitD3D Failed", "Error", MB_OK);
return 0;
}
if(!Setup())
{
::MessageBox(0, "Setup Failed", "Error", MB_OK);
return 0;
}
EnterMsgLoop( Display );
Cleanup();
Device->Release();
return 0;
}
示例12: WinMain
//-----------------------------------------------------------------------------
// Name: WinMain()
// Desc: The application's entry point
//-----------------------------------------------------------------------------
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT )
{
// Register the window class
WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L,
GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
"D3D Tutorial", NULL };
RegisterClassEx( &wc );
// Create the application's window
HWND hWnd = CreateWindow( "D3D Tutorial", "D3D Tutorial 01: CreateDevice",
WS_EX_TOPMOST, 100, 100, 300, 300,
GetDesktopWindow(), NULL, wc.hInstance, NULL );
// Initialize Direct3D
if( SUCCEEDED( InitD3D( hWnd ) ) )
{
// Show the window
ShowWindow( hWnd, SW_SHOWDEFAULT );
UpdateWindow( hWnd );
// Enter the message loop
MSG msg;
while( GetMessage( &msg, NULL, 0, 0 ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
}
UnregisterClass( "D3D Tutorial", wc.hInstance );
return 0;
}
示例13: Initilize
void Initilize(void)
{
// Register the window class
WNDCLASSEX createWin = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L,
GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
_T("The Throne of The Kingdom"), NULL };
RegisterClassEx( &createWin );
// Create the application's window
hwnd = CreateWindow( _T("The Throne of The Kingdom"), _T("TOK"),
WS_OVERLAPPEDWINDOW, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT,
NULL, NULL, createWin.hInstance, NULL );
InitD3D(hwnd);
if(!SUCCEEDED(D3DXCreateSprite(renderDevice, &sprite)))
{
MessageBox(NULL, _T("Error of create sprite"), NULL, NULL);
}
//ZeroMemory(&bg, sizeof(Objects));
//ZeroMemory(&om, sizeof(ObjectManager));
LoadData();
// Show the window
ShowWindow( hwnd, SW_SHOWDEFAULT );
UpdateWindow( hwnd );
}
示例14: MessageProc
// Win32 MessageProc callback
LRESULT CALLBACK MessageProc(HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
// Send event message to AntTweakBar
if( TwEventWin(wnd, msg, wParam, lParam) )
return 0; // Event has been handled by AntTweakBar
switch( msg )
{
case WM_CHAR:
if( wParam==VK_ESCAPE )
PostQuitMessage(0);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_SIZE: // Window size has been changed
// Reset D3D device
if( g_D3DDev )
{
g_D3Dpp.BackBufferWidth = LOWORD(lParam);
g_D3Dpp.BackBufferHeight = HIWORD(lParam);
if( g_D3Dpp.BackBufferWidth>0 && g_D3Dpp.BackBufferHeight>0 )
{
g_D3DDev->Reset(&g_D3Dpp);
InitD3D(); // re-initialize D3D states
}
// TwWindowSize has been called by TwEventWin32,
// so it is not necessary to call it again here.
}
return 0;
default:
return DefWindowProc(wnd, msg, wParam, lParam);
}
}
示例15: vp
// Initialize application window
// Most of the error checking omitted
bool App::Init()
{
/*
viewports[0].SetVPSize(winWidth/2, winHeight/2);
Viewport vp(viewports[0]);
vp.SetVPPosition(winWidth/2, winHeight/2);
viewports.push_back(vp);
*/
if(!InitWindow())
return false;
if(!InitD3D())
return false;
// Call resize to do rest of window initialization
Resize();
if(!CompileShaders())
return false;
// Set up sampler states for perlin noise
SetupSamplers();
// Set up lookup textures for perlin noise
SetupTextures();
// Initialize vertex buffer with canvas quad
InitCanvas();
// Init default viewport
viewports[0].RefreshBuffer();
// Initialize viewport buffer
D3D11_SUBRESOURCE_DATA vpbufData;
vpbufData.pSysMem = viewports[0].GetBufferData();
vpbufData.SysMemPitch = NULL;
vpbufData.SysMemSlicePitch = NULL;
HR(dev->CreateBuffer(&Viewport::viewportBufferDesc, NULL, &viewportBuffer));
// Initialize shader params buffer;
D3D11_BUFFER_DESC shaderBufferDesc= {
sizeof(ShaderParams),
D3D11_USAGE_DYNAMIC,
D3D11_BIND_CONSTANT_BUFFER,
D3D11_CPU_ACCESS_WRITE,
0
};
D3D11_SUBRESOURCE_DATA shaderBuffer;
shaderBuffer.pSysMem = shaderParams;
shaderBuffer.SysMemPitch = NULL;
shaderBuffer.SysMemSlicePitch = NULL;
HR(dev->CreateBuffer(&shaderBufferDesc, &shaderBuffer, &shaderParamsBuffer));
// And finally update the window
UpdateWindow(mainWnd);
return true;
}