Jump to content
  • Advertisement
Sign in to follow this  
DarkRonin

DX11 Dynamic texture problem

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

Hi Guys,

I am having a bit of a problem with a dynamic texture.

It is creating without error and I am attempting to initialize the first pixel to white to make sure I am mapping correctly. But when I draw the texture to the quad it displays the whole quad white (instead of just one pixel).

This is how I am creating, mapping, and setting the first pixel to white. But as mentioned, when I draw the quad, the entire quad is white.

 

	// Create dynamic texture
	D3D11_TEXTURE2D_DESC textureDesc = { 0 };
	textureDesc.Width = 2048;
	textureDesc.Height = 2048;
	textureDesc.MipLevels = 1;
	textureDesc.ArraySize = 1;
	textureDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
	textureDesc.SampleDesc.Count = 1;
	textureDesc.Usage = D3D11_USAGE_DYNAMIC;
	textureDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
	textureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
	textureDesc.MiscFlags = 0;

	HRESULT result = d3dDevice->CreateTexture2D(&textureDesc, NULL, &textureDynamic);
	if (FAILED(result))
		return -1;

	result = d3dDevice->CreateShaderResourceView(textureDynamic, 0, &textureRV);
	if (FAILED(result))
		return -2;

	D3D11_MAPPED_SUBRESOURCE resource;
	if (FAILED(d3dContext->Map(textureDynamic, 0, D3D11_MAP_WRITE_DISCARD, 0, &resource)))
		return -1;
	memset(resource.pData, 255, 4);
	d3dContext->Unmap(textureDynamic, 0);

 

Hopefully I have just made an oversight somewhere.

Any assistance would be greatly appreciated :)

(If I change the 255 value to 128 the quad then turns grey, so the mapping is definitely doing something. Just can't work out why it is colouring the whole quad and not the first pixel)

Edited by lonewolff

Share this post


Link to post
Share on other sites
Advertisement

Thanks Hodgman,

I knew the UV's were ok, but you jogged my memory. I hadn't updated the input description code and only had vertex position.

I have now updated it to use the texcoords as well and all is now good.

Thanks again :)

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!