游戏开发论坛

 找回密码
 立即注册
搜索
查看: 3820|回复: 5

<D3D9>求教获取BackBuffer地址的问题.

[复制链接]

2

主题

5

帖子

5

积分

新手上路

Rank: 1

积分
5
发表于 2005-7-5 11:07:00 | 显示全部楼层 |阅读模式
LPDIRECT3DSURFACE9 g_pBackBuffer = NULL;
g_pD3dDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &g_pBackBuffer);
g_pBackBuffer->LockRect(&BackBuffer, NULL, D3DLOCK_DISCARD | D3DLOCK_DONOTWAIT);

用LockRect为什么无法获取BackBuffer地址?
BackBuffer.Pitch和BackBuffer.pBits都是0.
但同样在离屏表面上却都是可以获得Pitch和pBits.
请高人指点.谢谢!!!

89

主题

822

帖子

847

积分

高级会员

Rank: 4

积分
847
发表于 2005-7-5 11:56:00 | 显示全部楼层

Re:<D3D9>求教获取BackBuffer地址的问题.

Remarks

If the D3DLOCK_DONOTWAIT flag is specified and the driver cannot lock the surface immediately, IDirect3DSurface9:ockRect will return D3DERR_WASSTILLDRAWING so that an application can use the CPU cycles while waiting for the driver to lock the surface.

The only lockable format for a depth-stencil surface is D3DFMT_D16_LOCKABLE. See D3DFORMAT.

For performance reasons, dirty regions are recorded only for level zero of a texture. Dirty regions are automatically recorded when IDirect3DSurface9::LockRect is called without D3DLOCK_NO_DIRTY_UPDATE or D3DLOCK_READONLY. See IDirect3DDevice9::UpdateTexture for more information.

A multisample back buffer cannot be locked.

This method cannot retrieve data from a surface that is is contained by a texture resource created with D3DUSAGE_RENDERTARGET because such a texture must be assigned to D3DPOOL_DEFAULT memory and is therefore not lockable. In this case, use instead IDirect3DDevice9::GetRenderTargetData to copy texture data from device memory to system memory.

121

主题

2029

帖子

2034

积分

金牌会员

Rank: 6Rank: 6

积分
2034
QQ
发表于 2005-7-5 13:04:00 | 显示全部楼层

Re:<D3D9>求教获取BackBuffer地址的问题.

在创建设备的时候注意,要把后备缓冲的Lockable打开。具体参见SDK,我忘了。

2

主题

5

帖子

5

积分

新手上路

Rank: 1

积分
5
 楼主| 发表于 2005-7-6 12:39:00 | 显示全部楼层

Re:<D3D9>求教获取BackBuffer地址的问题.

3Q!!!

3

主题

59

帖子

59

积分

注册会员

Rank: 2

积分
59
发表于 2005-7-6 13:50:00 | 显示全部楼层

Re:&lt;D3D9&gt;求教获取BackBuffer地址的问题.

伪码描述如下:
1:D3Dpp.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;  // 允许锁住后备缓冲
2:Device-&gt;GetBackBuffer( 0, D3DBACKBUFFER_TYPE_MONO, &amp;Surface)
3:D3DLOCKED_RECT d3dl_rect; (这个是32位色的版本,改为16位色很简单)
     Surface-&gt;LockRect(&amp;d3dl_rect, NULL, NULL );
     int Pitch32 = d3dl_rect.Pitch / 4;
     DWORD* p = (DWORD*) d3dl_rect.pBits;  // 这个P就是想要的东东了,尽情F吧!
     Surface-&gt;UnlockRect();

42

主题

418

帖子

418

积分

中级会员

Rank: 3Rank: 3

积分
418
发表于 2005-7-7 11:59:00 | 显示全部楼层

Re:<D3D9>求教获取BackBuffer地址的问题.

学习
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-12-26 08:29

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表