Strange texture load anomaly
Hi. I am sort of rebuilding in a new Visual C++ project an older one
that I began after learning how DirectX, specifically Direct3D retained mode, displays 3D objects. The first project was an attemp to go beyond simple viewing and make a 3D modeling program, but it was kind of a haphazardly organized thing with only an object hierarchy architecture thought out. I determined to redo as though from scratch all the functionality I did have only this one would be completely modular and object oriented. Using the old project, which works correctly, I have been reached the point where the Viewports can display what's in a frame hierarchy.
The problem is that the test object that is supposed to have a texture
that a load texture callback function loads when the MeshBuilder2's load function is called gets displayed without the texture. I encountered that problem inside the project folder of the old editor earlier on. After a diagnosis attempt to enumerate the colors on my
old computer and the new one that I am now running both projects on, I found the answer to be a lot simpler. I had to copy all relevant files onto a flash drive and use that to put them on my new computer and though I had copied the X file into old editor's folder, I had failed to copy a tex1.ppm file that's name was in the X file. Putting that file in there as well fixed it. Naturally, I though the same thing must be the problem with the new one when I first tested it and it didn't display the texture. I was wrong.
The ppm file and that X file are both in the new editor's folder. I compiled versions that had a SetCurrentDirectory call to where it was and ones with that line commented out, but no good. I even changed the source code of the old editor where it set its directory to point
into the new editor's folder instead and it displays the object right. I ran a test with the same code pasted into both programs to GetImage from the texture (which by the way claims to have loaded just fine-D3DRM_OK) and then write all the bytes of the pallete it indicates it uses and the actual image buffer itself to a file. I then compared them with a routine, byte for byte, and both the file the old editor which does still display right and the new one which does not are identical.
Clearly, I am missing something. It cannot be a difference in my old computer and my new one that causes this because both the running copy of my old editor and the new one are doing different things on the same machine. It can't be the fact that my old computer ran Windows 98 and the new one is Windows XP, nor the old one's DirectX version 5.0 only versus the new computer's DirectX 9.0 for the same reason. Both programs use only the calls, and the same ones, that work in one but not the other project. Besides, though I would like to explore what new wonders seem to be available in the new version, my copy of Visual C++ is the Standard 6.0 version which had only header files for up to DirectX 5.0. I know the answer is therefore locked in the code, but everything I can think of has failed to resolve it. I even tried reordering the D3DRM objects' creation and setup calls so that just as in the old one, the MeshBuilder load call happens after the retained mode device is created (though admittedly, the viewports get created before the object too, which is unlike the old version).
I don't know if its order of events, but any help on understanding exactly what DirectX does to load an object from an X file with a file named texture reference would probably help shed light on it. I can't really proceed if I have a problem I don't understand with something as crucial to a 3D modeling program as textures. Thank you for any help. Sorry about the long post.
|