Jump to content
  • Advertisement
Sign in to follow this  
kolarz3

DX11 Problem with loading data to 2D Texture

This topic is 2061 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

Hello, I have the same problem that is in topic :). I have array with unsigned char "RGBABufor". I map this data to ID3D11Texture2D (only 20 sciles). When I try save this texture i have HRESULT : Unspecified error


	ID3D11Texture2D *defaultTex;
	D3D11_TEXTURE2D_DESC desc; 
	ZeroMemory( &desc, sizeof(desc)); 
	desc.Width = clip->getWidth(); 
	desc.Height = 20; 
	desc.MipLevels = desc.ArraySize = 1; 
	desc.Format =  DXGI_FORMAT_R8G8B8A8_UINT; 
	desc.SampleDesc.Count = 1; 
	desc.Usage = D3D11_USAGE_DYNAMIC; 
	desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; 
	desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; 

	engine.d3d11Device->CreateTexture2D( &desc, NULL, &defaultTex ); 
	
	D3D11_MAPPED_SUBRESOURCE mapResource;
	engine.d3d11DevCon->Map(defaultTex,0,D3D11_MAP_WRITE_DISCARD,0,&mapResource);
	BYTE* mappedData = reinterpret_cast<BYTE*>(mapResource.pData);
	memcpy(mappedData,RGBABufor, clip->getWidth()*20*4);
	engine.d3d11DevCon->Unmap(defaultTex, 0);

	hr=D3DX11SaveTextureToFile(engine.d3d11DevCon,defaultTex,D3DX11_IFF_PNG,L"obraz.png");
	

This is fragment of "mappedData", 3 pixels:

ùùùÿùùùÿùùùÿ

This looks good. Where is problem ... ?

 

 

Share this post


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

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!