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

天行健 君子當自強而不息

坐標系與基本圖元(2)

創建頂點緩沖區

在創建頂點緩沖區之前,需要先定義一個表示頂點的結構類型,描述頂點保存格式的FVF和一個保存頂點的結構數組。

struct sCustomVertex
{
float x, y, z, rhw;
DWORD color;
};
#define D3DFVF_CUSTOM_VERTEX (D3DFVF_XYZRHW | D3DFVF_DIFFUSE) 
sCustomVertex vertices[] =
{
{ 100.0f, 400.0f, 1.0f, 1.0f, 0xffffff00, },
{ 300.0f, 50.0f, 1.0f, 1.0f, 0xff00ff00, },
{ 500.0f, 400.0f, 1.0f, 1.0f, 0xffff00ff, },
};

創建頂點緩沖區的函數IDirect3DDevice9::CreateVertexBuffer()聲明如下:

Creates a vertex buffer.

HRESULT CreateVertexBuffer(
UINT Length,
DWORD Usage,
DWORD FVF,
D3DPOOL Pool,
IDirect3DVertexBuffer9** ppVertexBuffer,
HANDLE* pSharedHandle
);

Parameters

Length
[in] Size of the vertex buffer, in bytes. For FVF vertex buffers, Length must be large enough to contain at least one vertex, but it need not be a multiple of the vertex size. Length is not validated for non-FVF buffers. See Remarks.
Usage
[in] Usage can be 0, which indicates no usage value. However, if usage is desired, use a combination of one or more D3DUSAGE constants. It is good practice to match the usage parameter in CreateVertexBuffer with the behavior flags in IDirect3D9::CreateDevice. For more information, see Remarks.
FVF
[in] Combination of D3DFVF, a usage specifier that describes the vertex format of the vertices in this buffer. If this parameter is set to a valid FVF code, the created vertex buffer is an FVF vertex buffer (see Remarks). Otherwise, if this parameter is set to zero, the vertex buffer is a non-FVF vertex buffer.
Pool
[in] Member of the D3DPOOL enumerated type, describing a valid memory class into which to place the resource. Do not set to D3DPOOL_SCRATCH.
ppVertexBuffer
[out, retval] Address of a pointer to an IDirect3DVertexBuffer9 interface, representing the created vertex buffer resource.
pSharedHandle
[in] Reserved. Set this parameter to NULL.

Return Values

If the method succeeds, the return value is D3D_OK. If the method fails, the return value can be one of the following: D3DERR_INVALIDCALL, D3DERR_OUTOFVIDEOMEMORY, E_OUTOFMEMORY.

Defines the memory class that holds the buffers for a resource.

typedef enum D3DPOOL
{
D3DPOOL_DEFAULT = 0,
D3DPOOL_MANAGED = 1,
D3DPOOL_SYSTEMMEM = 2,
D3DPOOL_SCRATCH = 3,
D3DPOOL_FORCE_DWORD = 0x7fffffff,
} D3DPOOL, *LPD3DPOOL;

Constants

D3DPOOL_DEFAULT
Resources are placed in the memory pool most appropriate for the set of usages requested for the given resource. This is usually video memory, including both local video memory and AGP memory. The D3DPOOL_DEFAULT pool is separate from D3DPOOL_MANAGED and D3DPOOL_SYSTEMMEM, and it specifies that the resource is placed in the preferred memory for device access. Note that D3DPOOL_DEFAULT never indicates that either D3DPOOL_MANAGED or D3DPOOL_SYSTEMMEM should be chosen as the memory pool type for this resource. Textures placed in the D3DPOOL_DEFAULT pool cannot be locked unless they are dynamic textures or they are private, FOURCC, driver formats. To access unlockable textures, you must use functions such as IDirect3DDevice9::UpdateSurface, IDirect3DDevice9::UpdateTexture, IDirect3DDevice9::GetFrontBufferData, and IDirect3DDevice9::GetRenderTargetData. D3DPOOL_MANAGED is probably a better choice than D3DPOOL_DEFAULT for most applications. Note that some textures created in driver-proprietary pixel formats, unknown to the Direct3D runtime, can be locked. Also note that - unlike textures - swap chain back buffers, render targets, vertex buffers, and index buffers can be locked. When a device is lost, resources created using D3DPOOL_DEFAULT must be released before calling IDirect3DDevice9::Reset. For more information, see Lost Devices (Direct3D 9).

When creating resources with D3DPOOL_DEFAULT, if video card memory is already committed, managed resources will be evicted to free enough memory to satisfy the request.

D3DPOOL_MANAGED
Resources are copied automatically to device-accessible memory as needed. Managed resources are backed by system memory and do not need to be recreated when a device is lost. See Managing Resources (Direct3D 9) for more information. Managed resources can be locked. Only the system-memory copy is directly modified. Direct3D copies your changes to driver-accessible memory as needed.
D3DPOOL_SYSTEMMEM
Resources are placed in memory that is not typically accessible by the Direct3D device. This memory allocation consumes system RAM but does not reduce pageable RAM. These resources do not need to be recreated when a device is lost. Resources in this pool can be locked and can be used as the source for a IDirect3DDevice9::UpdateSurface or IDirect3DDevice9::UpdateTexture operation to a memory resource created with D3DPOOL_DEFAULT.
D3DPOOL_SCRATCH
Resources are placed in system RAM and do not need to be recreated when a device is lost. These resources are not bound by device size or format restrictions. Because of this, these resources cannot be accessed by the Direct3D device nor set as textures or render targets. However, these resources can always be created, locked, and copied.
D3DPOOL_FORCE_DWORD
Forces this enumeration to compile to 32 bits in size. Without this value, some compilers would allow this enumeration to compile to a size other than 32 bits. This value is not used.
 

創建頂點緩沖區的代碼如下:

g_device->CreateVertexBuffer(sizeof(vertices), 0, D3DFVF_CUSTOM_VERTEX, D3DPOOL_DEFAULT, &g_vertex_buffer, NULL);


現在,已經創建了頂點緩沖區g_vertex_buffer,接下來把頂點數據vertices[]中保存的頂點數據復制到頂點緩沖區中:

void* ptr;

g_vertex_buffer->Lock(0, sizeof(vertices), (void**)&ptr, 0);
memcpy(ptr, vertices, sizeof(vertices));
g_vertex_buffer->Unlock();

IDirect3DVertexBuffer9::Lock()通知Direct3D將要對頂點緩沖區進行內存操作,并獲得頂點緩沖區的內存指針,頂點數據復制完成后,IDirect3DVertexBuffer9::Unlock()通知Direct3D操作結束。

Locks a range of vertex data and obtains a pointer to the vertex buffer memory.

HRESULT Lock(
UINT OffsetToLock,
UINT SizeToLock,
VOID ** ppbData,
DWORD Flags
);

Parameters

OffsetToLock
[in] Offset into the vertex data to lock, in bytes. To lock the entire vertex buffer, specify 0 for both parameters, SizeToLock and OffsetToLock.
SizeToLock
[in] Size of the vertex data to lock, in bytes. To lock the entire vertex buffer, specify 0 for both parameters, SizeToLock and OffsetToLock.
ppbData
[out] VOID* pointer to a memory buffer containing the returned vertex data.
Flags
[in] Combination of zero or more locking flags that describe the type of lock to perform. For this method, the valid flags are:
  • D3DLOCK_DISCARD
  • D3DLOCK_NO_DIRTY_UPDATE
  • D3DLOCK_NOSYSLOCK
  • D3DLOCK_READONLY
  • D3DLOCK_NOOVERWRITE
For a description of the flags, see D3DLOCK.

Return Values

If the method succeeds, the return value is D3D_OK. If the method fails, the return value can be D3DERR_INVALIDCALL.

Remarks

When working with vertex buffers, you are allowed to make multiple lock calls; however, you must ensure that the number of lock calls match the number of unlock calls. DrawPrimitive calls will not succeed with any outstanding lock count on any currently set vertex buffer.

The D3DLOCK_DISCARD and D3DLOCK_NOOVERWRITE flags are valid only on buffers created with D3DUSAGE_DYNAMIC.

For information about using D3DLOCK_DISCARD or D3DLOCK_NOOVERWRITE with IDirect3DVertexBuffer9::Lock, see Using Dynamic Vertex and Index Buffers.

參數Flags表示頂點緩沖區的加鎖屬性,它可以取0(默認值)或者下表中任意值的邏輯或。

標識符

說明

D3DLOCK_DISCARD 更新整個緩沖區
D3DLOCK_NO_DIRTY_UPDATE 在默認狀態下,對緩沖區加鎖會對該區域設置一個Dirty標記。該屬性將不對該區域設置Dirty標記,當對緩沖區有特殊需要時使用。
D3DLOCK_NOOVERWRITE 保證不覆蓋緩沖區數據,設置該屬性可以立即返回內存指針,提高系統性能。
D3DLOCK_NOSYSLOCK 在加鎖過程中系統可以進行其他操作
D3DLOCK_READONLY 設置緩沖區為只讀屬性

執行Lock()函數需要一定的時間,默認狀態下,Direct3D會暫停其他的顯示操作,直至Lock()函數執行結束。設置D3DLOCK_NOSYSLOCK屬性,可以使Direct3D在執行對緩沖區加鎖的同時執行其他的顯示操作,比如移動鼠標。


posted on 2008-04-30 13:26 lovedday 閱讀(1417) 評論(0)  編輯 收藏 引用


只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


公告

導航

統計

常用鏈接

隨筆分類(178)

3D游戲編程相關鏈接

搜索

最新評論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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一区二区| 在线综合欧美| 新狼窝色av性久久久久久| 亚洲天堂成人在线观看| 亚洲欧美国产另类| 欧美一区影院| 毛片av中文字幕一区二区| 欧美成年人网| 亚洲精品乱码视频| 中文网丁香综合网| 久久岛国电影| 欧美激情综合在线| 国产精品一区二区久久精品| 激情综合视频| 在线视频精品一区| 久久嫩草精品久久久精品一| 亚洲高清免费视频| 一区二区三区四区五区精品| 久久成人免费网| 欧美激情一区二区三区成人| 国产精品久久久久一区| 精品不卡一区二区三区| 亚洲午夜女主播在线直播| 久久免费国产精品1| 亚洲精品美女在线观看| 欧美自拍偷拍| 国产精品乱码久久久久久| 亚洲二区在线| 欧美在线免费一级片| 91久久中文| 欧美一级视频| 国产精品久久久久久久久借妻| 永久免费精品影视网站| 亚洲欧美日韩精品在线| 亚洲国产综合91精品麻豆| 欧美专区日韩专区| 国产精品女人网站| 一区二区电影免费观看| 久久久国产精品一区| 久久爱www.| 毛片基地黄久久久久久天堂| 国产精品麻豆va在线播放| 亚洲国产三级网| 欧美主播一区二区三区| 一区二区三区免费看| 欧美电影在线观看| 激情久久影院| 久久久久99| 亚洲欧美日韩精品综合在线观看| 欧美精品在线一区| 日韩亚洲在线| 亚洲黄色尤物视频| 久久亚洲影院| 在线免费观看成人网| 蜜臀av性久久久久蜜臀aⅴ| 欧美在线1区| 红桃视频欧美| 欧美阿v一级看视频| 久久影院午夜片一区| 在线免费精品视频| 男人的天堂亚洲在线| 久久高清福利视频| 国产在线观看一区| 快射av在线播放一区| 久久深夜福利| 亚洲黄色在线观看| 亚洲人成高清| 国产精品高潮呻吟| 欧美亚洲在线| 久久国产黑丝| 亚洲国产天堂久久综合网| 亚洲国产精品va在线看黑人动漫 | 国产精品久久久久久久久动漫| 日韩网站在线| 一区二区三区不卡视频在线观看| 欧美午夜大胆人体| 欧美综合国产精品久久丁香| 久久精品论坛| 一本综合久久| 亚洲欧美激情一区| 精品成人久久| 99re6这里只有精品视频在线观看| 欧美视频免费在线| 久久久国产精品一区| 欧美成人日韩| 欧美一区2区视频在线观看| 久久精品国产77777蜜臀| 亚洲看片免费| 亚洲一区久久久| 伊人久久大香线| 99精品国产福利在线观看免费| 国产精品色网| 亚洲国产精品va在线观看黑人| 国产精品vvv| 免费看的黄色欧美网站| 国产精品h在线观看| 欧美a级在线| 国产欧美日韩亚洲精品| 亚洲一区二区三区涩| 欧美一区二区三区在线| 亚洲国产人成综合网站| 在线一区二区视频| 在线观看欧美视频| 一区二区三区视频免费在线观看| 国内精品一区二区三区| 日韩视频在线观看一区二区| 精品999网站| 亚洲字幕在线观看| 一本久道综合久久精品| 久久日韩精品| 久久三级视频| 国产久一道中文一区| 亚洲欧洲一区二区三区| 激情欧美一区二区| 亚洲欧美日韩一区在线| 亚洲一二三区在线观看| 欧美第十八页| 欧美成人激情视频| 国产日韩在线亚洲字幕中文| 一区二区91| 亚洲最新视频在线播放| 欧美二区在线看| 欧美国产亚洲精品久久久8v| 狠狠色丁香久久婷婷综合_中| 亚洲欧美清纯在线制服| 性欧美18~19sex高清播放| 欧美色播在线播放| 一级日韩一区在线观看| 亚洲一区免费观看| 欧美色偷偷大香| 在线视频精品一区| 亚洲欧美激情视频| 国产精品久久久久免费a∨大胸| 亚洲美女淫视频| 亚洲神马久久| 国产精品午夜在线观看| 亚洲女性裸体视频| 久久成人精品| 在线播放精品| 欧美韩国日本一区| 亚洲九九精品| 性做久久久久久| 国模私拍一区二区三区| 久久久免费精品| 欧美mv日韩mv亚洲| 亚洲精品乱码久久久久久黑人| 欧美精品三级在线观看| 99在线|亚洲一区二区| 亚洲影院色无极综合| 国产乱码精品一区二区三| 亚洲欧美久久久| 久久这里只精品最新地址| **网站欧美大片在线观看| 免费在线观看日韩欧美| 亚洲精品一区二区三区蜜桃久 | 麻豆国产精品777777在线| 尤妮丝一区二区裸体视频| 欧美xart系列在线观看| 亚洲久久在线| 久久福利一区| 亚洲欧洲久久| 国产精品久久久久99| 久久福利资源站| 亚洲精品裸体| 久久久久久久国产| 99精品国产福利在线观看免费| 亚洲一区国产视频| 国产色产综合色产在线视频| 亚洲一级一区| 久久久久久久久久码影片| 日韩亚洲成人av在线| 欧美一区二视频在线免费观看| 欧美国产1区2区| 91久久国产精品91久久性色| 亚洲特黄一级片| 久久精品视频导航| 久久综合给合久久狠狠色| 老司机精品久久| 亚洲精品美女在线| 国产伪娘ts一区| 麻豆成人91精品二区三区| 久久久亚洲精品一区二区三区| 欧美日韩国产丝袜另类| 久久久人成影片一区二区三区| 欧美日韩国产综合新一区| 蜜臀久久99精品久久久久久9 | 亚洲成人在线视频播放 | 国产精品久久久久av免费| 亚洲精品久久久久久久久| 亚洲欧美日韩在线一区| 黄色精品一区| 欧美图区在线视频| 久久一区二区三区国产精品 | 欧美午夜精品| 久久久久88色偷偷免费| 亚洲美女色禁图| 免费成人av在线看| 欧美一区午夜视频在线观看| 亚洲精品四区| 欧美岛国在线观看|