dx11 入门篇 Tutorial 01: 基本要素的创建 DirectXSampleBrowser(June 2010)

目标:这几天迅速入门dx11

第一讲主要是基本要素的创建:device 、context、view、swap;

笔记:

1.In Direct3D 10, the device object was used to perform both rendering and resource creation. In Direct3D 11, the immediate context is used by the application to perform rendering onto a buffer, and the device contains methods to create resources.

是说:图形两大块: 资源的创建和渲染;dx11前直接device实现,现在context渲染模块render buffer ,device管理资源的创建。

2.The front buffer is what is being presented currently to the user. This buffer is read-only and cannot be modified. The back buffer is the render target to which the device will draw. Once it finishes the drawing operation, the swap chain will present the backbuffer by swapping the two buffers. The back buffer becomes the front buffer, and vice versa.

前后buffer: front buffer只读,用于显示给我们, back buffer用于render,是我们实际绘制的内容;当完成一次绘制操作,swap chain 会进行front和back的切换

3.A resource view allows a resource to be bound to the graphics pipeline at a specific stage.We need to create a render target view because we would like to bind the back buffer of our swap chain as a render target.    

RenderTargetView 关联资源的创建和与backBuffer的绑定:

	// Create a render target view
	ID3D11Texture2D* pBackBuffer = NULL;
	hr = g_pSwapChain->GetBuffer( 0, __uuidof( ID3D11Texture2D ), ( LPVOID* )&pBackBuffer );//swapChian获取backBuffer,
	if( FAILED( hr ) )
		return hr;
	hr = g_pd3dDevice->CreateRenderTargetView( pBackBuffer, NULL, &g_pRenderTargetView );//Device 创建资源,并与backBuffer绑定
	pBackBuffer->Release();
	if( FAILED( hr ) )
		return hr;
	g_pImmediateContext->OMSetRenderTargets( 1, &g_pRenderTargetView, NULL );//context设置渲染:backBuffer的内容

4.The viewport maps clip space coordinates, where X and Y range from -1 to 1 and Z ranges from 0 to 1,we set the top left point to (0, 0) and width and height to be identical to the render target's size.

视口坐标系下,XY原点位于左上角。  Z的范围为0到1

 

总结下流程:

1.创建 device、context、swapChain

2.swapChain获取一个backBuffer、device创建renderTargetView并绑定buffer,context设置渲染目标,

3.viewport的创建

4.修改window响应方式为监听但不阻塞;同时在非阻塞时候进行图形render

5.render()

 

posted @ 2015-01-16 14:09  dust_fly  阅读(654)  评论(0编辑  收藏  举报