C ++ Direct3D 9:D3DXSprite无法呈现

时间:2019-03-24 06:52:51

标签: c++ game-engine direct3d9

我想为我的C ++游戏引擎创建一个使用Direct3D(不是Direct2D)的GUI系统。我创建了一个D3DXSprite,分配了一个D3DXTexture,使用背景以外的另一种颜色来绘制它……仍然没有显示。我在这里做什么错了?

#include <d3dx9.h>

_Obst_PanelDx9::_Obst_PanelDx9( _Obst_Gui* owner, _Obst_Vector2& size ) : _Obst_Panel(owner)
{
    m_position = _Obst_Vector2( 0, 0 );
    m_size     = size;
    m_color    = _Obst_Vector4( 1, 1, 1, 1 );

    D3DXCreateSprite( ((_Obst_Gui*) owner)->getDisplayContext()->getD3Ddevice(), &m_sprite );
    D3DXCreateTexture( ((_Obst_Gui*) owner)->getDisplayContext()->getD3Ddevice(), m_size.x, m_size.y, 0, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &m_texture );
}

_Obst_PanelDx9::~_Obst_PanelDx9()
{
    if ( m_sprite )  m_sprite->Release();
    if ( m_texture ) m_texture->Release();
}

void _Obst_PanelDx9::render()
{
    m_sprite->Begin( D3DXSPRITE_ALPHABLEND );

    //m_sprite->Draw( m_texture, 0, 0, &D3DXVECTOR3(m_position.x, m_position.y, 0), D3DCOLOR_ARGB((int) (m_color.w * 255), (int) (m_color.x * 255), (int) (m_color.y * 255), (int) (m_color.z * 255)));

    // In order: ID3DXTexture* t, RECT* srcRect, D3DXVECTOR3* center, D3DXVECTOR3* position, D3DCOLOR color
    m_sprite->Draw( m_texture, 0, 0, &D3DXVECTOR3(0, 0, 0), 0xFFFFFFFF);

    m_sprite->End();
}

On the following image,如果我没记错的话,窗口的左上角应该有一个白色正方形。

我尝试调整alpha值,颜色,调整D3DUSAGE,D3DPOOL和D3DFORMAT枚举,设置精灵的变换矩阵,设置中心点和srcRect参数...

编辑:忘记了,我的目标是不显示图像,子画面就像面板小部件(彩色矩形)。只是ID3DXTexture包含大小值。

0 个答案:

没有答案