当前位置: 首页>>代码示例>>C++>>正文


C++ InitD3D函数代码示例

本文整理汇总了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;
}
开发者ID:lazyrohan,项目名称:triexporter-22735,代码行数:7,代码来源:3d.cpp

示例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 );
}
开发者ID:chinajeffery,项目名称:dx_sdk,代码行数:64,代码来源:Textures.cpp

示例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;
}
开发者ID:popekim,项目名称:ShaderPrimer,代码行数:38,代码来源:ShaderFramework.cpp

示例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;
}
开发者ID:ruke79,项目名称:advanced-animation-with-directx-source-code,代码行数:35,代码来源:WinMain.cpp

示例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;
}
开发者ID:joncampbell123,项目名称:dosbox-x,代码行数:60,代码来源:direct3d.cpp

示例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;
}
开发者ID:daodaodaorenjiandao,项目名称:Graphics,代码行数:30,代码来源:main.cpp

示例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;
}
开发者ID:netpyoung,项目名称:bs.3d_game_programming,代码行数:35,代码来源:2-6.cpp

示例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;
}
开发者ID:jameskun77,项目名称:3DSample,代码行数:35,代码来源:Main.cpp

示例9: DoResize

void DoResize()
{
	AppPreResize();
	InitD3D();
	AppPostResize();
	CallAppRender( true );
}
开发者ID:DeadZoneLuna,项目名称:SourceEngine2007,代码行数:7,代码来源:d3dapp.cpp

示例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;
}
开发者ID:betaking,项目名称:LAVFilters,代码行数:32,代码来源:dxva2dec.cpp

示例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;
}
开发者ID:dynaturtle,项目名称:opensim-map,代码行数:25,代码来源:cubeApp.cpp

示例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;
}
开发者ID:arlukin,项目名称:dev,代码行数:36,代码来源:CreateDevice.cpp

示例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 );
}
开发者ID:JueSungMun,项目名称:TOK,代码行数:27,代码来源:main.cpp

示例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);
    }
}
开发者ID:daemqn,项目名称:Atari_ST_Sources,代码行数:35,代码来源:TwSimpleDX9.cpp

示例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;
}
开发者ID:pkoivumaki,项目名称:xplosion,代码行数:61,代码来源:App.cpp


注:本文中的InitD3D函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。