zoukankan      html  css  js  c++  java
  • 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()

  • 相关阅读:
    Web2.0技能评测
    [收藏]流程设计和优化原则
    [读书笔记1] 卓有成效的管理者(彼得.德鲁克)
    [读书笔记3] 卓有成效的管理者聚焦贡献
    [读书笔记2] 卓有成效的管理者管理时间
    动态生成的Web软件 应该如何设计???
    Logs
    JQuery推荐插件(200+)
    Spring AOP 实例
    《JavaScript凌厉开发Ext详解与实践》一书说了些什么
  • 原文地址:https://www.cnblogs.com/dust-fly/p/4228578.html
Copyright © 2011-2022 走看看