Get Unknown error when CreateTextureFromFile

Last post 05-08-2008, 11:30 AM by David Hunt. 2 replies.
Sort Posts: Previous Next
  •  05-08-2008, 8:25 AM

    Get Unknown error when CreateTextureFromFile

    Hello.

    When I tried to load a texture (a BMP file) with DX10, I get an unknown HRESULT with CreateShaderResourceView.

    In order to be sure what the real problem with, I try the CreateTextureFromFile, but I get the same "unknown" HRESULT.

    Here is the code I am using.

    void DoTexture(void)
    {
      TCHAR szDirectorio[MAX_PATH];
      LPWSTR archivotextura;
      GetCurrentDirectory(sizeof(szDirectorio)-1, szDirectorio);
      archivotextura=szDirectorio;

      StringCchCat(archivotextura, MAX_PATH, L"\\marmol.BMP");

      D3DX10_IMAGE_LOAD_INFO infocarga;
      //ID3D10ShaderResourceView* recursoshader=NULL;
      ID3D10Resource* recursoshader=NULL;
      D3D10_SHADER_RESOURCE_VIEW_DESC* desctext=NULL;

      ZeroMemory(&infocarga, sizeof(infocarga));
      infocarga.BindFlags=D3D10_BIND_SHADER_RESOURCE;
      infocarga.Format=DXGI_FORMAT_BC1_UNORM;

      HRESULT hr;

      hr=D3DX10CreateTextureFromFile(d3ddev, archivotextura, &infocarga, NULL, &recursoshader, NULL);
      //hr=D3DX10CreateShaderResourceViewFromFile(d3ddev, archivotextura, &infocarga, NULL, &recursoshader, NULL);
      MessageBox(hWnd, DXGetErrorString(hr), L"Error", MB_OK);
      //recursoshader->GetDesc(desctext);
    }
    What can be happening?
  •  05-08-2008, 11:12 AM

    Re: Get Unknown error when CreateTextureFromFile

    Just solved.

    The problem was that the bitmap file wasn't located on the directory it should be. Althought the linker puts the result files on one directory and executes it from there (what seems to me) the actual "working directory" is another one.

  •  05-08-2008, 11:30 AM

    Re: Get Unknown error when CreateTextureFromFile

    You can change the working directory used when debugging under Project Properties/Debug (or something like that).

     

View as RSS news feed in XML
©2007 Microsoft Corporation. All rights reserved. Privacy Statement Terms of Use Code of Conduct Feedback