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

4D星宇

c++

  C++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
  57 隨筆 :: 0 文章 :: 39 評論 :: 0 Trackbacks

有Effect版:
    DWORD         g_dwShaderFlags; // Shader compilate and link flags
      LPD3DXBUFFER  g_pCompiledFragments = NULL; 

    D3DXGatherFragmentsFromFile( L"FragmentLinker.fx", NULL,
                NULL, g_dwShaderFlags, &g_pCompiledFragments, NULL );

D3DXGatherFragmentsFromFile requires the .fx file, pointers to the #define and #include handlers (both set to NULL in this example), and the shader compile flags. The method returns a buffer which contains the compiled shader fragment. The method can return a second buffer with compile errors, which is set to NULL in this example because it is not used. D3DXGatherFragments is overloaded to handle loading fragments from a string, a file, or a resource.

Set your debugger to break on this method to look for compile errors in the debugger. The compiler can catch errors in syntax, but it cannot check for registers that are shared incorrectly due to the fact that it has no way to predict which parameters a user may want to share between fragments.

You need a fragment linker to manage the compiled fragments. Create the fragment linker by calling D3DXCreateFragmentLinker:

ID3DXFragmentLinker* g_pFragmentLinker = NULL;     // Fragment linker interface
IDirect3DDevice9*    pd3dDevice        = NULL;

    // Initialize the device before using it
 ...
 
    // Create the fragment linker interface
    D3DXCreateFragmentLinker( pd3dDevice, 0, &g_pFragmentLinker );

Then simply add the compiled fragments to the fragment linker using ID3DXFragmentLinker::AddFragments.

    // Add the compiled fragments to a list
    g_pFragmentLinker->AddFragments(    
              (DWORD*)g_pCompiledFragments->GetBufferPointer() );

ID3DXFragmentLinker::AddFragments requires a pointer to the DWORD stream that contains the compiled shader.

After compiling fragments and creating a fragment linker, there are several ways to link fragments. One way to link a vertex shader fragment is to call ID3DXFragmentLinker::LinkVertexShader. Here is an example that links two vertex shader fragments:

    // Get a handle to each fragment   
    D3DXHANDLE fragmentHandle[2];
 fragmentHandle[0] =
     (D3DXHANDLE)g_pFragmentLinker->GetFragmentHandleByName("Ambient");
 fragmentHandle[1] =
     (D3DXHANDLE)g_pFragmentLinker->GetFragmentHandleByName("AmbientDiffuseFragment");
   
    // Link the fragments together to form a vertex shader
    IDirect3DVertexShader9* pVertexShader = NULL;
    g_pFragmentLinker->LinkVertexShader( "vs_1_1", g_dwShaderFlags,
           fragmentHandle, 2, &pVertexShader, NULL );

This requires a shader compile target, the shader compile and link flags, and a handle to each of the fragments to link. If the fragments are successfully linked, ID3DXFragmentLinker::LinkVertexShader returns a vertex shader (IDirect3DVertexShader9). The vertex shader needs to be set in the effect before rendering. But before this, here's how the shader is declared in the effect:

VertexShader MyVertexShader; // Vertex shader set by the application

The effect technique contains all the state set for a pass. This pass specifies the vertex shader like this:

technique RenderScene
{
    pass P0
    {
        VertexShader = <MyVertexShader>;   
        PixelShader = compile ps_1_1 ModulateTexture();   
    }

With the effect's vertex shader created and initialized, the render code also sets the uniform constants and calls the render loop. Set the uniform constants similar to this:

    // Update the uniform shader constants.
    g_pEffect->SetMatrix( "g_mWorldViewProjection", &mWorldViewProjection );
    g_pEffect->SetMatrix( "g_mWorld", &mWorld );
    g_pEffect->SetFloat( "g_fTime", (float)fTime );   
Then render the effect by setting the current technique and pass:

    // Render the scene
    if( SUCCEEDED( pd3dDevice->BeginScene() ) )
    { 
        // Apply the technique contained in the effect
        UINT cPasses, iPass;
        g_pEffect->Begin(&cPasses, 0);

        for (iPass = 0; iPass < cPasses; iPass++)
        {
            g_pEffect->BeginPass(iPass);

            // Render the mesh with the applied technique
            g_pMesh->DrawSubset(0);

            g_pEffect->EndPass();
        }
        g_pEffect->End();

        pd3dDevice->EndScene();
    }

When setting uniform shader constants, it is more efficient to cache a handle to the parameter by calling ID3DXBaseEffect::GetParameterByName. This avoids the string lookup that is necessary when calling effect methods like ID3DXBaseEffect::SetMatrix.

  // Instead of setting a uniform constant like this in the render loop
  g_pEffect->SetMatrix( "g_mWorldViewProjection", &mWorldViewProjection );

  // Get a handle to a uniform constant outside of the render loop
  D3DXHANDLE hParameter;
  GetParameterByName( hParameter,"g_mWorldViewProjection");

  ...
 
  // Use the handle to set the uniform constant in the render loop
  g_pEffect->SetMatrix(hParameter);

無Effect版:
 LPD3DXCONSTANTTABLE pConstantTable;
    LPD3DXBUFFER pShaderBuf;
    IDirect3DVertexShader9* pVertexShader = NULL;

    // Compile the fragments to a buffer.
    D3DXGatherFragmentsFromFile( L"FragmentLinker.fx", NULL, NULL,
         g_dwShaderFlags, &g_pCompiledFragments, NULL );
   
    g_pFragmentLinker->AddFragments((DWORD*)g_pCompiledFragments->GetBufferPointer());
    g_pFragmentLinker->LinkShader(
     "vs_1_1",
     g_dwShaderFlags,
     aHandles,
     NUM_FRAGMENTS,
     &pShaderBuf,
     NULL);
    D3DXGetShaderConstantTable(
     (DWORD*)pShaderBuf->GetBufferPointer(),
     &pConstantTable );
   
    pDevice->CreateVertexShader(
     (DWORD*)pShaderBuf->GetBufferPointer(),
     &pVertexShader);
    RELEASE(pShaderBuf);

posted on 2008-05-12 19:51 bloodbao 閱讀(470) 評論(0)  編輯 收藏 引用 所屬分類: c++
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            依依成人综合视频| 久久影视三级福利片| 午夜欧美精品| 中文在线资源观看视频网站免费不卡| 精品动漫一区二区| 国产一区在线免费观看| 国产日韩欧美三级| 狠狠色综合网| 亚洲电影免费观看高清完整版| 激情成人av在线| 亚洲国产精品毛片| 在线综合视频| 欧美一区二区三区日韩| 开元免费观看欧美电视剧网站| 巨胸喷奶水www久久久免费动漫| 欧美成人亚洲| 99国产精品国产精品久久| 亚洲视屏在线播放| 美国成人直播| 国产精品日本精品| 亚洲国产综合在线看不卡| 亚洲婷婷在线| 模特精品在线| 一区二区欧美日韩| 久久美女性网| 欧美日韩第一区日日骚| 欧美日韩免费一区| 国产亚洲欧美一区二区三区| 亚洲国产日韩一区| 香蕉成人久久| 欧美成人中文字幕| 亚洲一区二区三区涩| 久久夜色精品国产噜噜av| 欧美精品亚洲二区| 韩日成人在线| 亚洲综合三区| 亚洲国产欧美不卡在线观看| 正在播放亚洲一区| 免费视频一区二区三区在线观看| 国产精品成人v| 亚洲国产精品一区二区www| 欧美一区视频| 亚洲在线一区二区| 毛片一区二区三区| 国产精品福利在线| 亚洲精品韩国| 久久夜精品va视频免费观看| 夜夜嗨av色一区二区不卡| 久久久精品日韩欧美| 国产精品久久久对白| 亚洲激情网站免费观看| 久久精品夜色噜噜亚洲a∨ | 免费欧美在线视频| 免费不卡在线视频| 亚洲精品乱码久久久久久| 亚洲欧美www| 亚洲国产高清aⅴ视频| 国产精品国产三级国产专播品爱网 | 免费在线观看一区二区| 一区二区欧美在线观看| 美日韩精品免费观看视频| 国产在线欧美日韩| 久久久久久9999| 午夜一区二区三区在线观看| 国产美女搞久久| 久久视频在线视频| 99精品国产在热久久下载| 欧美777四色影视在线| 极品中文字幕一区| 久久综合九色九九| 久久久久久夜| 亚洲欧洲一区二区三区在线观看| 欧美一二三区精品| 午夜一级久久| 黑人一区二区| 牛夜精品久久久久久久99黑人| 欧美一区二区三区四区视频| 国产精品影视天天线| 亚洲欧美日韩一区二区在线 | 国产午夜精品美女毛片视频| 欧美一区二区啪啪| 亚洲一区www| 亚洲午夜三级在线| 狠狠综合久久av一区二区老牛| 麻豆成人综合网| 欧美日韩爆操| 久久国产精品高清| 欧美成人一二三| 亚洲天堂第二页| 午夜精品久久久久久久99水蜜桃| 国产亚洲一本大道中文在线| 麻豆freexxxx性91精品| 欧美日韩国产欧美日美国产精品| 亚洲资源av| 久久久久国产精品一区| 一本一本久久| 久久国产精品毛片| 99精品欧美一区二区三区综合在线| 亚洲视频在线观看三级| 一区二区亚洲| 一本一本a久久| 在线观看不卡| 亚洲一区二区三区在线| 在线看国产一区| 一区二区三区福利| 亚洲二区在线视频| 亚洲一区二区视频| 亚洲国产高清视频| 亚洲天堂成人在线观看| 亚洲黄色毛片| 欧美一区二视频在线免费观看| 亚洲精品欧洲精品| 久久精品30| 欧美在线视频免费观看| 欧美成人情趣视频| 美女黄色成人网| 国产女精品视频网站免费 | 久久本道综合色狠狠五月| 在线视频亚洲欧美| 欧美黑人一区二区三区| 久久久av毛片精品| 国产欧美一区二区三区在线看蜜臀| 亚洲欧美日本日韩| 国产视频在线观看一区| 亚洲经典在线| 久久久久久久高潮| 久久精品视频在线看| 国产精品青草久久久久福利99| 亚洲精品极品| 亚洲激情女人| 美女网站在线免费欧美精品| 久久久国产91| 国产一区99| 欧美中在线观看| 久久久久久久久久看片| 国产精品视频久久| 一区二区三区四区蜜桃| 亚洲视频欧美视频| 欧美三级电影网| 日韩一级精品视频在线观看| 99这里只有精品| 国产精品成人免费| 亚洲男女自偷自拍图片另类| 欧美一级播放| 欧美三级在线| 久久精品国产99国产精品澳门| 亚洲午夜电影| 欧美午夜视频在线| 999亚洲国产精| 亚洲综合精品四区| 国产欧美日韩精品专区| 午夜精品久久久久久久99热浪潮 | 国产日韩精品一区二区浪潮av| 亚洲婷婷国产精品电影人久久| 亚洲一级电影| 国产精品久久久久99| 亚洲视频一区在线观看| 香蕉av777xxx色综合一区| 国产欧美高清| 久久久久久久久久久一区| 欧美国产一区二区在线观看| 日韩视频在线一区二区| 欧美日韩国产精品一区| 亚洲影音一区| 久久精品理论片| 亚洲高清在线精品| 欧美日本精品| 亚洲永久在线观看| 狼狼综合久久久久综合网| 日韩视频二区| 国产精品一二| 欧美成人午夜77777| 亚洲网在线观看| 免费欧美日韩| 亚洲天堂av在线免费| 国产在线精品成人一区二区三区| 欧美aⅴ一区二区三区视频| 9色国产精品| 米奇777超碰欧美日韩亚洲| 99精品国产在热久久| 国产视频久久久久| 欧美日韩大片| 久久久久高清| 一本一本久久a久久精品综合妖精 一本一本久久a久久精品综合麻豆 | 久久综合久久久| 亚洲片在线观看| 国产亚洲毛片| 欧美性开放视频| 欧美~级网站不卡| 午夜天堂精品久久久久| 日韩网站在线| 欧美激情在线有限公司| 欧美综合二区| 亚洲在线国产日韩欧美| 亚洲黑丝一区二区| 国产亚洲va综合人人澡精品| 欧美日韩第一区| 欧美精品激情在线| 蜜桃av噜噜一区二区三区| 午夜电影亚洲|