游戏开发论坛

 找回密码
 立即注册
搜索
查看: 1677|回复: 1

ID3DXFont 怎么可以加入z的值?怎么也试没效果,快疯掉了

[复制链接]

119

主题

1367

帖子

1393

积分

金牌会员

Rank: 6Rank: 6

积分
1393
发表于 2009-3-2 15:31:00 | 显示全部楼层 |阅读模式
为了绘制在屏幕上的字体能正确的被遮挡,需要给ID3DXFont 加入z值,而借助于ID3DXSprite接口
查了很多资料,似乎是这样做的,可我怎么也搞不出来

m_pSprite->Begin(D3DXSPRITE_ALPHABLEND | D3DXSPRITE_SORT_DEPTH_FRONTTOBACK);
D3DXMATRIX matrix;
D3DXMatrixIdentity(&matrix);
D3DXMatrixTranslation(&matrix, 0.0f, 0.0f, 0.5f); <-- 最后一个参数是z值

m_pSprite->SetTransform(&matrix);

m_pFont->DrawText(
                NULL,
                pMsg,
                -1, // size of string or -1 indicates null terminating string
                &rect,            // rectangle text is to be formatted to in windows coords
                format, // draw in the top left corner of the viewport
                color);
m_pSprite.End()


[em17]

119

主题

1367

帖子

1393

积分

金牌会员

Rank: 6Rank: 6

积分
1393
 楼主| 发表于 2009-3-2 16:24:00 | 显示全部楼层

Re: ID3DXFont 怎么可以加入z的值?怎么也试没效果,快疯掉了

搞定了,低级错误一个

m_pSprite->Begin(D3DXSPRITE_ALPHABLEND | D3DXSPRITE_SORT_DEPTH_FRONTTOBACK);
D3DXMATRIX matrix;
D3DXMatrixIdentity(&matrix);
D3DXMatrixTranslation(&matrix, 0.0f, 0.0f, 0.5f); <-- 最后一个参数是z值

m_pSprite->SetTransform(&matrix);

m_pFont->DrawText(
m_pSprite,  //<--- 这么低级的错误,呵呵...
pMsg,
-1, // size of string or -1 indicates null terminating string
&rect,            // rectangle text is to be formatted to in windows coords
format, // draw in the top left corner of the viewport
color);
m_pSprite.End()
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-1-20 05:07

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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