Sign in to follow this  
jWarr

Using textured meshes without ATL

Recommended Posts

jWarr    122
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[i] = tempMaterials[i].MatD3D; // get the material info material[i].Ambient = material[i].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[i].pTextureFilename), &texture[i]))) texture[i] = 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?

Share this post


Link to post
Share on other sites
MJP    19755
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this