Jump to content

View more

Image of the Day

Working on an auto spawn system. #gamedev #indiedev #screenshotsaturday https://t.co/Mm2kfekz7b
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Problem with loading data to 2D Texture

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
No replies to this topic

#1 kolarz3   Members   

164
Like
0Likes
Like

Posted 02 March 2014 - 05:21 AM

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 ... ?

 

 






Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.