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


C++ IDXGISwapChain类代码示例

本文整理汇总了C++中IDXGISwapChain的典型用法代码示例。如果您正苦于以下问题:C++ IDXGISwapChain类的具体用法?C++ IDXGISwapChain怎么用?C++ IDXGISwapChain使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了IDXGISwapChain类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: RenderFrameDX10

void RenderFrameDX10(void)
{
	int w, h;
	GutGetWindowSize(w, h);

	Vector4 vClearColor(0.0f, 0.0f, 0.0f, 0.0f);
	UINT stride = sizeof(Vertex_VT);
	UINT offset = 0;

	ID3D10RenderTargetView *pRenderTargetView = GutGetDX10RenderTargetView(); //frame buffer
	ID3D10DepthStencilView *pDepthStencilView = GutGetDX10DepthStencilView(); //depth/stencil buffer

	D3D10_VIEWPORT vp = {0, 0, w, h, 0.0f, 1.0f};
	g_pDevice->RSSetViewports(1, &vp);

	g_pDevice->OMSetRenderTargets(1, &pRenderTargetView, NULL);
	// 設定Shader
	g_pDevice->VSSetShader(g_pBlurVS);
	g_pDevice->PSSetShader(g_pRGBAPixelShader);
	// 設定vertex shader讀取參數的記憶體位罝
	g_pDevice->VSSetConstantBuffers(0, 1, &g_pVSConstantBuffer);
	// 設定vertex資料格式
	g_pDevice->IASetInputLayout(g_pVertexLayout);
	// 設定三角形頂點索引值資料排列是triangle strip
	g_pDevice->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
	g_pDevice->PSSetShaderResources(0, 1, &g_pTexture);
	g_pDevice->IASetVertexBuffers(0, 1, &g_pVertexBuffer, &stride, &offset);
	g_pDevice->Draw(4, 0);

	if ( g_bPosteffect )
	{
		ID3D10ShaderResourceView *pRSView = NULL;
		pRSView = BrightnessImage(g_pTexture, &g_ImageInfo);
		pRSView = BlurImage(pRSView, &g_ImageInfo);

		g_pDevice->OMSetRenderTargets(1, &pRenderTargetView, NULL);
		g_pDevice->RSSetViewports(1, &vp);

		float dummy[] = {0,0,0,0};
		g_pDevice->OMSetBlendState(g_pAddBlend, dummy, 0xffffffff);
		// 設定Shader
		g_pDevice->VSSetShader(g_pBlurVS);
		g_pDevice->PSSetShader(g_pRGBAPixelShader);
		// 設定vertex shader讀取參數的記憶體位罝
		g_pDevice->VSSetConstantBuffers(0, 1, &g_pVSConstantBuffer);
		// 設定vertex資料格式
		g_pDevice->IASetInputLayout(g_pVertexLayout);
		// 設定三角形頂點索引值資料排列是triangle strip
		g_pDevice->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
		g_pDevice->PSSetShaderResources(0, 1, &pRSView);
		g_pDevice->IASetVertexBuffers(0, 1, &g_pVertexBuffer, &stride, &offset);
		g_pDevice->Draw(4, 0);

		g_pDevice->OMSetBlendState(g_pNoBlend, dummy, 0xffffffff);
	}

	// 等待硬體掃結束, 然後才更新畫面
	IDXGISwapChain *pSwapChain = GutGetDX10SwapChain();
	pSwapChain->Present(1, 0);
}
开发者ID:chenbk85,项目名称:3dlearn,代码行数:60,代码来源:render_dx10.cpp

示例2: RenderFrameDX10

void RenderFrameDX10(void)
{
    Vector4 vClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    // 取得呼叫GutCreateGraphicsDeviceDX10時所產生的D3D10物件
    ID3D10RenderTargetView *pRenderTargetView = GutGetDX10RenderTargetView(); //frame buffer
    ID3D10DepthStencilView *pDepthStencilView = GutGetDX10DepthStencilView(); //depth/stencil buffer
    IDXGISwapChain *pSwapChain = GutGetDX10SwapChain(); // front/back buffer
    // 清除顏色
    g_pDevice->ClearRenderTargetView(pRenderTargetView, (float *)&vClearColor);
    // 清除Depth/Stencil buffer
    g_pDevice->ClearDepthStencilView(pDepthStencilView, D3D10_CLEAR_DEPTH | D3D10_CLEAR_STENCIL, 1.0f, 0);
    //
    /*
    sModelLight light;

    light.vPosition = g_Lights[0].m_Position;
    light.vDirection = g_Lights[0].m_Direction;
    light.vDiffuse = g_Lights[0].m_Diffuse;
    light.vSpecular = g_Lights[0].m_Specular;
    */

    //g_Heightmap.Render(g_Control.GetObjectMatrix(), g_Control.GetViewMatrix(), g_proj_matrix, &light);
    g_Heightmap.Render(g_Control.GetObjectMatrix(), g_Control.GetViewMatrix(), g_proj_matrix);
    // 等待硬體掃結束, 然後才更新畫面
    pSwapChain->Present(1, 0);
}
开发者ID:erickterri,项目名称:3dlearn,代码行数:26,代码来源:render_dx10.cpp

示例3: Render

//------------------------------------------------------------------
//! @brief ゲームの描画
//!
//! @param なし
//!
//! @return なし
//------------------------------------------------------------------
void GameMain::Render()
{
	// ダイレクト3Dの取得
	Direct3D* direct3D = Direct3D::GetInstance();

	// デバイスリソースの取得
	ID3D11DeviceContext*    pDeviceContext = direct3D->GetDeviceContext();
	ID3D11RenderTargetView* pRenderTargetView = direct3D->GetRenderTargetView();

	//深度バッファの取得
	ID3D11DepthStencilView*  pDepthStencilView = direct3D->GetDepthStencilView();
	IDXGISwapChain*         pSwapChain = direct3D->GetSwapChain();
	

	// レンダーターゲットのクリア
	pDeviceContext->ClearRenderTargetView(pRenderTargetView, Colors::DarkBlue);
	//深度バッファのクリア
	pDeviceContext->ClearDepthStencilView(pDepthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0);


	// シーンマネージャの描画
	m_pSceneManager->Render();


	// 画面のフリップ
	pSwapChain->Present(0, 0);


}
开发者ID:GT1-KFM,项目名称:CESA,代码行数:36,代码来源:GameMain.cpp

示例4: RenderFrameDX10

void RenderFrameDX10(void)
{
	Vector4 vClearColor(0.0f, 0.0f, 0.0f, 0.0f);
	UINT stride = sizeof(Vector4);
	UINT offset = 0;

	// 取得呼叫GutCreateGraphicsDeviceDX10時所產生的D3D10物件
	ID3D10RenderTargetView *pRenderTargetView = GutGetDX10RenderTargetView(); //frame buffer
	ID3D10DepthStencilView *pDepthStencilView = GutGetDX10DepthStencilView(); //depth/stencil buffer
	IDXGISwapChain *pSwapChain = GutGetDX10SwapChain(); // front/back buffer

	// 清除顏色
	g_pDevice->ClearRenderTargetView(pRenderTargetView, (float *)&vClearColor);
	// 清除Depth/Stencil buffer
	g_pDevice->ClearDepthStencilView(pDepthStencilView, D3D10_CLEAR_DEPTH | D3D10_CLEAR_STENCIL, 1.0f, 0);
	// 設定vertex shader
	g_pDevice->VSSetShader(g_pVertexShader);
	// 設定pixel shader
	g_pDevice->PSSetShader(g_pPixelShader);
	// 設定vertex shader讀取參數的記憶體位罝
	g_pDevice->VSSetConstantBuffers(0, 1, &g_pConstantBuffer);
	// 設定vertex資料格式
	g_pDevice->IASetInputLayout(g_pVertexLayout);
	// 設定vertex buffer
	g_pDevice->IASetVertexBuffers(0, 1, &g_pVertexBuffer, &stride, &offset);
	// 設定要畫線
	g_pDevice->IASetPrimitiveTopology( D3D10_PRIMITIVE_TOPOLOGY_LINELIST );
	// 畫線
	g_pDevice->Draw(16, 0);
	// 更新畫面
	pSwapChain->Present(0, 0);
}
开发者ID:as2120,项目名称:ZNginx,代码行数:32,代码来源:render_dx10.cpp

示例5: CreateSwapChain

	std::shared_ptr<IDXGISwapChain3> CreateSwapChain( ID3D12Device * device, ID3D12CommandQueue * commandQueue, const HWND* hWnd, DXGI_SWAP_CHAIN_DESC* swapChainDesc)
	{
		IDXGISwapChain* swapChain;
		IDXGISwapChain3* swapChain3;

		DXGI_SWAP_CHAIN_DESC defaultDesc = {};
		if (!swapChainDesc)
		{
			defaultDesc.BufferCount = 2;
			defaultDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
			defaultDesc.BufferDesc.Width = 1200;
			defaultDesc.BufferDesc.Height = 900;
			defaultDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
			defaultDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
			defaultDesc.OutputWindow = *hWnd;
			defaultDesc.SampleDesc.Count = 1;
			defaultDesc.Windowed = TRUE;
			swapChainDesc = &defaultDesc;
		}

		DirectX::ThrowIfFailed(CreateFactory()->CreateSwapChain(
			commandQueue,
			swapChainDesc,
			&swapChain
			));
		swapChain->QueryInterface(IID_PPV_ARGS(&swapChain3));
		swapChain->Release();
		return std::shared_ptr<IDXGISwapChain3>(swapChain3, ReleaseIUnknown);
	}
开发者ID:kururu-zzz,项目名称:DirectX12-BaseSystem,代码行数:29,代码来源:dxgi.cpp

示例6: V

void DX11Engine::setFullScreen(IUnknown* pSwapchain, IUnknown* pOutput, bool bFull) const {
    IDXGISwapChain* swapchain = reinterpret_cast<IDXGISwapChain*>(pSwapchain);
    IDXGIOutput* output = reinterpret_cast<IDXGIOutput*>(pOutput);

    HRESULT hr;
    V(swapchain->SetFullscreenState(bFull, output));
}
开发者ID:Zhou-Zhenglong,项目名称:star,代码行数:7,代码来源:SDX11Engine.cpp

示例7: RenderFrameDX10

void RenderFrameDX10(void)
{
	Vector4 vClearColor(0.0f, 0.0f, 0.0f, 0.0f);
	// 取得呼叫GutCreateGraphicsDeviceDX10時所產生的D3D10物件
	ID3D10RenderTargetView *pRenderTargetView = GutGetDX10RenderTargetView(); //frame buffer
	ID3D10DepthStencilView *pDepthStencilView = GutGetDX10DepthStencilView(); //depth/stencil buffer
	IDXGISwapChain *pSwapChain = GutGetDX10SwapChain(); // front/back buffer

	g_pDevice->ClearRenderTargetView(pRenderTargetView, &vClearColor[0]);
	g_pDevice->ClearDepthStencilView(pDepthStencilView, D3D10_CLEAR_DEPTH|D3D10_CLEAR_STENCIL, 1.0f, 0);

	Matrix4x4 camera_matrix = g_Control.GetCameraMatrix();
	Matrix4x4 view_matrix = g_Control.GetViewMatrix();
	Matrix4x4 world_matrix = g_Control.GetObjectMatrix();

	g_Model_DX10.SetLight(0, g_Lights[0]);
	g_Model_DX10.SetLight(1, g_Lights[1]);
	g_Model_DX10.EnableLighting(true);

	g_Model_DX10.SetProjectionMatrix(g_proj_matrix);
	g_Model_DX10.SetWorldMatrix(world_matrix);
	g_Model_DX10.SetViewMatrix(view_matrix);
	g_Model_DX10.SetInvViewMatrix(camera_matrix);
	g_Model_DX10.UpdateMatrix();

	g_Model_DX10.Render();

	// 等待硬體掃結束, 然後才更新畫面
	pSwapChain->Present(1, 0);
}
开发者ID:as2120,项目名称:ZNginx,代码行数:30,代码来源:render_dx10.cpp

示例8: VE_ASSERT_GE

//--------------------------------------------------------------------------
void D3D12RenderWindow::Init(D3D12Renderer& kRenderer) noexcept
{
	if ((!m_kNode.is_attach()) && m_spTargetWindow)
	{
		D3D12_COMMAND_QUEUE_DESC kQueueDesc = {};
		kQueueDesc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE;
		kQueueDesc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT;
		VE_ASSERT_GE(kRenderer.m_pkDevice->CreateCommandQueue(&kQueueDesc, IID_PPV_ARGS(&m_pkCommandQueue)), S_OK);
		DXGI_SWAP_CHAIN_DESC kSwapChainDesc = {};
		kSwapChainDesc.BufferCount = D3D12Renderer::FRAME_COUNT;
		kSwapChainDesc.BufferDesc.Width = m_spTargetWindow->GetWidth();
		kSwapChainDesc.BufferDesc.Height = m_spTargetWindow->GetHeight();
		kSwapChainDesc.BufferDesc.Format = DXGI_FORMAT_R10G10B10A2_UNORM;
		kSwapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
		kSwapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
		kSwapChainDesc.OutputWindow = (HWND)(m_spTargetWindow->GetNativeHandle());
		kSwapChainDesc.SampleDesc.Count = 1;
		kSwapChainDesc.Windowed = TRUE;
		IDXGISwapChain* pkSwapChain;
		VE_ASSERT_GE(kRenderer.m_pkDXGIFactory->CreateSwapChain(m_pkCommandQueue, &kSwapChainDesc, &pkSwapChain), S_OK);
		VE_ASSERT_GE(pkSwapChain->QueryInterface(IID_PPV_ARGS(&m_pkSwapChain)), S_OK);
		VE_SAFE_RELEASE(pkSwapChain);
		VE_ASSERT(m_pkCommandQueue && m_pkSwapChain);
		for (uint32_t i(0); i < D3D12Renderer::FRAME_COUNT; ++i)
		{
			FrameCache& kFrame = m_akFrameCache[i];
			VE_ASSERT_GE(m_pkSwapChain->GetBuffer(i, IID_PPV_ARGS(&kFrame.m_pkBufferResource)), S_OK);
			kFrame.m_hHandle.ptr = kRenderer.m_kRTVHeap.GetCPUStart().ptr + kRenderer.m_kRTVHeap.Alloc();
			kRenderer.m_pkDevice->CreateRenderTargetView(
				kFrame.m_pkBufferResource, nullptr, kFrame.m_hHandle);
			VE_ASSERT_GE(kRenderer.m_pkDevice->CreateCommandAllocator(
				D3D12_COMMAND_LIST_TYPE_DIRECT,
				IID_PPV_ARGS(&kFrame.m_pkDirectAllocator)), S_OK);
			VE_ASSERT_GE(kRenderer.m_pkDevice->CreateCommandAllocator(
				D3D12_COMMAND_LIST_TYPE_BUNDLE,
				IID_PPV_ARGS(&kFrame.m_pkBundleAllocator)), S_OK);
			kFrame.m_u64FenceValue = 0;

			VE_ASSERT_GE(kRenderer.m_pkDevice->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT,
				kFrame.m_pkDirectAllocator, nullptr, IID_PPV_ARGS(&kFrame.m_pkTestList)), S_OK);
			VE_ASSERT_GE(kFrame.m_pkTestList->Close(), S_OK);
		}

		m_u64FenceValue = 0;
		VE_ASSERT_GE(kRenderer.m_pkDevice->CreateFence(m_u64FenceValue++,
			D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&m_pkFence)), S_OK);
		m_kFenceEvent = CreateEventEx(nullptr, FALSE, FALSE, EVENT_ALL_ACCESS);
		VE_ASSERT(m_kFenceEvent);
		const uint64_t u64FenceToWaitFor = m_u64FenceValue++;
		VE_ASSERT_GE(m_pkCommandQueue->Signal(m_pkFence, u64FenceToWaitFor), S_OK);
		VE_ASSERT_GE(m_pkFence->SetEventOnCompletion(u64FenceToWaitFor, m_kFenceEvent), S_OK);
		WaitForSingleObject(m_kFenceEvent, INFINITE);
		m_u32FramePtr = m_pkSwapChain->GetCurrentBackBufferIndex();
		m_u64FrameIndex = 0;

		m_spTargetWindow->Show();

		kRenderer.m_kRenderWindowList.attach_back(m_kNode);
	}
}
开发者ID:Napoleon314,项目名称:Venus3D,代码行数:61,代码来源:D3D12RenderWindow.cpp

示例9: GoFullscreen

void ACD3D::GoFullscreen(BOOL value)
{
	mIsFullscreen = value;
	IDXGISwapChain* pSwapChain = mpVpComponents[mActiveWnd]->pSwapChain;
	if (SUCCEEDED(pSwapChain->SetFullscreenState(value, nullptr)))
		Log("Goto Fullscreen success. GoFullscreen()");
	else
	{
		MessageBoxA(nullptr, "[ERROR] Goto Fullscreen. GoFullscreen()", "Error", MB_OK | MB_ICONERROR);
	}
};
开发者ID:dgadens,项目名称:ActionEngine,代码行数:11,代码来源:ACD3D.cpp

示例10: RenderFrameDX10

void RenderFrameDX10(void)
{
	Matrix4x4 view_matrix = g_Control.GetViewMatrix();
	Matrix4x4 world_matrix = g_Control.GetObjectMatrix();

	Vector4 vClearColor(0.0f, 0.0f, 0.0f, 0.0f);

	UINT stride = sizeof(Vertex_VT);
	UINT offset = 0;

	ID3D10RenderTargetView *pRenderTargetView = GutGetDX10RenderTargetView();
	ID3D10DepthStencilView *pDepthStencilView = GutGetDX10DepthStencilView();

	g_pDevice->OMSetRenderTargets(1, &g_pRTView[FULLSIZE], pDepthStencilView);
	g_pDevice->ClearRenderTargetView(g_pRTView[FULLSIZE], &vClearColor[0]);
	g_pDevice->ClearDepthStencilView(pDepthStencilView, D3D10_CLEAR_DEPTH|D3D10_CLEAR_STENCIL, 1.0f, 0);

	SetViewport(FULLSIZE);

	CGutModel_DX10::SetViewMatrix(view_matrix);
	CGutModel_DX10::SetWorldMatrix(world_matrix);
	CGutModel_DX10::SetProjectionMatrix(g_proj_matrix);
	CGutModel_DX10::UpdateMatrix();

	g_Model_DX10.Render();

	ConvertToLuminance();
	Average();

	AdaptiveLuminance();
	AutoExposure();

	if ( g_iMode & 0x01 )
	{
		g_pDevice->OMSetRenderTargets(1, &pRenderTargetView, pDepthStencilView);
		SetViewport(FULLSIZE);

		float x = -1.0f;
		float y = -1.0f;
		float w = 0.2f;
		float h = 0.2f;

		DrawImage(g_pSRView[LUMINANCE_CURRENT], x, y, w, h);
		x+=w;
		DrawImage(g_pSRView[LUMINANCE_PREVIOUS], x, y, w, h);
		x+=w;
	}

	// 等待硬體掃結束, 然後才更新畫面
	IDXGISwapChain *pSwapChain = GutGetDX10SwapChain();
	pSwapChain->Present(1, 0);
}
开发者ID:chenbk85,项目名称:3dlearn,代码行数:52,代码来源:render_dx10.cpp

示例11: RenderFrameDX10

void RenderFrameDX10(void)
{
    Vector4 vClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    UINT stride = sizeof(Vertex_VCN);
    UINT offset = 0;
    // 取得呼叫GutCreateGraphicsDeviceDX10時所產生的D3D10物件
    ID3D10RenderTargetView *pRenderTargetView = GutGetDX10RenderTargetView(); //frame buffer
    ID3D10DepthStencilView *pDepthStencilView = GutGetDX10DepthStencilView(); //depth/stencil buffer
    IDXGISwapChain *pSwapChain = GutGetDX10SwapChain(); // front/back buffer
    // 清除顏色
    g_pDevice->ClearRenderTargetView(pRenderTargetView, (float *)&vClearColor);
    // 清除Depth/Stencil buffer
    g_pDevice->ClearDepthStencilView(pDepthStencilView, D3D10_CLEAR_DEPTH | D3D10_CLEAR_STENCIL, 1.0f, 0);
    // 設定vertex shader
    g_pDevice->VSSetShader(g_pVertexShader);
    // 設定pixel shader
    g_pDevice->PSSetShader(g_pPixelShader);
    // 設定vertex shader讀取參數的記憶體位罝
    g_pDevice->VSSetConstantBuffers(0, 1, &g_pConstantBuffer);
    // 設定vertex資料格式
    g_pDevice->IASetInputLayout(g_pVertexLayout);
    // 設定vertex buffer
    g_pDevice->IASetVertexBuffers(0, 1, &g_pVertexBuffer, &stride, &offset);
    // 設定index buffer
    g_pDevice->IASetIndexBuffer(g_pIndexBuffer, DXGI_FORMAT_R16_UINT, 0);
    // 設定三角形頂點索引值資料排列是triangle strip
    g_pDevice->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
    // 計算矩陣
    Matrix4x4 view_proj_matrix = g_view_matrix * g_proj_matrix;
    Matrix4x4 world_view_proj_matrix = g_world_matrix * view_proj_matrix;
    // 設定shader參數
    Matrix4x4 *pConstData;
    g_pConstantBuffer->Map( D3D10_MAP_WRITE_DISCARD, NULL, (void **) &pConstData );
    *pConstData = world_view_proj_matrix;
    g_pConstantBuffer->Unmap();
    // 更新頂點資料
    Vertex_VCN *pVertex;
    g_pVertexBuffer->Map( D3D10_MAP_WRITE_DISCARD, NULL, (void **) &pVertex );
    memcpy(pVertex, g_pGridVertices, sizeof(Vertex_VCN) * g_iNumGridVertices);
    g_pVertexBuffer->Unmap();
    // 更新索引值陣列
    unsigned short *pIndex;
    g_pIndexBuffer->Map( D3D10_MAP_WRITE_DISCARD, NULL, (void **) &pIndex );
    memcpy(pIndex, g_pGridIndices, sizeof(unsigned short) * g_iNumGridIndices);
    g_pIndexBuffer->Unmap();
    // 畫出格子
    g_pDevice->DrawIndexed(g_iNumGridIndices, 0, 0);
    // 等待硬體掃描結束, 然後才更新畫面
    pSwapChain->Present(1, 0);
}
开发者ID:erickterri,项目名称:3dlearn,代码行数:50,代码来源:render_dx10.cpp

示例12: RenderFrameDX10

void RenderFrameDX10(void)
{
	Vector4 vClearColor(0.0f, 0.0f, 0.0f, 0.0f);
	// frame buffer
	ID3D10RenderTargetView *pRenderTargetView = GutGetDX10RenderTargetView(); 
	// depth/stencil buffer
	ID3D10DepthStencilView *pDepthStencilView = GutGetDX10DepthStencilView(); 
	// front/back buffer
	IDXGISwapChain *pSwapChain = GutGetDX10SwapChain(); 
	// 清除顏色
	g_pDevice->ClearRenderTargetView(pRenderTargetView, (float *)&vClearColor);
	// 清除Depth/Stencil buffer
	g_pDevice->ClearDepthStencilView(pDepthStencilView, D3D10_CLEAR_DEPTH | D3D10_CLEAR_STENCIL, 1.0f, 0);
	// 取得轉換矩陣
	Matrix4x4 view_matrix = g_Control.GetViewMatrix();
	Matrix4x4 world_matrix = g_Control.GetObjectMatrix();
	Matrix4x4 ident_matrix = Matrix4x4::IdentityMatrix();

	CGutModel_DX10::SetProjectionMatrix(g_proj_matrix);
	CGutModel_DX10::SetViewMatrix(view_matrix);
	// 畫出茶具組
	{
		g_pDevice->OMSetDepthStencilState(NULL, 1);
		CGutModel_DX10::SetWorldMatrix(world_matrix);
		CGutModel_DX10::UpdateMatrix();
		g_Model_DX10.Render();
	}
	// stencil pass, 在stencil buffer里標出光源照射到的像素
	{
		g_pDevice->OMSetDepthStencilState(g_pZStencil_Mask, 1);
		CGutModel_DX10::SetWorldMatrix(ident_matrix);
		CGutModel_DX10::UpdateMatrix();
		CGutModel_DX10::SetMaterialOverwrite(&g_material_stencilpass);
		g_SpotLightModel_DX10.Render();
	}
	// 畫出被光線照射到的區域
	{
		g_pDevice->OMSetDepthStencilState(g_pZStencil_Test, 1);
		CGutModel_DX10::SetMaterialOverwrite(&g_material_spotlightpass);
		g_SpotLightModel_DX10.Render();
	}
	// 畫出光柱圓錐
	{
		g_pDevice->OMSetDepthStencilState(NULL, 1);
		CGutModel_DX10::SetMaterialOverwrite(NULL);
		g_SpotLightModel_DX10.Render();
	}
	// 等待硬體掃結束, 然後才更新畫面.
	pSwapChain->Present(1, 0);
}
开发者ID:as2120,项目名称:ZNginx,代码行数:50,代码来源:render_dx10.cpp

示例13: RenderFrameDX10

void RenderFrameDX10(void)
{
	Vector4 vClearColor(0.0f, 0.0f, 0.0f, 0.0f);

	// 取得主畫面
	ID3D10RenderTargetView *pRenderTargetView = GutGetDX10RenderTargetView();
	ID3D10DepthStencilView *pDepthStencilView = GutGetDX10DepthStencilView(); 

	g_pDevice->ClearRenderTargetView(pRenderTargetView, (float *)&vClearColor);
	g_pDevice->ClearDepthStencilView(pDepthStencilView, D3D10_CLEAR_DEPTH | D3D10_CLEAR_STENCIL, 1.0f, 0);

	g_pDevice->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_LINESTRIP);

	ID3D10EffectTechnique *g_pShader = NULL;

	switch(g_iMode)
	{
	default:
	case 1:
		g_pShader = g_pDrawCurveFX->GetTechniqueByName("SinCurve");
		break;
	case 2:
		{
			g_pShader = g_pDrawCurveFX->GetTechniqueByName("ZCurve");

			Vector4 vNearFar(1.0f, 100.0f, 0.0f, 0.0f);
			Matrix4x4 proj_matrix = GutMatrixPerspectiveRH_DirectX(45.0f, 1.0f, vNearFar[0], vNearFar[1]);
			//Matrix4x4 proj_matrix = GutMatrixOrthoRH_DirectX(10.0f, 10.0f, vNearFar[0], vNearFar[1]);
			//Matrix4x4 proj_matrix = GutMatrixOrthoRH_OpenGL(10.0f, 10.0f, vNearFar[0], vNearFar[1]);
			//Matrix4x4 proj_matrix = GutMatrixPerspectiveRH_OpenGL(45.0f, 1.0f, vNearFar[0], vNearFar[1]);

			ID3D10EffectMatrixVariable *pMatrix = 
				g_pDrawCurveFX->GetVariableByName("proj_matrix")->AsMatrix();
			ID3D10EffectVectorVariable *pNearFarPlane = 
				g_pDrawCurveFX->GetVariableByName("NearFarPlane")->AsVector();

			pMatrix->SetMatrix(&proj_matrix[0][0]);
			pNearFarPlane->SetFloatVector(&vNearFar[0]);

			break;
		}
	}

	g_pShader->GetPassByIndex(0)->Apply(0);
	g_pDevice->Draw(2, 0);

	IDXGISwapChain *pSwapChain = GutGetDX10SwapChain(); 
	pSwapChain->Present(1, 0);
}
开发者ID:as2120,项目名称:ZNginx,代码行数:49,代码来源:render_dx10.cpp

示例14: ZeroMemory

        std::shared_ptr<SwapChain> Device::createSwapChain(const Window& window)
        {
            std::shared_ptr<SwapChain> swapChain;

            IDXGIDevice* dxgiDevice = nullptr;
            if (SUCCEEDED(m_device->QueryInterface<IDXGIDevice>(&dxgiDevice)))
            {
                IDXGIAdapter* adapter = nullptr;
                if (SUCCEEDED(dxgiDevice->GetAdapter(&adapter)))
                {
                    IDXGIFactory* dxgiFactory = nullptr;
                    if (SUCCEEDED(adapter->GetParent(__uuidof(IDXGIFactory), reinterpret_cast<void**>(&dxgiFactory))))
                    {
                        DXGI_SWAP_CHAIN_DESC sd;
                        ZeroMemory(&sd, sizeof(sd));
                        sd.BufferCount = 1;
                        sd.BufferDesc.Width = window.getWidth();
                        sd.BufferDesc.Height = window.getHeight();
                        sd.BufferDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
                        sd.BufferDesc.RefreshRate.Numerator = 0;
                        sd.BufferDesc.RefreshRate.Denominator = 1;
                        sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
                        sd.OutputWindow = window.getPlatformData()->getHandle();
                        sd.SampleDesc.Count = 1;
                        sd.SampleDesc.Quality = 0;
                        sd.Windowed = TRUE;
                        IDXGISwapChain* nativeSwapChain = nullptr;
                        if (SUCCEEDED(dxgiFactory->CreateSwapChain(m_device, &sd, &nativeSwapChain)))
                        {
                            ID3D11Texture2D* backBufferTexture = nullptr;
                            if (SUCCEEDED(nativeSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), reinterpret_cast<void**>(&backBufferTexture))))
                            {
                                auto texture = std::make_shared<Texture2d>(backBufferTexture);
                                auto backBufferRenderCommandEncoder = createRenderCommandEncoder(1, &texture, nullptr, false);
                                swapChain = std::make_shared<SwapChain>(nativeSwapChain, backBufferRenderCommandEncoder);
                            }

                            dxgiFactory->Release();
                        }

                        adapter->Release();
                    }
                }

                dxgiDevice->Release();
            }

            return swapChain;
        }
开发者ID:jpark37,项目名称:RenderApplication,代码行数:49,代码来源:DeviceD3D.cpp

示例15: CreateSwapChain

HRESULT STDMETHODCALLTYPE CDXGIFactoryDWM::CreateSwapChain(IUnknown *pDevice, DXGI_SWAP_CHAIN_DESC *pDesc, IDXGIOutput *pOutput, IDXGISwapChainDWM **ppSwapChain)
{
    IDXGISwapChain *pSwapChain = NULL;
    if (retrace::forceWindowed) {
        pDesc->Windowed = TRUE;
    }
    HRESULT hr = m_pFactory->CreateSwapChain(pDevice, pDesc, &pSwapChain);
    if (SUCCEEDED(hr)) {
        if (!retrace::forceWindowed) {
            pSwapChain->SetFullscreenState(TRUE, pOutput);
        }
        *ppSwapChain = new CDXGISwapChainDWM(pSwapChain);
    }
    return hr;
}
开发者ID:is00hcw,项目名称:apitrace,代码行数:15,代码来源:d3dretrace_dxgi.hpp


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