Jump to content
  • Advertisement
Sign in to follow this  
gangliu

poor fps

This topic is 4979 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello all I load a bitmap(800*600) to an OffeScreenSurface. I get a poor fps(28) when copy the surface to back buffer in 32 bit color. My video card is Geforce2 Mx/mx400. I guess I have maked a mistake. This is my code :
bool 
CD3DImg::LoadImg(const std::string& sPath, int w, int h,  int nRow, int nCol)
{
    if ( !m_pD3DDevice )
    {
        return false ;
    }
    Clear() ;

    m_nRow = nRow ;
    m_nCol = nCol ;

    m_nImgWidth = w ;
    m_nImgHeight = h ;

    if ( FAILED(m_pD3DDevice->CreateOffscreenPlainSurface(
                                                w, h, 
                                                m_nD3DFmt, 
                                                D3DPOOL_SYSTEMMEM,
						 &m_pLocalImg, 
                                                NULL
                                                ) ))
    {
        return false ;
    }

    m_nTransClr = 0 ;

    if ( FAILED(D3DXLoadSurfaceFromFile(
                                m_pLocalImg, 
                                NULL, NULL, 
                                sPath.c_str(), 
                                NULL, 
                                D3DX_FILTER_NONE,
				m_nTransClr, 
                                NULL) ))
    {
        return false;
    }
    
    return true ;
}

bool
CD3DImg::Draw()
{
    IDirect3DSurface9* pBackBuffer ;
    
    //reference count ++
    if ( FAILED(m_pD3DDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer)) )
    {
        return false ;
    }
    
    FreeDxRes<IDirect3DSurface9> freeRes1(pBackBuffer) ;

    RECT rc;
    POINT pt ;
    HRESULT hr ;

    int nFrameW, nFrameH ;
    int nRow, nCol ;

    nRow = m_nCurFrame/m_nCol ;
    nCol = m_nCurFrame%m_nCol ;
    nCol = std::max<int>(nCol, 0)  ;

    ASSERT(m_nRow&&m_nCol) ;
    nFrameH = abs(m_nImgHeight)/m_nRow ;
    nFrameW = abs(m_nImgWidth)/m_nCol ;

    rc.top  = (float)nRow*nFrameH;
    rc.left = (float)nCol*nFrameW;
    rc.right  = rc.left+nFrameW ;
    rc.bottom = rc.top+nFrameH ;

    pt.x = m_Rect.left;
    pt.y = m_Rect.top ;

    hr = m_pD3DDevice->UpdateSurface(
                        m_pLocalImg, 
                        &rc,
                        pBackBuffer,
                        &pt
                        )  ;
    
    if ( FAILED(hr))
    {
        return false ;
    }

    return true ;
 }
 
Thanks for your any advice .

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!