DirectX 9 w/DXUT & C++ Sprite/Device problem

Started by
7 comments, last by Corvwyn 14 years, 3 months ago
I've been making a game engine based on the architecture in the book Game Coding Complete by Mike McShaffry. When I began trying to draw sprites I'm not able to create a valid texture with the D3DXCreateTextureFromFile or ..Ex function. The texture name just ends up scrambled with chinese letters, the resolution is also incorrect. After some debugging I found out that the d3ddevice parameters are all mixed up, the resolution is where the refresh rate should be, for example. The actual resolution seems to be correct though. I'm using the core game engine in a static library (.lib) and running a game implementation on top of that. I haven't used much of the code in the book, since I've rewritten most of it from scratch. Any ideas what the problem could be? I'm at work now, but I could include some screens later if that would help. I thought I'd ask before making an svn branch and making some drastic changes to find out.
Advertisement
Quote:When I began trying to draw sprites I'm not able to create a valid texture

The Creation of the texture is not in the OnD3D9FrameRender() but in the OnD3D9CreateDevice()

Quote:The texture name just ends up scrambled with chinese letters

I'm not sure but try to use D3DXCreateTextureFromFileA() and not D3DXCreateTextureFromFile

I don't understand the problem of resolution, Actually, I think that a screen of your Sprite is required if you want more [help]

++
Have a great day!Richard Geslot, 3D game developermy 3D creation
Maybe I was a bit imprecise with my descriptions.

I create the texture in DeviceReset (DXUTSetCallbackD3D9DeviceReset) and I draw it in FrameRender.

I've tried using D3DXCreateTextureFromFile too, the reason I'm using the ExA version is to set transparency etc.

You can see my problem in these screens:

D3D9Device problem:


Texture problem:


[Edited by - Corvwyn on January 6, 2010 6:57:35 AM]
I don't know if it's helpful, but here is my method :

	//the file exist ?	if ( INVALID_FILE_ATTRIBUTES == GetFileAttributesA(FileName) ) { ERROR_MESSAGE("file doesn't exist"); return; }	m_pTexture = NULL;	D3DXIMAGE_INFO pSrcInfo;	HRESULT hr = D3DXCreateTextureFromFileExA(	pd3dDevice,	FileName,	D3DX_DEFAULT,	D3DX_DEFAULT,	D3DX_DEFAULT, // mipmap	0,	TextureFormat,	D3DPOOL_MANAGED,	D3DX_FILTER_NONE,	D3DX_DEFAULT,	ColorKey,		&pSrcInfo,	NULL,	&m_pTexture);	if (m_pTexture == NULL || hr != D3D_OK ) 	{          ERROR_MESSAGE("not load");        }


edit : TextureFormat = D3DFMT_A8R8G8B8 (for example)
Have a great day!Richard Geslot, 3D game developermy 3D creation
Thanks, but I don't think creating the texture is the main problem here. It seems like the device gets corrupted or something, since width = 9403360, format = 32 etc. If I check the device right after it gets created it's also like this.

I'm using Windows 7 and Visual Studio 2008 and I've tried DirectX SDK March and August 2009. I don't think it's got aything to do with Windows 7, since I've been using it for a year or two already without problems.

Anyone know what the hell this could be? I've tried to put all the code in one project instead of separate static libraries, but I still seem to be getting this problem, even when removing "complex" code. Have I totally lost it or something?

Maybe I should just drop the DXUT framework and do everything the old way, but it's not that tempting.
I found out what the problem was. I was using an offset for drawing the texture which caused it to draw nothing. Silly mistake.

I still have a problem though, even though it's not as important. Visual studio seems to be showing the wrong information about directx objects like d3ddevice9 and IDirect3DTexture9 while debugging. That's the reason I didn't think they were created properly.

Does anyone have a clue why this is happening? I've been using both VS 2008 and 2010 beta 2, as well as the March and August DirectX SDK so I'm not quite sure where the error lies.
Debugging information might not always be reliable, depends on what compiler flags you've set, especially when enabling optimization. Have a look at what you've set in your projects properties, especially under Configuration/Debugging, Configuration/C/C++/General and Configuration/C/C++/Optimization. Try play around with the settings.

If that does not help, try storing the values you're interested in in some member variables, or even log them to some file. Since your app is obviously working, I bet you get sensible values by then.

unbird
Thanks. I'll check that out.
I fixed this problem on friday. Apparently I was running the retail version of Direct X. After checking out the Direct X control panel and switching it to debug all the parameters were correct. Doesn't seem like the SDK changes the Direct X version to debug automatically anymore.

Now I can finally do more interesting stuff than debugging.

This topic is closed to new replies.

Advertisement