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

隨筆 - 505  文章 - 1034  trackbacks - 0
<2007年2月>
28293031123
45678910
11121314151617
18192021222324
25262728123
45678910


子曾經曰過:編程無他,唯手熟爾!

常用鏈接

留言簿(94)

隨筆分類(649)

隨筆檔案(505)

相冊

BCB

Crytek

  • crymod
  • Crytek's Offical Modding Portal

Game Industry

OGRE

other

Programmers

Qt

WOW Stuff

搜索

  •  

積分與排名

  • 積分 - 920381
  • 排名 - 14

最新隨筆

最新評論

閱讀排行榜

評論排行榜

術語:
FVF (flexible vertex format)   靈活的頂點格式



//-----------------------------------------------------------------------------
// File: Vertices.cpp
//
// Desc: In this tutorial, we are rendering some vertices. This introduces the
//       concept of the vertex buffer, a Direct3D object used to store
//       vertices. Vertices can be defined any way we want by defining a
//       custom structure and a custom FVF (flexible vertex format). In this
//       tutorial, we are using vertices that are transformed (meaning they
//       are already in 2D window coordinates) and lit (meaning we are not
//       using Direct3D lighting, but are supplying our own colors).
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#include <d3d9.h>
#pragma warning( disable : 
4996 ) // disable deprecated warning 
#include <strsafe.h>
#pragma warning( 
default : 4996 ) 




//-----------------------------------------------------------------------------
// Global variables
//-----------------------------------------------------------------------------
LPDIRECT3D9             g_pD3D       = NULL; // Used to create the D3DDevice
LPDIRECT3DDEVICE9       g_pd3dDevice = NULL; // Our rendering device
LPDIRECT3DVERTEXBUFFER9 g_pVB        = NULL; // Buffer to hold vertices 頂點Buffer

// A structure for our custom vertex type 自定義頂點類型
struct CUSTOMVERTEX
{
    FLOAT x, y, z, rhw; 
// The transformed position for the vertex
    DWORD color;        // The vertex color
};

// Our custom FVF, which describes our custom vertex structure
#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZRHW|D3DFVF_DIFFUSE)




//-----------------------------------------------------------------------------
// Name: InitD3D()
// Desc: Initializes Direct3D
//-----------------------------------------------------------------------------
HRESULT InitD3D( HWND hWnd )
{
    
// Create the D3D object.
    if( NULL == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
        
return E_FAIL;

    
// Set up the structure used to create the D3DDevice
    D3DPRESENT_PARAMETERS d3dpp;
    ZeroMemory( 
&d3dpp, sizeof(d3dpp) );
    d3dpp.Windowed 
= TRUE;
    d3dpp.SwapEffect 
= D3DSWAPEFFECT_DISCARD;
    d3dpp.BackBufferFormat 
= D3DFMT_UNKNOWN;

    
// Create the D3DDevice
    if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
                                      D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                                      
&d3dpp, &g_pd3dDevice ) ) )
    {
        
return E_FAIL;
    }

    
// Device state would normally be set here

    
return S_OK;
}




//-----------------------------------------------------------------------------
// Name: InitVB()
// Desc: Creates a vertex buffer and fills it with our vertices. The vertex
//       buffer is basically just a chuck of memory that holds vertices. After
//       creating it, we must Lock()/Unlock() it to fill it. For indices, D3D
//       also uses index buffers. The special thing about vertex and index
//       buffers is that they can be created in device memory, allowing some
//       cards to process them in hardware, resulting in a dramatic
//       performance gain.
//-----------------------------------------------------------------------------
HRESULT InitVB()
{
    
// Initialize three vertices for rendering a triangle 初始化要渲染的三角形的三個頂點
    CUSTOMVERTEX vertices[] =
    {
        { 
150.0f,  50.0f0.5f1.0f0xffff0000, }, // x, y, z, rhw, color
        { 250.0f250.0f0.5f1.0f0xff00ff00, },
        {  
50.0f250.0f0.5f1.0f0xff00ffff, },
    };

    
// Create the vertex buffer. 創建vertex buffer
    
// Here we are allocating enough memory
    
// (from the default pool) to hold all our 3 custom vertices. We also
    
// specify the FVF, so the vertex buffer knows what data it contains.
    if( FAILED( g_pd3dDevice->CreateVertexBuffer( 3*sizeof(CUSTOMVERTEX),
                                                  
0, D3DFVF_CUSTOMVERTEX,
                                                  D3DPOOL_DEFAULT, 
&g_pVB, NULL ) ) )
    {
        
return E_FAIL;
    }

    
// Now we fill the vertex buffer. 填充vertex buffer
    
// To do this, we need to Lock() the VB to
    
// gain access to the vertices. This mechanism is required becuase vertex
    
// buffers may be in device memory.
    VOID* pVertices; // 輸出參數
    if( FAILED( g_pVB->Lock( 0sizeof(vertices), (void**)&pVertices, 0 ) ) )
        
return E_FAIL;
    memcpy( pVertices, vertices, 
sizeof(vertices) );
    g_pVB
->Unlock();

    
return S_OK;
}




//-----------------------------------------------------------------------------
// Name: Cleanup()
// Desc: Releases all previously initialized objects
//-----------------------------------------------------------------------------
VOID Cleanup()
{
    
if( g_pVB != NULL )        
        g_pVB
->Release();

    
if( g_pd3dDevice != NULL ) 
        g_pd3dDevice
->Release();

    
if( g_pD3D != NULL )       
        g_pD3D
->Release();
}




//-----------------------------------------------------------------------------
// Name: Render()
// Desc: Draws the scene
//-----------------------------------------------------------------------------
VOID Render()
{
    
// Clear the backbuffer to a blue color
    g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,255), 1.0f0 );

    
// Begin the scene
    if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
    {
        
// Draw the triangles in the vertex buffer. 畫vertex buffer中的三角形
        
// This is broken into a few steps. 

        
// We are passing the vertices down a "stream", so first we need
        
// to specify the source of that stream, which is our vertex buffer. 
        
// 我們正傳遞頂點到一個“流”里,這個流的源頭是vertex buffer
        g_pd3dDevice->SetStreamSource( 0, g_pVB, 0sizeof(CUSTOMVERTEX) );

        
// Then we need to let D3D know what vertex shader to use.
        
// 讓D3D知道我們用什么vertex shader
        
// Full, custom vertex shaders are an advanced topic,
        
// but in most cases the vertex shader is just the FVF,
        
// so that D3D knows what type of vertices we are dealing with. 
        g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX );

        
// Finally, we call DrawPrimitive() which does the actual rendering
        
// of our geometry (in this case, just one triangle).
        g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 01 );

        
// End the scene
        g_pd3dDevice->EndScene();
    }

    
// Present the backbuffer contents to the display
    g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}




//-----------------------------------------------------------------------------
// Name: MsgProc()
// Desc: The window's message handler
//-----------------------------------------------------------------------------
LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
    
switch( msg )
    {
        
case WM_DESTROY:
            Cleanup();
            PostQuitMessage( 
0 );
            
return 0;
    }

    
return DefWindowProc( hWnd, msg, wParam, lParam );
}




//-----------------------------------------------------------------------------
// Name: WinMain()
// Desc: The application's entry point
//-----------------------------------------------------------------------------
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT )
{
    
// Register the window class
    WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L0L,
                      GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
                      
"D3D Tutorial", NULL };
    RegisterClassEx( 
&wc );

    
// Create the application's window
    HWND hWnd = CreateWindow( "D3D Tutorial""D3D Tutorial 02: Vertices",
                              WS_OVERLAPPEDWINDOW, 
100100300300,
                              NULL, NULL, wc.hInstance, NULL );

    
// Initialize Direct3D
    if( SUCCEEDED( InitD3D( hWnd ) ) )
    {
        
// Create the vertex buffer
        if( SUCCEEDED( InitVB() ) )
        {
            
// Show the window
            ShowWindow( hWnd, SW_SHOWDEFAULT );
            UpdateWindow( hWnd );

            
// Enter the message loop
            MSG msg;
            ZeroMemory( 
&msg, sizeof(msg) );
            
while( msg.message!=WM_QUIT )
            {
                
if( PeekMessage( &msg, NULL, 0U0U, PM_REMOVE ) )
                {
                    TranslateMessage( 
&msg );
                    DispatchMessage( 
&msg );
                }
                
else
                    Render();
            }
        }
    }

    UnregisterClass( 
"D3D Tutorial", wc.hInstance );
    
return 0;
}
posted on 2007-02-15 22:16 七星重劍 閱讀(977) 評論(0)  編輯 收藏 引用 所屬分類: Game Graphics
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            欧美中在线观看| 欧美一区二区三区男人的天堂 | 久久精品观看| 亚洲美女视频在线观看| 久久久久久久久久久一区| 亚洲调教视频在线观看| 亚洲第一在线| 国产精品嫩草99av在线| 欧美日韩精品久久| 麻豆精品精品国产自在97香蕉| 一区二区av| 亚洲日韩第九十九页| 久久久999精品| 亚洲欧美中日韩| 一本色道久久综合狠狠躁的推荐| 国内免费精品永久在线视频| 欧美高清日韩| 亚洲性感美女99在线| 欧美亚洲免费高清在线观看| 国产欧美一区二区三区久久| 久久婷婷久久一区二区三区| 国产精品yjizz| 免费不卡亚洲欧美| 欧美成人a视频| 久久久伊人欧美| 欧美紧缚bdsm在线视频| 欧美日韩国产综合网| 国产精品久久久久久久午夜片 | 亚洲综合国产精品| 久久久久国产一区二区三区| 亚洲黄色小视频| 一本不卡影院| 久久久中精品2020中文| 欧美日韩不卡一区| 国产一区二区三区观看| 国产一区二区三区电影在线观看| 亚洲黄色av一区| 久久精品亚洲乱码伦伦中文| 久久久久亚洲综合| 99国产精品国产精品毛片| 99精品视频免费观看| 亚洲综合大片69999| 午夜欧美大尺度福利影院在线看| 亚洲日本理论电影| 亚洲乱码国产乱码精品精 | 欧美日韩综合| 欧美日韩成人精品| 狠狠色综合网| 狼人天天伊人久久| 欧美中文字幕精品| 在线精品国精品国产尤物884a| 欧美亚洲视频在线观看| 亚洲精品在线观看视频| 亚洲在线不卡| 国产噜噜噜噜噜久久久久久久久| 艳妇臀荡乳欲伦亚洲一区| 亚洲经典自拍| 日韩视频一区| 亚洲私人影吧| 亚洲高清不卡在线| 一本色道久久综合狠狠躁篇怎么玩| 免费短视频成人日韩| 一区二区久久| 欧美国产一区二区| 欧美91福利在线观看| 亚洲高清视频的网址| 亚洲人成网在线播放| 久久久国产精品一区二区三区| 国产精品日本| 亚洲国产精彩中文乱码av在线播放| 亚洲美女免费视频| 欧美二区在线| 欧美日韩在线播放一区| 一本色道久久加勒比精品| 久久伊人一区二区| 亚洲一级二级在线| 狂野欧美一区| 在线观看日韩www视频免费 | 欧美在线免费视频| 欧美一区2区三区4区公司二百| 亚洲精品视频免费在线观看| 亚洲人成在线观看| 欧美日韩精品一区二区三区| 亚洲淫性视频| 久久精品在线免费观看| 欧美大片专区| 国产精品久久久久9999吃药| 美女网站久久| 亚洲二区视频在线| 亚洲国产精品黑人久久久| 国产欧美日韩亚洲一区二区三区| 欧美不卡在线| 日韩视频免费看| 久久精品免费电影| 久久国产精品毛片| 久久婷婷国产综合国色天香| 亚洲一区二区三区精品视频| 午夜精品在线观看| 亚洲大胆视频| 欧美午夜电影网| 9i看片成人免费高清| 亚洲视频精品| 欧美日韩国产a| 久久精品二区| 韩国女主播一区二区三区| 亚洲精品久久久久久久久久久久久| 国产欧美一区二区三区沐欲| 久久久免费观看视频| 亚洲国产视频直播| 久久精品国产免费| 亚洲三级毛片| 午夜日韩视频| 亚洲国产精品久久久久秋霞蜜臀 | 国产主播一区二区三区| 欧美成人精品在线| 亚洲视频电影在线| 黄色成人在线免费| 日韩视频一区二区三区在线播放免费观看| 欧美国产精品一区| 六十路精品视频| 欧美freesex交免费视频| 亚洲电影在线播放| 亚洲精品综合| 欧美影院成人| 国产视频在线观看一区| 亚洲一区二区视频在线| 欧美一区二区视频网站| 国内精品美女在线观看| 国产婷婷色一区二区三区| 欧美区二区三区| 欧美在线精品免播放器视频| 玖玖精品视频| 亚洲五月婷婷| 亚洲综合第一| 午夜视频久久久久久| 香蕉久久久久久久av网站| 亚洲永久免费视频| 国产欧美日韩三区| 另类图片综合电影| 亚洲一区二区三区免费观看 | 免费不卡亚洲欧美| 欧美国产成人精品| 欧美三级不卡| 国产精品久久91| 国产老女人精品毛片久久| 国产一区二区在线免费观看| 一区精品在线播放| 在线看日韩av| 在线看成人片| 亚洲国产一区视频| 欧美1级日本1级| 久久噜噜亚洲综合| 最近看过的日韩成人| 欧美18av| 亚洲午夜免费福利视频| 99国内精品| 亚洲看片网站| 国外成人性视频| 一区二区视频在线观看| 国产自产2019最新不卡| 校园激情久久| 亚洲高清在线播放| 免费看亚洲片| 亚洲欧洲日产国码二区| 新67194成人永久网站| 久久精品三级| 久久久久国产精品人| 欧美极品一区| 亚洲精品一区中文| 奶水喷射视频一区| 亚洲欧美精品伊人久久| 欧美日韩成人一区二区| 亚洲国产精品久久久久秋霞影院| 久久久久国产精品www| 久久夜色撩人精品| 久久性色av| 亚洲欧美综合另类中字| 欧美日韩亚洲一区在线观看| 一区久久精品| 久久九九国产精品| 亚洲精品综合| 国产精品一国产精品k频道56| 亚洲国产综合91精品麻豆| 久久久天天操| 麻豆国产精品777777在线| 欧美久久久久久蜜桃| 一区二区三区日韩精品| 久久一区二区三区四区| 一本久道久久综合婷婷鲸鱼| 欧美日韩国产精品一区二区亚洲| 亚洲精品一区在线| 亚洲桃色在线一区| 国产精品va在线播放| 99re6热只有精品免费观看 | 欧美午夜免费电影| 久久久久国产精品www| 欧美日韩欧美一区二区| 国产精品影音先锋| 一本大道久久精品懂色aⅴ| 亚洲国产精品综合|