none
CA2W

    Question

  • i have this function.....that wll be caled inrender.cpp as follow  =>  LoadModel(&gridbox, TEXT("GridBox.x"));

    there is a error => error C2664: 'D3DXCreateTextureFromFileA' : cannot convert parameter 2 from 'ATL::CA2WEX<>' to 'LPCSTR'

     

    void LoadModel(MODEL* Model, LPCTSTR File)
    {
        LPD3DXBUFFER bufMaterial;

        D3DXLoadMeshFromX(File,
                          D3DXMESH_SYSTEMMEM,
                          d3ddev,
                          NULL,
                          &bufMaterial,
                          NULL,
                          &Model->numMaterials,
                          &Model->Mesh);

        D3DXMATERIAL* tempMaterials = (D3DXMATERIAL*)bufMaterial->GetBufferPointer();

        Model->Material = new D3DMATERIAL9[Model->numMaterials];
        Model->Texture = new LPDIRECT3DTEXTURE9[Model->numMaterials];

        for(DWORD index = 0; index < Model->numMaterials; index++)
        {
            Model->Material[index] = tempMaterials[index].MatD3D;
            Model->Material[index].Ambient = Model->Material[index].Diffuse;

            USES_CONVERSION;
            if(FAILED(D3DXCreateTextureFromFile(d3ddev,
                                                CA2W(tempMaterials[index].pTextureFilename),
                                                &Model->Texture[index])))
                Model->Texture[index] = NULL;
        }

    can anyone help me wat is CA2W ...caz error show me this line got problem,,thanks m online to see the result...

    regards Omid

    Saturday, April 24, 2010 3:09 PM

Answers

  • Hello OMid80,

    1. The message does not actually indicate an error. The dinput.h file is indeed found and is being used.

    2. It comes from the following part of the dinput.h file :

    /*
     *  To build applications for older versions of DirectInput
     *
     *  #define DIRECTINPUT_VERSION [ 0x0300 | 0x0500 | 0x0700 ]
     *
     *  before #include <dinput.h>.  By default, #include <dinput.h>
     *  will produce a DirectX 8-compatible header file.
     *
     */

    #define DIRECTINPUT_HEADER_VERSION  0x0800
    #ifndef DIRECTINPUT_VERSION
    #define DIRECTINPUT_VERSION         DIRECTINPUT_HEADER_VERSION
    #pragma message(__FILE__ ": DIRECTINPUT_VERSION undefined. Defaulting to version 0x0800")
    #endif

    3. Read and follow the important instructions in the comments (which I have highlighted in bold).

    - Bio.

    Sunday, April 25, 2010 5:56 AM

All replies

  • Hello OMid80,

     

    1. Since your are using TCHAR types, e.g. the "File" parameter to LoadMode() is of type LPCTSTR :

    void LoadModel(MODEL* Model, LPCTSTR File)

    You should be consistent and use the ATL::CA2CTEX() macro instead of the ATL::CA2W() macro.

     

    2. ATL::CA2CTEX() converts an ANSI string to a generic character string (which is set to a wide character string when _UNICODE is defined, otherwise is set to an ANSI string).

     

    3. Note that the D3DXCreateTextureFromFile() function itself takes an LPCTSTR type for the second parameter.

     

    Hope this will help,

    - Bio.

    Saturday, April 24, 2010 4:06 PM
  • >c:\program files\microsoft directx sdk (august 2009)\include\dinput.h: DIRECTINPUT_VERSION undefined. Defaulting to version 0x0800

    may u explain this error...cant not open  dinput.h

    wat to do to open it i also include it

     

    Saturday, April 24, 2010 5:48 PM
  • Hello OMid80,

    1. The message does not actually indicate an error. The dinput.h file is indeed found and is being used.

    2. It comes from the following part of the dinput.h file :

    /*
     *  To build applications for older versions of DirectInput
     *
     *  #define DIRECTINPUT_VERSION [ 0x0300 | 0x0500 | 0x0700 ]
     *
     *  before #include <dinput.h>.  By default, #include <dinput.h>
     *  will produce a DirectX 8-compatible header file.
     *
     */

    #define DIRECTINPUT_HEADER_VERSION  0x0800
    #ifndef DIRECTINPUT_VERSION
    #define DIRECTINPUT_VERSION         DIRECTINPUT_HEADER_VERSION
    #pragma message(__FILE__ ": DIRECTINPUT_VERSION undefined. Defaulting to version 0x0800")
    #endif

    3. Read and follow the important instructions in the comments (which I have highlighted in bold).

    - Bio.

    Sunday, April 25, 2010 5:56 AM
  • Also note that the error you posted (error C2664: 'D3DXCreateTextureFromFileA' : cannot convert parameter 2 from 'ATL::CA2WEX<>' to 'LPCSTR') is not consistent with the code you posted, as one uses LPCSTR and the other uses LPCTSTR. Reconcile these.
    Tuesday, April 27, 2010 5:04 PM