Using textured meshes without ATL

Started by
1 comment, last by MJP 15 years, 9 months ago
I've been using this tutorial to learn DX9 in C++, however when I get to textured meshes, it seems I need use of ATL in order to convert formats to display the texture. I am using VCEE, which as far as I know does not support ATL. The page is http://www.directxtutorial.com/Tutorial9/C-Direct3DMeshes/dx9C3.aspx#still Here is the section of code in question. for(DWORD i = 0; i < numMaterials; i++) // for each material... { material = tempMaterials.MatD3D; // get the material info material.Ambient = material.Diffuse; // make ambient the same as diffuse USES_CONVERSION; // allows certain string conversions // if there is a texture to load, load it if(FAILED(D3DXCreateTextureFromFile(d3ddev, CA2W(tempMaterials.pTextureFilename), &texture))) texture = NULL; // if there is no texture, set the texture to NULL } Is there an alternative way to write this that isn't dependent on ATL?
Advertisement
You should be able to scrap the ATL code and just force the use of D3DXCreateTextureFromFileA() ('A' for narrow and 'W' for wide characters).

Otherwise you can still convert from narrow to wide using MultiByteToWideChar().

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

The bit that uses ATL is the CA2W macro, which converts an ANSI string to a wide-character string. See the D3DXMATERIAL structure always contains an ANSI string even when Unicode compilation is enabled, which means you would get an error if you tried to send it to the Unicode version of D3DXCreateTextureFromFile. Your two options are:

1. Call the ANSI version of D3DXCreateTextureFromFile, D3DXCreateTextureFromFileA and just send it the ANSI string.

2. Convert the ANSI string to ta wide-character string using MultiByteToWideChar.

This topic is closed to new replies.

Advertisement