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

天行健 君子當自強而不息

坐標系與基本圖元(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导航| 99亚洲一区二区| 国产一区日韩欧美| 欧美视频一区二区三区| 久久偷看各类wc女厕嘘嘘偷窃| 亚洲一区二区在线观看视频| 亚洲日本乱码在线观看| 欧美在线一级va免费观看| 一区二区av在线| 亚洲乱码国产乱码精品精98午夜| 亚洲成色www8888| 狠狠色伊人亚洲综合成人| 国产女精品视频网站免费| 国产精品黄色| 欧美日在线观看| 欧美欧美天天天天操| 美腿丝袜亚洲色图| 久久蜜桃资源一区二区老牛 | 日韩一级大片在线| 亚洲国产精品久久久久婷婷老年 | 欧美不卡高清| 久久性天堂网| 久久这里只有| 老司机精品久久| 美女黄毛**国产精品啪啪| 久久久久久久久久久久久久一区| 性色av香蕉一区二区| 亚洲欧美国内爽妇网| 亚洲天堂视频在线观看| 中文日韩欧美| 亚洲欧美另类在线| 午夜亚洲视频| 久久er精品视频| 久久免费精品视频| 免费在线欧美黄色| 亚洲国产精品一区二区www| 亚洲高清不卡在线| 亚洲精品久久7777| 夜夜嗨av一区二区三区| 国产精品99久久久久久人 | 亚洲免费人成在线视频观看| 亚洲宅男天堂在线观看无病毒| 亚洲一区二区三区四区五区黄| 亚洲视频在线观看网站| 亚洲女人天堂成人av在线| 香港成人在线视频| 久久精品视频一| 麻豆精品国产91久久久久久| 欧美精品一区三区在线观看| 国产精品va在线| 国产亚洲精品久久久久婷婷瑜伽| 国内精品美女av在线播放| 亚洲第一精品电影| 99av国产精品欲麻豆| 亚洲砖区区免费| 久久精品国产亚洲aⅴ| 免费观看在线综合| 亚洲精品日韩精品| 亚洲专区一区| 麻豆久久婷婷| 国产精品久久久久久久9999 | 亚洲国产欧洲综合997久久| 最新国产精品拍自在线播放| 亚洲图片你懂的| 久久久久久自在自线| 欧美日本在线看| 国产精品手机视频| 亚洲福利在线看| 亚洲一区免费视频| 开心色5月久久精品| 91久久亚洲| 午夜精品久久久久| 欧美顶级少妇做爰| 国产欧美日韩亚洲一区二区三区| 亚洲国产精品一区二区久| 亚洲制服欧美中文字幕中文字幕| 浪潮色综合久久天堂| 99re热这里只有精品免费视频| 欧美一区1区三区3区公司| 欧美www视频| 国产欧美一区二区三区在线看蜜臀| 亚洲韩国青草视频| 欧美一区午夜精品| 亚洲黄色尤物视频| 欧美资源在线| 欧美性开放视频| 亚洲日本免费| 久久久亚洲国产天美传媒修理工 | 在线成人激情黄色| 亚洲一区二区三区四区视频 | 亚洲综合日韩中文字幕v在线| 欧美顶级大胆免费视频| 国产综合色在线视频区| 亚洲一区二区三区精品在线观看| 欧美成年视频| 亚洲女女女同性video| 欧美大片在线看| 狠狠久久亚洲欧美专区| 午夜精品久久久久| 亚洲精品欧美| 久久久精品视频成人| 国产精品一区免费在线观看| 一本色道88久久加勒比精品| 免费观看亚洲视频大全| 性做久久久久久| 欧美性猛交视频| 日韩亚洲一区在线播放| 欧美大成色www永久网站婷| 欧美亚洲专区| 国产精品网站在线| 中日韩美女免费视频网站在线观看| 欧美成人免费视频| 久久gogo国模啪啪人体图| 国产精品蜜臀在线观看| 99热这里只有精品8| 亚洲第一精品电影| 久久这里只有精品视频首页| 国产综合在线视频| 欧美自拍偷拍| 亚洲欧美日韩精品在线| 国产精品久线观看视频| 亚洲午夜精品网| 亚洲美女av在线播放| 欧美激情亚洲国产| 亚洲九九爱视频| 亚洲国产日韩精品| 欧美激情欧美狂野欧美精品| 亚洲欧洲在线视频| 亚洲国产成人精品女人久久久| 久久综合狠狠综合久久综合88| 精品成人在线视频| 免费日韩视频| 米奇777在线欧美播放| 亚洲国产精品国自产拍av秋霞| 欧美.www| 免费欧美日韩| 韩国av一区| 欧美成年人网站| 欧美国产日韩在线观看| 亚洲精品欧美在线| 亚洲人在线视频| 欧美色视频日本高清在线观看| 亚洲香蕉在线观看| 亚洲免费在线视频| 国产一区三区三区| 麻豆久久久9性大片| 欧美成人xxx| 日韩亚洲视频| 一区二区三区久久精品| 国产日产亚洲精品| 久久综合一区二区三区| 免费久久久一本精品久久区| 在线午夜精品| 亚洲欧美国产一区二区三区| 国产一区二区按摩在线观看| 久热国产精品视频| 欧美成人嫩草网站| 亚洲一区二区三区午夜| 销魂美女一区二区三区视频在线| 极品av少妇一区二区| 亚洲国产免费| 国产精品福利在线| 久久精品在线| 欧美xart系列在线观看| 亚洲欧美中文另类| 久久精品国产第一区二区三区| 亚洲国产视频一区| 一区二区av在线| 国产曰批免费观看久久久| 亚洲大片在线观看| 国产精品久久久久久久电影| 久久看片网站| 欧美韩日一区| 欧美一区二区三区男人的天堂 | 亚洲欧洲一区二区三区在线观看| 9色精品在线| 国产一本一道久久香蕉| 欧美激情亚洲国产| 国产精品久久久一本精品| 久久综合电影| 欧美日本亚洲韩国国产| 欧美一区二区三区在| 美女日韩在线中文字幕| 亚洲综合激情| 麻豆成人小视频| 欧美在线视频观看免费网站| 美女网站久久| 午夜一级久久| 欧美极品在线视频| 久久国产精品一区二区三区| 欧美成人免费网站| 久久gogo国模裸体人体| 欧美黄网免费在线观看| 久久久美女艺术照精彩视频福利播放 | 最新中文字幕亚洲| 国产真实久久| 99热在线精品观看| 永久域名在线精品|