Point sprites using ID3DXSprite

Started by
-1 comments, last by PumpkinPieman 19 years, 3 months ago
Right now I have a sprite class that retrieves a sprite interface from the graphics class, with this class I can render sprites to a dimention. So if my dimension was set at 640x480, and the screen is 1280x1024 the sprites would be displayed at 2X the scale to compensate for the screen difference. Now I want to beable to use point sprites and since I have this class I was kind of hoping I could make use of it in the same way. Now I believe that if a flag of D3DXSPRITE_SORT_DEPTH_BACKTOFRONT or D3DXSPRITE_SORT_DEPTH_FRONTTOBACK is supplied to Begin() then it will use the z-buffer to sort all of the quads that are rendered. What I'm wondering is if I supply a z value will it change the scale of the sprites (I'm trying to avoid that)? Here's my current Draw function:

bool cSprite::Draw()
    {
        if(graphics == NULL || texture == NULL)
            return false;
        if(graphics->GetSprite() == NULL)
            return false;

        D3DXMATRIX mat;
        float AspectX = graphics->GetWidth() / m_view.x;
        float AspectY = graphics->GetHeight() / m_view.y;

        D3DXVECTOR2 tempcenter((m_center.x * AspectX), (m_center.y * AspectY));
        D3DXVECTOR2 temptranslation((m_position.x * AspectX), (m_position.y * AspectY));    
        D3DXVECTOR2 tempscale((m_scale.x * AspectX), (m_scale.y * AspectY));

        D3DXMatrixTransformation2D(&mat,NULL,0.0,&tempscale,&tempcenter,m_rotation,&temptranslation);
        graphics->GetSprite()->SetTransform(&mat);

        return SUCCEEDED(graphics->GetSprite()->Draw(texture->GetTexture(), &pSrcRect, NULL, NULL, m_colour));
    };


This topic is closed to new replies.

Advertisement