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

天行健 君子當(dāng)自強(qiáng)而不息

坐標(biāo)系與基本圖元(2)

創(chuàng)建頂點(diǎn)緩沖區(qū)

在創(chuàng)建頂點(diǎn)緩沖區(qū)之前,需要先定義一個表示頂點(diǎn)的結(jié)構(gòu)類型,描述頂點(diǎn)保存格式的FVF和一個保存頂點(diǎn)的結(jié)構(gòu)數(shù)組。

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, },
};

創(chuàng)建頂點(diǎn)緩沖區(qū)的函數(shù)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.
 

創(chuàng)建頂點(diǎn)緩沖區(qū)的代碼如下:

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


現(xiàn)在,已經(jīng)創(chuàng)建了頂點(diǎn)緩沖區(qū)g_vertex_buffer,接下來把頂點(diǎn)數(shù)據(jù)vertices[]中保存的頂點(diǎn)數(shù)據(jù)復(fù)制到頂點(diǎn)緩沖區(qū)中:

void* ptr;

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

IDirect3DVertexBuffer9::Lock()通知Direct3D將要對頂點(diǎn)緩沖區(qū)進(jìn)行內(nèi)存操作,并獲得頂點(diǎn)緩沖區(qū)的內(nèi)存指針,頂點(diǎn)數(shù)據(jù)復(fù)制完成后,IDirect3DVertexBuffer9::Unlock()通知Direct3D操作結(jié)束。

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.

參數(shù)Flags表示頂點(diǎn)緩沖區(qū)的加鎖屬性,它可以取0(默認(rèn)值)或者下表中任意值的邏輯或。

標(biāo)識符

說明

D3DLOCK_DISCARD 更新整個緩沖區(qū)
D3DLOCK_NO_DIRTY_UPDATE 在默認(rèn)狀態(tài)下,對緩沖區(qū)加鎖會對該區(qū)域設(shè)置一個Dirty標(biāo)記。該屬性將不對該區(qū)域設(shè)置Dirty標(biāo)記,當(dāng)對緩沖區(qū)有特殊需要時使用。
D3DLOCK_NOOVERWRITE 保證不覆蓋緩沖區(qū)數(shù)據(jù),設(shè)置該屬性可以立即返回內(nèi)存指針,提高系統(tǒng)性能。
D3DLOCK_NOSYSLOCK 在加鎖過程中系統(tǒng)可以進(jìn)行其他操作
D3DLOCK_READONLY 設(shè)置緩沖區(qū)為只讀屬性

執(zhí)行Lock()函數(shù)需要一定的時間,默認(rèn)狀態(tài)下,Direct3D會暫停其他的顯示操作,直至Lock()函數(shù)執(zhí)行結(jié)束。設(shè)置D3DLOCK_NOSYSLOCK屬性,可以使Direct3D在執(zhí)行對緩沖區(qū)加鎖的同時執(zhí)行其他的顯示操作,比如移動鼠標(biāo)。


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


只有注冊用戶登錄后才能發(fā)表評論。
網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


公告

導(dǎo)航

統(tǒng)計

常用鏈接

隨筆分類(178)

3D游戲編程相關(guān)鏈接

搜索

最新評論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            好吊视频一区二区三区四区 | 久久久99爱| 99在线热播精品免费| 亚洲精品1区2区| 久久综合国产精品| 久久久人成影片一区二区三区观看 | 六月婷婷一区| 欧美激情按摩在线| 欧美日韩一区二区三区在线观看免 | 西西裸体人体做爰大胆久久久| 在线视频中文亚洲| 亚洲欧美日韩精品久久亚洲区| 亚洲在线日韩| 欧美一区二区三区在线播放| 久久精品视频一| 欧美激情自拍| 99热这里只有成人精品国产| 亚洲专区一区| 玖玖综合伊人| 欧美日韩一区二区高清| 国产精品不卡在线| 极品尤物一区二区三区| 亚洲欧洲一区二区在线观看| 一区二区三区www| 香蕉久久夜色精品国产| 久久精品系列| 日韩亚洲精品视频| 欧美中文字幕在线| 欧美激情视频一区二区三区免费| 国产精品chinese| 久久亚洲国产精品日日av夜夜| 激情久久一区| 亚洲精选成人| 欧美在线亚洲一区| 欧美激情 亚洲a∨综合| 亚洲色图综合久久| 裸体歌舞表演一区二区| 欧美视频在线视频| 亚洲电影下载| 午夜在线一区| 亚洲美女av黄| 久久婷婷蜜乳一本欲蜜臀| 欧美深夜影院| 欧美成人激情视频| 免费看av成人| 欧美激情综合五月色丁香小说 | 国产精品99久久久久久久久久久久 | 国产日韩精品视频一区| 国产日韩欧美视频在线| 亚洲国产精品久久久久秋霞蜜臀| 中文av一区特黄| 嫩草国产精品入口| 亚洲欧美日韩在线观看a三区| 欧美激情第4页| 在线观看亚洲视频| 久久久久国产精品一区二区| 亚洲色图制服丝袜| 欧美激情欧美狂野欧美精品| 黄色成人免费网站| 久久精品亚洲精品| 亚洲欧美成人一区二区在线电影| 欧美乱人伦中文字幕在线| 亚洲国语精品自产拍在线观看| 久久久久久亚洲综合影院红桃| 亚洲四色影视在线观看| 欧美日韩在线不卡一区| 99国产精品久久久久久久成人热| 欧美成人一区在线| 久久国产精品免费一区| 国产亚洲精品久久久久婷婷瑜伽| 亚洲欧美亚洲| 亚洲欧美卡通另类91av| 国产精品mv在线观看| 亚洲视频欧美视频| 一本色道久久88综合亚洲精品ⅰ| 欧美日韩另类国产亚洲欧美一级| 亚洲美女色禁图| 日韩亚洲欧美综合| 国产精品久久久一本精品| 亚洲欧美日韩精品一区二区| 亚洲午夜一区| 国内精品模特av私拍在线观看 | 亚洲黄色免费电影| 亚洲一区二区三区在线| 亚洲美女啪啪| 美女免费视频一区| 亚洲三级电影全部在线观看高清| 欧美va天堂va视频va在线| 鲁大师影院一区二区三区| 亚洲毛片在线观看.| 亚洲三级国产| 国产精品久久久久免费a∨| 午夜久久久久久| 久久精品国产一区二区三| 亚洲国产日韩一级| 亚洲精品一区二区三区婷婷月| 欧美巨乳在线| 欧美一区二区三区视频在线| 久久性天堂网| 亚洲视频免费在线| 久久国产一二区| 亚洲另类自拍| 亚洲欧美精品中文字幕在线| 亚洲成色777777女色窝| 99视频在线精品国自产拍免费观看| 国产精品久久久久aaaa九色| 久久频这里精品99香蕉| 欧美日韩理论| 麻豆精品在线观看| 欧美视频二区| 欧美xxx在线观看| 国产精品成人观看视频免费| 美女在线一区二区| 欧美午夜剧场| 欧美激情在线播放| 国产亚洲欧美激情| 99riav久久精品riav| 激情欧美丁香| 亚洲欧美国内爽妇网| 亚洲日韩欧美视频| 性做久久久久久久久| 亚洲网友自拍| 免费观看一区| 久久夜色精品国产| 国产精品视频| 亚洲最新色图| 日韩天堂在线观看| 久久亚洲精品中文字幕冲田杏梨| 午夜久久福利| 国产精品久久久久9999| 亚洲伦理久久| 亚洲伦理自拍| 另类av一区二区| 久久久久久久久久久久久女国产乱 | 欧美高清成人| 免费亚洲一区二区| 国产一区二区三区在线观看视频 | 久久久久久久一区二区三区| 欧美日韩一级大片网址| 亚洲精品1234| 亚洲精品国久久99热| 日韩一级网站| 日韩视频不卡中文| 99精品国产热久久91蜜凸| 老妇喷水一区二区三区| 久久久久久久久久久一区 | 亚洲精品一区二区三| 亚洲欧洲精品一区| 欧美电影免费观看高清完整版| 麻豆久久精品| 伊甸园精品99久久久久久| 欧美在线一级va免费观看| 91久久亚洲| 欧美精品综合| 亚洲最新视频在线播放| 亚洲一区二区三| 国产精品一区久久久| 在线视频欧美精品| 欧美一区二区三区四区在线观看地址| 国产精品亚洲人在线观看| 亚洲欧美精品一区| 久久亚洲精品网站| 亚洲第一区在线观看| 蜜桃av噜噜一区二区三区| 亚洲大胆人体视频| 一道本一区二区| 国产精品久久久久久久久久尿| 亚洲曰本av电影| 久久久夜夜夜| 亚洲日本欧美在线| 欧美日韩在线三区| 欧美亚洲色图校园春色| 久久在线91| 夜夜嗨av一区二区三区网站四季av| 欧美母乳在线| 午夜精品一区二区三区在线视 | 亚洲一区999| 老**午夜毛片一区二区三区| 亚洲日本免费| 国产日韩亚洲欧美精品| 久久综合一区| 亚洲一区二区三区涩| 另类亚洲自拍| 亚洲一区二区三区四区视频| 国产一区视频观看| 欧美精品一区在线发布| 亚洲欧美精品中文字幕在线| 欧美激情第二页| 香蕉成人久久| 日韩视频在线免费| 国产一区二区主播在线| 欧美激情视频在线播放 | 母乳一区在线观看| 亚洲欧美综合v| 亚洲国产天堂网精品网站| 国产欧美午夜| 欧美日韩情趣电影| 乱人伦精品视频在线观看| 亚洲欧美日韩在线| 99在线精品视频|