IDirect3DSurface9::GetDC! 调用类似很多D3D接口的方法怎么都返回错误:“不支持此方法”?

vcPlayer 2008-09-16 11:41:19
DX8及以后的版本 与DX7 差别怎么就这么大呢:(?原来还可以用DC直接在DX里面绘图,现在怎么不行了呢?

我的要求很“简单”:就是在Surface上面绘点图,输两个字符而已。不知哪位仁兄有好的办法没?

错误:“不支持此方法”有什么更详细的说明吗:
1、接口版本不正确;
2、参数不正确;
3、接口指针错误;
……
...全文
582 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
阿高 2011-05-10
  • 打赏
  • 举报
回复
打错了,是获取。。。
阿高 2011-05-10
  • 打赏
  • 举报
回复
始终无法活动HDC,郁闷中
qq845284425 2009-07-28
  • 打赏
  • 举报
回复

mark
xqhrs232 2009-07-25
  • 打赏
  • 举报
回复
也在学习这方面的东西,MARK
vcPlayer 2008-09-18
  • 打赏
  • 举报
回复
掌嘴,就在函数下方:(!!!!!
vcPlayer 2008-09-18
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 yxz_lp 的回复:]
这个没用过,但MSDN上有说明,要获得hdc有如下限制
The following restrictions apply.

1)IDirect3DSurface9::GetDC is valid on the following formats only: D3DFMT_R5G6B5, D3DFMT_X1R5G5B5, D3DFMT_R8G8B8, and D3DFMT_X8R8G8B8. Formats that contain Alpha are not supported because the GDI implementations don't have a well-defined behavior on the alpha channel. For more information about formats, see …
[/Quote]

谢谢:)。我直接用的2008的帮助文档,所以没看见这个解释(也许是心急没发现):(,也一直怀疑是创建设备的时候指定了什么属性导致有些方法不能使用。现正埋头测试。。。。
希望有熟悉的朋友能帮我缩短这个时间:)。。。
yxz_lp 2008-09-18
  • 打赏
  • 举报
回复
这个没用过,但MSDN上有说明,要获得hdc有如下限制
The following restrictions apply.

1)IDirect3DSurface9::GetDC is valid on the following formats only: D3DFMT_R5G6B5, D3DFMT_X1R5G5B5, D3DFMT_R8G8B8, and D3DFMT_X8R8G8B8. Formats that contain Alpha are not supported because the GDI implementations don't have a well-defined behavior on the alpha channel. For more information about formats, see D3DFORMAT.
2)Only one device context per surface can be returned at a time.
3)IDirect3DSurface9::GetDC will fail if the surface is already locked. If the surface is a member of a mipmap or cubemap, IDirect3DSurface9::GetDC fails if any other mipmap or cubemap member is locked.
4)IDirect3DSurface9::GetDC fails on render targets unless they were created lockable (or, in the case of back buffers, with the D3DPRESENTFLAG_LOCKABLE_BACKBUFFER flag).
5)For surfaces not created with IDirect3DDevice9::CreateOffscreenPlainSurface, IDirect3DSurface9::GetDC will fail on default pool (D3DPOOL_DEFAULT) surfaces unless they are dynamic (D3DUSAGE_DYNAMIC) or are lockable render targets.
6)IDirect3DSurface9::GetDC will fail on D3DPOOL_SCRATCH surfaces.
vcPlayer 2008-09-18
  • 打赏
  • 举报
回复
呵呵,多谢各位同仁的帮助:)。问题已经解决一半,剩下的也在继续攻关中…………

看情况,还是要从IDirect3DSurface9::GetDC下手才行。。。。。
flm007 2008-09-18
  • 打赏
  • 举报
回复
如果别人能找到例子又何必发帖子问呢,多此一举,
俺不会,俺帮你顶,但俺不会做不懂装懂的境界
palmax 2008-09-18
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 yxz_lp 的回复:]
这个没用过,但MSDN上有说明,要获得hdc有如下限制
The following restrictions apply.

1)IDirect3DSurface9::GetDC is valid on the following formats only: D3DFMT_R5G6B5, D3DFMT_X1R5G5B5, D3DFMT_R8G8B8, and D3DFMT_X8R8G8B8. Formats that contain Alpha are not supported because the GDI implementations don't have a well-defined behavior on the alpha channel. For more information about formats, see …
[/Quote]

说得很清楚了

常见的就是在 锁住表面后又去 GetDC,因为GetDC会自动锁表面
vcPlayer 2008-09-16
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 DRACULAX05 的回复:]
DX9的版本已经把DC和Surface分开了,画图就用纹理,输出文字可以用ID3DXFont
[/Quote]

谢谢!这就去测试。。。
DRACULAX05 2008-09-16
  • 打赏
  • 举报
回复
DX9的版本已经把DC和Surface分开了,画图就用纹理,输出文字可以用ID3DXFont
zhoujianhei 2008-09-16
  • 打赏
  • 举报
回复
DX8和DX9都有例子啊,参照一下。

19,469

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 图形处理/算法
社区管理员
  • 图形处理/算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧