Sign in to follow this  
RpgActioN

Meshes with textures help

Recommended Posts

I've been following a guide to help me start out with DirectX, and it's been pretty annoying in that several times the code is just downright wrong and you can tell he hasn't even tried to compile it because often there are typos that would prevent it from ever doing so if he tried and I'm rambling so I'll stop now. Anyways, the guide was this one - http://www.directxtutorial.com/Tutorial9/C-Direct3DMeshes/dx9C3.aspx - and I'm only still using it because I can't seem to find a better one, and even if I did now I'm already used to this guy's tutorial so I doubt it would be a comfortable transition and I'm rambling again.... Well, this is what I made of the bit of code changed in the init graphics function, and even though it compiles, running it results in a black screen that eats my computer for several minutes before I can get out of it:
	D3DXMATERIAL* tempMats = (D3DXMATERIAL*)bufShipMat->GetBufferPointer();
	g_shipMats = new D3DMATERIAL9[g_numShipMats]; // must new for nonconstant
	g_shipTex = new IDirect3DTexture9*[g_numShipMats];
	for (DWORD i=0; i<g_numShipMats; i++)
	{
		g_shipMats[i] = tempMats[i].MatD3D;
		g_shipMats[i].Ambient = g_shipMats[i].Diffuse;
		USES_CONVERSION; // allow for certain string conversions
		// load texture if one exists
		if(FAILED(D3DXCreateTextureFromFile(g_d3dDev,
				A2W(tempMats[i].pTextureFilename), g_shipTex)))
			g_shipTex[i] = NULL;
        }
Can you find anything fantastically wrong with it? If not, I didn't change much about his render function except a few viewplane coordinates (which have always worked thus far). The plane mesh displays fine if I don't try to load a texture, and I have the appropriate texture files in the project directory. Oh, and the message VC++ 2005 Express (that's the compiler / IDE I'm using, by the way, if you needed that) gives me if I'm fortunate enough to get back is: Unhandled exception at 0x72af758f in D3D.exe: 0xC0000005: Access violation writing location 0xcdcdcd7d. Unfortunately, I have no idea what that means.

Share this post


Link to post
Share on other sites
Quote:
Original post by RpgActioN
Unhandled exception at 0x72af758f in D3D.exe: 0xC0000005: Access violation writing location 0xcdcdcd7d.

Unfortunately, I have no idea what that means.
Nothing to do with DX really [smile]

0xCDCDCDCD is an uninitialized variable and your error is 80 bytes below this. Usually you'd get errors above it (e.g. array offsets) but the fact it's above the addressable range of most Win32 programs (0x80000000 iirc, which is why the VS flags start with letters...) would suggest, in the politest possible way, that you've buggered something up [smile]

Learn to love your debugger, place lots of breakpoints and step through the code inspecting each and every variable. Check the return code on every single function call.

hth
Jack

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