[DX10] CreateTexture2D from TGA

Started by
11 comments, last by LeGreg 17 years, 10 months ago
i've got my tga loaderfrom my old opengl engine, and now i'm stufing around with a dx10 engine and want to get textures loaded. so i've got this: where tga.GetPixels() returns a pointer to the image data. tga.GetBPP() = 4, tga.GetWidth() = 512, tga.GetHeight() = 512

CD3D10_TEXTURE2D_DESC desc(DXGI_FORMAT_R8G8B8A8_UINT, tga.GetWidth(), tga.GetHeight());

	D3D10_SUBRESOURCE_DATA data[1];
	memset(&data, 0, sizeof(D3D10_SUBRESOURCE_DATA));
	data[0].pSysMem = tga.GetPixels();
	data[0].SysMemPitch = tga.GetBPP() * tga.GetWidth();

	int bpp = tga.GetBPP();

	HRESULT hr;
	hr = static_cast<const DX10Device*>(device)->GetD3DDevice()->CreateTexture2D(&desc, data, &mTexture);
	if (FAILED(hr))
        return false;

the problem seems to be the second paramter to CreateTexture2D. If i make this null i get S_OK returned, if i pass in data as shwon, i get E_INVALIDARG
Advertisement
It looks like you are creating a texture with a full mipmap chain but provide initial data only for the first mipmap. CreateTexture2D requires that you pass an array of D3D10_SUBRESOURCE_DATA structs with one entry per subresources. Each mipmap is counted as a subresource.
erm, so is there a way i can supply only the top level image and let dx generate the mipmaps?

i added:
desc.MipLevels = 1;

but it still fails
Any debug spew?
how can i get debug errors with dx10, i remember a dxmon or soemthing in the dxsdk folder that would spew out errors but cant find anything in the june 06 sdk :-/
Unfortunately there is currently no mip generation function included. The texture load functions support this but they don’t support the TGA format.

With only one mipmap it should work but I am not on may Vista/D3D10 test system at the moment to verify this.

Have you try the debug runtime and checked the output (in the output window from visual studio)?
there is nothing in the vc output window relating to directx errors unfortunately.
any other way to get dx error info?
If you have enabled the debug runtime you should get a last an information message from the runtime after the device is created. Do you have used the “D3D10_CREATE_DEVICE_DEBUG“ flag?
okay this is what i get back after enabling debug:

		Category	D3D10_MESSAGE_CATEGORY_STATE_CREATION	D3D10_MESSAGE_CATEGORY		Severity	D3D10_MESSAGE_SEVERITY_ERROR	D3D10_MESSAGE_SEVERITY		ID	D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDARG_RETURN	D3D10_MESSAGE_ID+		pDescription	0x0017f750 "ID3D10Device::CreateTexture2D: Returning E_INVALIDARG, meaning invalid parameters were passed."	const char *


oh yay, how vague can you get :-/
Have you enabled the debug runtime in the DirectX control panel too? For me these still locks like you run on the release runtime.

This topic is closed to new replies.

Advertisement