游戏开发论坛

 找回密码
 立即注册
搜索
查看: 3210|回复: 7

D3D将缓冲渲染到窗口时,能否指定窗口的某些区域不被写入?

[复制链接]

7

主题

16

帖子

18

积分

新手上路

Rank: 1

积分
18
发表于 2005-12-28 11:10:00 | 显示全部楼层 |阅读模式
比如,Present时,我想让窗口上某个矩形不被缓冲区的图像更新

36

主题

1047

帖子

1147

积分

金牌会员

Rank: 6Rank: 6

积分
1147
发表于 2005-12-28 11:30:00 | 显示全部楼层

Re:D3D将缓冲渲染到窗口时,能否指定窗口的某些区域不被写

present 参数里有。

7

主题

16

帖子

18

积分

新手上路

Rank: 1

积分
18
 楼主| 发表于 2005-12-28 11:48:00 | 显示全部楼层

Re: D3D将缓冲渲染到窗口时,能否指定窗口的某些区域不被

HRESULT Present(
CONST RECT *pSourceRect,
CONST RECT *pDestRect,
HWND hDestWindowOverride,
CONST RGNDATA *pDirtyRegion
);
Parameters
pSourceRect
[in] Pointer to a value that must be NULL unless the swap chain was created with D3DSWAPEFFECT_COPY or D3DSWAPEFFECT_COPY_VSYNC. pSourceRectis a pointer to a RECT structure containing the source rectangle. If NULL, the entire source surface is presented. If the rectangle exceeds the source surface, the rectangle is clipped to the source surface.
pDestRect
[in] Pointer to a value that must be NULL unless the swap chain was created with D3DSWAPEFFECT_COPY or D3DSWAPEFFECT_COPY_VSYNC. PDestRect is a pointer to a RECT structure containing the destination rectangle, in window client coordinates. If NULL, the entire client area is filled. If the rectangle exceeds the destination client area, the rectangle is clipped to the destination client area.
hDestWindowOverride
[in] Pointer to a destination window whose client area is taken as the target for this presentation. If this value is NULL, then the hWndDeviceWindow member of D3DPRESENT_PARAMETERS is taken.
pDirtyRegion
[in] This parameter is not used and should be set to NULL.

我的理解是,Present最多只能指定源矩形和目标矩形,而我要达到的目标是
在目标矩形中去除某些部分不被写入

1

主题

50

帖子

50

积分

注册会员

Rank: 2

积分
50
发表于 2005-12-28 15:03:00 | 显示全部楼层

Re:D3D将缓冲渲染到窗口时,能否指定窗口的某些区域不被写

可以,但不能指望present
学一下stencil buffer吧。

8

主题

182

帖子

268

积分

中级会员

Rank: 3Rank: 3

积分
268
发表于 2005-12-29 16:24:00 | 显示全部楼层

Re:D3D将缓冲渲染到窗口时,能否指定窗口的某些区域不被写

窗口上某个矩形不被缓冲区的图像更新 这个到是能做到。假设不希望窗口中间1/3的部分不想更新,那么你需要4个矩阵来更新你其余部分,代码大概如下。
           RECT rc;
                for(DWORD di=0;di<m_dwClearRectCount;di++)
                {
                        rc.left=m_prcClearRect[di].x1;
                        rc.right=m_prcClearRect[di].x2;
                        rc.top=m_prcClearRect[di].y1;
                        rc.bottom=m_prcClearRect[di].y2;
                        if(rc.left>=rc.right || rc.top>=rc.bottom)
                                continue;
                        V(pDevice-&gtresent(&rc,&rc,m_hWnd,NULL));
                }
再注意了解一下 D3DSWAPEFFECT_COPY。

132

主题

1341

帖子

1341

积分

金牌会员

Rank: 6Rank: 6

积分
1341
发表于 2005-12-29 19:30:00 | 显示全部楼层

Re:D3D将缓冲渲染到窗口时,能否指定窗口的某些区域不被写

如果是为了实现赃矩形的算法,则使用5楼方法,但我觉得楼主不是这个目的,所以应该用4楼所说的模板去实现

72

主题

447

帖子

454

积分

中级会员

Rank: 3Rank: 3

积分
454
QQ
发表于 2006-6-1 14:15:00 | 显示全部楼层

Re:D3D将缓冲渲染到窗口时,能否指定窗口的某些区域不被写

我想楼主的意思跟我差不多,就是想绘制文本框
但是每次文本框都被刷新了,所以想画出一个区域不刷新。请问pDevice-&gtresent(NYULL,NULL,NYULL,NULL);中最后一个参数可以实现吗?

13

主题

978

帖子

978

积分

高级会员

Rank: 4

积分
978
发表于 2006-6-1 15:57:00 | 显示全部楼层

Re:D3D将缓冲渲染到窗口时,能否指定窗口的某些区域不被写

模板缓冲才是王道啊!
不过我咋就看不懂DX9.0b的那个例子是啥意思涅?
郁闷ing
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-1-24 15:31

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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