SharpDX: Enabling BlendState

主宰稳场 提交于 2019-12-04 17:21:05

All resource in Direct3D11 are immutable, so when you are creating the new Blendstate(mDevice, new BlendStateDescription()), you cannot change the description later. The normal workflow is:

var blendDescription = new BlendDescription();
blendDescription.RenderTarget[0].IsBlendEnabled = .. // set all values 
[...]
var blendState = new BlendState(device, blendDescription);
context.OutputMerger.SetBlendState(blendState, ...);

Also resource objects need to be stored somewhere and disposed when you are completely done with them (most of the time for blendstates, at the end of your application), otherwise you will get memory leaks.

I advice you to look more closely at some Direct3D11 C++ samples when you are not sure about the API usage. Also, I recommend you to read a book like "Introduction to 3D Game Programming with DirectX 11" by Frank.D.Luna which is perfect to begin and learn the Direct3D11 API.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!