locked
DirectX RRS feed

  • Question

  • Code Block

    int CD3DRenderer::AddTexture2D(char *file, int *texId)

    {

    if(!file || !m_Device) return UGP_FAIL;

    int len = strlen(file);

    if(!len) return UGP_FAIL;

    int index = m_numTextures;

    if(!m_textureList)

    {

    m_textureList = new stD3DTexture[1];

    if(!m_textureList) return UGP_FAIL;

    }

    else

    {

    stD3DTexture *temp;

    temp = new stD3DTexture[m_numTextures + 1];

    memcpy(temp, m_textureList,

    sizeof(stD3DTexture) * m_numTextures);

    delete[] m_textureList;

    m_textureList = temp;

    }

    m_textureList[index].fileName = new char[len];

    memcpy(m_textureList[index].fileName, file, len);

    D3DCOLOR colorkey = 0xff000000;

    D3DXIMAGE_INFO info;

    if(D3DXCreateTextureFromFileEx(m_Device, (LPCWSTR)file, 0, 0, 0, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, colorkey, &info, NULL, &m_textureList[index].image) != D3D_OK) return false;

    m_textureList[index].image->SetAutoGenFilterType(D3DTEXF_LINEAR);

    m_textureList[index].image->GenerateMipSubLevels();

    m_textureList[index].width = info.Width;

    m_textureList[index].height = info.Height;

    *texId = m_numTextures;

    m_numTextures++;

    return UGP_OK;

    }

     

    this is my code I do not understand why my function breaks on

    Code Block

    if(D3DXCreateTextureFromFileEx(m_Device, (LPCWSTR)file, 0, 0, 0, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, colorkey, &info, NULL, &m_textureList[index].image) != D3D_OK) return false;

    statment while in debug. I do not know why it never return's D3D_OK.

    Can some one help me.

    Sunday, December 9, 2007 8:59 PM