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

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

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

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

在創(chuàng)建頂點(diǎn)緩沖區(qū)之前,需要先定義一個(gè)表示頂點(diǎn)的結(jié)構(gòu)類型,描述頂點(diǎn)保存格式的FVF和一個(gè)保存頂點(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將要對(duì)頂點(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)識(shí)符

說明

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

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


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


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


公告

導(dǎo)航

統(tǒng)計(jì)

常用鏈接

隨筆分類(178)

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

搜索

最新評(píng)論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            欧美一级二区| 欧美国产一区二区三区激情无套| 亚洲高清久久| 欧美va亚洲va国产综合| 91久久精品国产91久久| 亚洲狠狠丁香婷婷综合久久久| 免费日韩成人| 99精品视频免费观看视频| 日韩午夜在线播放| 国产精品一香蕉国产线看观看 | 欧美三级日韩三级国产三级| 亚洲性线免费观看视频成熟| 亚洲一区中文字幕在线观看| 国产综合久久久久影院| 欧美第一黄色网| 欧美日韩一区在线观看| 欧美亚洲免费在线| 久久久久久久国产| 99这里只有精品| 亚洲影视综合| 亚洲激情国产精品| 亚洲夜间福利| 亚洲电影一级黄| 在线一区二区三区做爰视频网站| 国产乱码精品一区二区三区忘忧草 | 午夜精品久久久久久久蜜桃app| 亚洲欧美日韩区| 亚洲风情在线资源站| av不卡在线| 在线欧美电影| 亚洲欧美精品一区| 亚洲国产日韩欧美在线图片| 亚洲一区二区三区在线看| 伊人天天综合| 制服丝袜激情欧洲亚洲| 亚洲高清一二三区| 性欧美激情精品| 国产精品99久久久久久www| 久久久久久久999精品视频| 亚洲手机视频| 欧美α欧美αv大片| 久久久国产精品亚洲一区 | 欧美日韩国产综合在线| 久久亚洲高清| 国产女同一区二区| aⅴ色国产欧美| 日韩一区二区高清| 免费成人高清| 老鸭窝亚洲一区二区三区| 国产精品色一区二区三区| 亚洲黄色免费电影| 亚洲大黄网站| 久久精品国产综合| 欧美一区二区在线播放| 国产精品vvv| 99视频国产精品免费观看| 91久久在线播放| 一区二区三区在线不卡| 欧美一区二区三区四区视频 | 久久综合久久综合九色| 国产精一区二区三区| 一本久道久久综合中文字幕| 亚洲美女黄色片| 欧美电影电视剧在线观看| 欧美激情精品久久久六区热门 | 亚洲免费影视第一页| 欧美日本一道本在线视频| 欧美激情视频一区二区三区免费| 在线观看日韩专区| 麻豆成人精品| 91久久中文| 国产视频精品xxxx| 亚洲人成7777| 国产欧美一区二区三区久久人妖| 99热在线精品观看| 亚洲一区中文字幕在线观看| 国产精品都在这里| 午夜精品999| 久久一二三区| 最新国产成人av网站网址麻豆| 欧美1区2区3区| 亚洲美女网站| 欧美一区午夜视频在线观看| 国产综合视频| 欧美成人精品福利| 一区二区三区四区精品| 欧美一级大片在线免费观看| 国产主播精品在线| 免费观看日韩av| 一本一本a久久| 久久久久88色偷偷免费| 亚洲精品视频在线| 久久精品亚洲一区| 欧美超级免费视 在线| 国产在线乱码一区二区三区| 亚洲国产激情| 亚洲欧美日韩精品| 激情欧美国产欧美| 欧美金8天国| 性做久久久久久久免费看| 欧美顶级艳妇交换群宴| 亚洲午夜精品久久| 加勒比av一区二区| 欧美日韩一区二区在线视频| 欧美伊人影院| 日韩一级黄色大片| 欧美va天堂va视频va在线| 在线综合欧美| …久久精品99久久香蕉国产| 欧美性一区二区| 欧美成人精品| 久久激情网站| 亚洲香蕉网站| 亚洲国产一区二区视频| 久久久久久久久岛国免费| 欧美日韩久久不卡| 国产一区香蕉久久| 国产精品美女999| 亚洲欧美成人网| 亚洲日本免费| 欧美成人高清| 久久九九热免费视频| 亚洲制服av| 亚洲毛片av在线| 影音先锋日韩资源| 国产日韩欧美精品在线| 国产精品a久久久久| 欧美片在线播放| 欧美风情在线| 免费亚洲一区二区| 久久一区二区三区av| 欧美在线999| 亚洲综合久久久久| 亚洲手机在线| 一区二区欧美激情| 日韩亚洲欧美在线观看| 亚洲区一区二区三区| 亚洲黄色免费| 欧美激情视频网站| 欧美黄色视屏| 亚洲视频欧美在线| 噜噜噜躁狠狠躁狠狠精品视频| 国产精品日韩精品欧美精品| 欧美日韩精品是欧美日韩精品| 鲁大师成人一区二区三区| 久久久久久噜噜噜久久久精品| 性久久久久久| 久久国产日韩| 久久综合国产精品台湾中文娱乐网| 午夜亚洲视频| 久久久久久久久久看片| 久久久久免费视频| 欧美91大片| 欧美日本韩国在线| 欧美亚洲成人精品| 国产精品日韩欧美综合| 国产视频亚洲精品| 黄色精品一区| 最新日韩在线| 亚洲视频第一页| 欧美一区二区高清在线观看| 久久免费视频在线| 亚洲高清不卡| 一区二区日韩欧美| 欧美一区二区三区日韩视频| 亚洲精品乱码久久久久久黑人 | 日韩网站在线观看| 一区二区激情视频| 亚洲欧洲99久久| 久久综合狠狠综合久久综青草 | 小黄鸭视频精品导航| 久久精品国产99国产精品| 免播放器亚洲一区| 欧美午夜一区二区| 狠狠色丁香婷婷综合影院| 亚洲日本中文字幕| 新片速递亚洲合集欧美合集| 美女啪啪无遮挡免费久久网站| 亚洲激情欧美激情| 亚洲欧美另类在线观看| 蘑菇福利视频一区播放| 国产精品黄视频| 亚洲国产99| 性欧美超级视频| 亚洲国产精品视频一区| 亚洲综合色丁香婷婷六月图片| 久久夜色精品国产噜噜av| 国产精品白丝黑袜喷水久久久| 在线播放视频一区| 亚洲欧美在线高清| 91久久在线视频| 久久久精品国产99久久精品芒果| 欧美日韩精品不卡| 一色屋精品视频在线看 | 国产亚洲毛片| 亚洲一级免费视频| 亚洲电影网站| 久久野战av| 国外精品视频| 欧美亚洲一区二区在线|