Jump to content
  • Advertisement
Sign in to follow this  
supagu

OpenGL [DX10] CreateTexture2D from TGA

This topic is 4481 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Any debug spew?

Share this post


Link to post
Share on other sites
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 :-/

Share this post


Link to post
Share on other sites
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)?

Share this post


Link to post
Share on other sites
there is nothing in the vc output window relating to directx errors unfortunately.
any other way to get dx error info?

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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 :-/

Share this post


Link to post
Share on other sites
Have you enabled the debug runtime in the DirectX control panel too? For me these still locks like you run on the release runtime.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!