青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

麒麟子

~~

導航

<2010年1月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456

統計

常用鏈接

留言簿(12)

隨筆分類

隨筆檔案

Friends

WebSites

積分與排名

最新隨筆

最新評論

閱讀排行榜

評論排行榜

[轉]關于Direct3D多窗口編程的一篇翻譯


In DirectX 8, support for rendering to multiple windows is provided through the creation of additional swap chains. However, there are currently no examples of this in the SDK, and the documentation is a bit vague. This article is provided to fill the gaps, and will explain the steps you need to take to write an application that will render multiple views in separate windows.


在DX8中,對多窗口的支持是通過創建更多的Swap Chains來提供的。SDK中沒有相關的例子而且文檔也只是泛泛而談。這篇文章就是為了解決這個問題,它將向您展示應當如何一步步地實現在多個分離窗口中渲染多個視圖。

 

 

Step 1 - Setting Up The Parent Frame


第一步:設置父框架窗口

 

 

In an application with multiple views, we start with a top level frame that will contain child windows in its client area to display various views. Once the parent frame parent frame has been created, we create our Direct3D device interface, specifying windowed mode and setting the top level window handle as the focus window:


在多視圖的應用程序中,我們需要從最高層次的框架——這個框架將包含所有在他用戶區之內的子視圖窗口——開始我們的旅程。當父框架創建的時候,我們需要創建Direct3D Device接口,為其指定使用窗口模式,而且設置這最高層次的窗口句柄作為“焦點窗口”的句柄:

 

 

g_pD3D=Direct3DCreate8(D3D_SDK_VERSION);


if (!g_pD3D) return -1;


D3DPRESENT_PARAMETERS d3dpp;


ZeroMemory( &d3dpp, sizeof(d3dpp) );


d3dpp.Windowed = TRUE;


d3dpp.SwapEffect = D3DSWAPEFFECT_COPY;


// Use the current display mode. 使用當前的顯示模式


D3DDISPLAYMODE mode;

if(FAILED(g_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT , &mode))) {


    SAFE_RELEASE(g_pD3D);


    return -1;


}


d3dpp.BackBufferFormat = mode.Format;


d3dpp.BackBufferWidth = mode.Width;


d3dpp.BackBufferHeight = mode.Height;


d3dpp.EnableAutoDepthStencil=TRUE;


d3dpp.AutoDepthStencilFormat = D3DFMT_D16;


// m_hWnd is handle to top level window    m_hWnd是最高層窗口的句柄


if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, m_hWnd,


                                  D3DCREATE_SOFTWARE_VERTEXPROCESSING,


                                  &d3dpp, &g_pd3dDevice) ) ) {


    SAFE_RELEASE(g_pD3D);


    return -1;


}

 

 


Note that for simplicity the above code does not test depth format, instead choosing a fixed format. Your application should determine a compatible depth format for the format of the rendering target.


注意上面代碼處于簡單考慮并沒有去測試深度緩存的格式(?depth format),而只是選擇了一個確定的格式(D3DFMT_D16)。您的程序應該為需要渲染的Render Target選擇一個可接受的深度緩存格式。

 

 

The device has a frame buffer, which the child views will be rendered into, as well as a depth buffer which will be shared among the views. The frame buffer and depth buffer are sized to the full screen resolution, to allow for the fact that the window may later be resized. Otherwise, window size changes would require resetting the device and re-creating the swap chains.


Device都需要有幀緩存,這樣子視圖才能進行渲染,同時,深度緩沖也應當被不同的視圖進行共享。幀緩存和深度緩存都被設置為全屏幕大小,以考慮到可能窗口會被改變大小的情況。如果不的話,窗口改變大小的時候,就需要Reset Device和重新創建Swap Chain。

 

 

Step 2 - Setting Up View Windows


第二步:設置子視圖窗口

 

 

Now we are ready to create our view windows, and associate them with swap chains that can be rendered to the device. Once the windows have been created, the following code generates a swap chain for the child window:


現在我們可以準備創建我們的子窗口也就是視圖窗口,并把它們與交換鏈關聯以使得他們可以被渲染到Device上。當窗口創建后,下面的代碼將為子窗口創建一個交換鏈:

 

 

D3DPRESENT_PARAMETERS d3dpp;


ZeroMemory( &d3dpp, sizeof(d3dpp) );


d3dpp.Windowed = TRUE;


d3dpp.SwapEffect = D3DSWAPEFFECT_COPY;


// Use the current display mode. 使用當前的顯示模式


D3DDISPLAYMODE mode;


g_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT , &mode);


d3dpp.BackBufferFormat = mode.Format;


// m_hWnd contains child window handle m_hWnd儲存子窗口的句柄


d3dpp.hDeviceWindow=m_hWnd;


// m_pSwapChain is IDirect3DSwapChain *   m_pSwapChain是一個IDirect3DSwapChain*對象


g_pd3dDevice->CreateAdditionalSwapChain(&d3dpp, &m_pSwapChain);

 

 


After executing this code, the m_pSwapChain variable will contain a pointer to an IDirect3DSwapChain interface, which contains a frame buffer corresponding to the client area of the child window. This process is performed for each view window, so that that there is a swap chain for each view window.


經過這些代碼之后,m_pSwapChain變量就儲存了IDirect3DSwapChain接口的指針,這個接口將儲存子窗口視圖區所對應的幀緩沖。

 

 

Step 3 - Rendering a View

第三步:渲染視圖

 

 

Prior to rendering each view, we must direct the device to render to the appropriate frame buffer, using the SetRenderTarget() method. We pass the back buffer from the window's swap chain, while using the depth buffer that was originally created with the device:


在渲染每個視圖窗口之前,我們必須使得Device來渲染對應的幀緩沖,這我們就需要用到SetRenderTarget方法。我們向其中傳入子窗口SwapChain交換鏈的后備緩沖BackBuffer,以及使用最開始跟著Device一起創建的深度緩沖。

 

 

LPDIRECT3DSURFACE8 pBack=NULL,pStencil=NULL;


m_pSwapChain->GetBackBuffer(0,D3DBACKBUFFER_TYPE_MONO,&pBack);


g_pd3dDevice->GetDepthStencilSurface(&pStencil);


g_pd3dDevice->SetRenderTarget(pBack,pStencil);


pBack->Release();


pStencil->Release();

 

 


Note that we release the stencil and backbuffer pointers after we use them, because the GetBackBuffer() and GetDepthStencilSurface() functions call AddRef() on these interfaces to increment their reference counters. Failing to release them would lead to a memory leak.


注意我們必須Release掉Stencil和BackBuffer的指針,因為GetBackBuffer和GetDepthStencilSurface這兩個函數都會調用COM的AddRef方法,來增加相應COM接口的引用計數,因此如果不刪除它們,將會導致內存泄露。

 

 

We are now ready to render the view. Rendering is performed within a scene in the normal manner, except that we call Present() on the swap chain interface rather than the device interface:


我們現在已經做好準備渲染視圖窗口了。渲染的方法看起來和我們平常用的方法差不多,只是有一點:我們現在需要調用Swap Chain的接口,而不是Device的接口。

 

 

g_pd3dDevice->Clear(0,NULL,D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,0x00000000,1.0,0);


if (SUCCEEDED(g_pd3dDevice->BeginScene())) {


  


    // rendering code goes here 渲染代碼寫在這里

 

 


    g_pd3dDevice->EndScene();


}


m_pSwapChain->Present(NULL,NULL,NULL,NULL);

 

 


Step 4 - Handling Resize of Child Views


第四步,子窗口的Resize問題

 

 

DirectX will automatically deal with changes in the child view by using a stretch blit to present the swap chain if the dimensions have client area is not the same size as the swap chain's frame buffer. However, this may not be desirable, as it will cause aliasing if the client area is increased in size.


如果窗口的視圖區大小和SwapChain的大小不一,那么DirectX將通過Stretch Blit來自動處理圖像的伸縮變化。盡管這可能并不令人期待,因為這在視圖區變大的時候將導致圖像的模糊。

 

posted on 2009-08-10 17:32 麒麟子 閱讀(2463) 評論(4)  編輯 收藏 引用 所屬分類: DirectX

評論

# re: [轉]關于Direct3D多窗口編程的一篇翻譯 2009-08-10 22:23 kuafoo

始終沒找到你發的那個兩個小游戲源碼  回復  更多評論   

# re: [轉]關于Direct3D多窗口編程的一篇翻譯 2009-08-11 00:01 Leaf

@kuafoo
額,我不曉得怎么放耶?。。?nbsp; 回復  更多評論   

# re: [轉]關于Direct3D多窗口編程的一篇翻譯 2009-08-12 12:05 戴爾電腦

不錯啊  回復  更多評論   

# re: [轉]關于Direct3D多窗口編程的一篇翻譯 2009-09-11 16:14 wu

<如果窗口的視圖區大小和SwapChain的大小不一,那么DirectX將通過Stretch Blit來自動處理圖像的伸縮變化。盡管這可能并不令人期待,因為這在視圖區變大的時候將導致圖像的模糊。> 你說的這個問題 要怎么才能解決?
  回復  更多評論   

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            欧美成人中文| 欧美日韩高清不卡| 国产视频精品va久久久久久| 亚洲自拍偷拍网址| 在线一区亚洲| 国产亚洲欧美一区二区三区| 欧美成人伊人久久综合网| 91久久综合| 亚洲激情视频在线观看| 欧美福利视频| 亚洲一区二三| 久久成人资源| 亚洲欧洲一区二区在线观看| 亚洲人成欧美中文字幕| 欧美性大战久久久久久久蜜臀| 亚洲一区区二区| 欧美亚洲在线视频| 亚洲国产精品激情在线观看| 亚洲精品免费一区二区三区| 欧美婷婷久久| 久久亚洲高清| 欧美黄色一区| 欧美一区综合| 欧美成人精品1314www| 亚洲手机成人高清视频| 香蕉久久夜色精品国产使用方法| 狠久久av成人天堂| 一区二区三区www| 国产噜噜噜噜噜久久久久久久久 | 欧美~级网站不卡| 一区二区三区四区五区视频| 香蕉成人久久| 一本色道**综合亚洲精品蜜桃冫| 亚洲免费一级电影| 亚洲免费观看视频| 欧美一区二区免费视频| 99精品免费视频| 久久久久成人网| 亚洲一区三区视频在线观看 | 亚洲高清久久网| 国产一区二区三区电影在线观看 | 老色批av在线精品| 欧美性理论片在线观看片免费| 久久九九国产| 欧美性片在线观看| 欧美激情综合色| 国产综合色一区二区三区| 亚洲精品美女在线观看| 亚洲电影免费观看高清完整版| 中国成人黄色视屏| 亚洲美洲欧洲综合国产一区| 久久国产主播| 久久精品五月婷婷| 国产日韩在线亚洲字幕中文| 在线一区二区日韩| 中文日韩电影网站| 欧美日韩另类视频| 亚洲三级国产| 亚洲精品视频免费观看| 久久综合99re88久久爱| 久久久久久穴| 黄色成人免费观看| 欧美一区二区三区日韩| 欧美亚洲一区| 国产欧美精品在线| 午夜精品国产精品大乳美女| 性欧美暴力猛交69hd| 国产精品男人爽免费视频1| 一区二区日韩伦理片| 在线视频一区二区| 欧美日本中文字幕| 99这里有精品| 亚洲欧美春色| 国产精品午夜在线| 欧美一区二区三区在线| 久久久综合精品| 亚洲国产欧美国产综合一区 | 亚洲美女91| 99精品99| 国产精品日韩二区| 先锋影音久久| 欧美91精品| 日韩视频在线观看免费| 欧美日精品一区视频| 亚洲视频国产视频| 久久精品亚洲热| 在线观看日韩欧美| 欧美日韩a区| 亚洲永久免费精品| 久久躁日日躁aaaaxxxx| 91久久香蕉国产日韩欧美9色| 欧美91福利在线观看| 99re在线精品| 欧美在线视频a| 亚洲国产精品一区在线观看不卡| 欧美激情精品久久久久久久变态| 最近中文字幕mv在线一区二区三区四区| 99精品热6080yy久久| 国产精品美女久久久浪潮软件 | 亚洲老板91色精品久久| 性色av一区二区三区红粉影视| 国模套图日韩精品一区二区| 欧美成人午夜视频| 亚洲欧美日韩天堂一区二区| 欧美国产日本高清在线| 亚洲女爱视频在线| 亚洲电影在线看| 国产精品青草久久| 玖玖在线精品| 亚洲欧美一区二区精品久久久| 免费黄网站欧美| 午夜精彩国产免费不卡不顿大片| 国产一区二区日韩精品| 欧美日韩视频一区二区| 久久久久国色av免费观看性色| 亚洲人体1000| 久热re这里精品视频在线6| 亚洲色图在线视频| 亚洲国产二区| 狠狠久久五月精品中文字幕| 欧美色另类天堂2015| 欧美freesex交免费视频| 西瓜成人精品人成网站| 9久草视频在线视频精品| 欧美88av| 两个人的视频www国产精品| 午夜在线一区二区| 中国女人久久久| 亚洲精品久久在线| 在线观看亚洲| 在线观看91久久久久久| 国产欧美精品日韩区二区麻豆天美| 欧美日韩视频| 欧美精品三级在线观看| 欧美+亚洲+精品+三区| 久久久精品tv| 欧美永久精品| 欧美一级理论片| 亚洲欧美在线x视频| 亚洲天堂网在线观看| 亚洲狼人精品一区二区三区| 亚洲欧洲在线看| 最新日韩在线视频| 亚洲精品麻豆| 日韩视频在线你懂得| 亚洲人永久免费| 亚洲精品美女91| 一本大道久久精品懂色aⅴ| 亚洲人成毛片在线播放| 亚洲国产精品尤物yw在线观看| 欧美成人资源| 亚洲国产网站| 99视频精品全国免费| 夜夜精品视频| 亚洲综合视频一区| 欧美一区二区黄| 久久久欧美精品sm网站| 美女视频黄免费的久久| 欧美国产一区二区在线观看| 欧美精品大片| 国产精品久久久久久av下载红粉 | 亚洲国产另类精品专区| 亚洲乱码久久| 亚洲一二区在线| 亚洲欧美国产日韩天堂区| 久久国产精品久久久久久久久久| 欧美在线视频在线播放完整版免费观看 | 1000部国产精品成人观看| 亚洲二区视频| 亚洲视频一二区| 欧美一区二区三区免费视频| 久久综合一区二区三区| 亚洲福利视频网站| 一区二区三区高清不卡| 性久久久久久久| 欧美超级免费视 在线| 欧美午夜精品久久久久久浪潮 | 玖玖玖国产精品| 欧美日韩一卡| 国内精品视频在线观看| 日韩一区二区电影网| 久久久不卡网国产精品一区| 亚洲国产成人porn| 亚洲免费视频成人| 欧美电影免费网站| 国产精自产拍久久久久久蜜| 亚洲第一精品久久忘忧草社区| 亚洲一区二区在线看| 免费不卡在线观看av| 99在线热播精品免费99热| 久久网站免费| 国产欧美日韩一区二区三区| 91久久国产自产拍夜夜嗨| 久久成人精品电影| 日韩视频在线一区二区| 久久精品一区二区三区四区| 欧美性色aⅴ视频一区日韩精品| 亚洲国产高清在线| 欧美亚洲免费在线| 亚洲精品欧美激情|