How do I draw a full screen quad that shows red on the screen?
Asked
Active
Viewed 5,787 times
1 Answers
3
First, set the primitive topology to TRIANGLESTRIP (ID3D11DeviceContext::IASetPrimitiveTopology), set the following shaders then call devicecontext->Draw(4,0). You don't even need vertex buffers for this because of the automatic system value of vertex id in the shader.
float4 VertexShader(uint vI : SV_VERTEXID):SV_POSITION
{
float2 texcoord = float2(vI&1,vI>>1); //you can use these for texture coordinates later
return float4((texcoord.x-0.5f)*2,-(texcoord.y-0.5f)*2,0,1);
}
float4 PixelShader(float4 pos : SV_POSITION):SV_TARGET
{
return float4(1,0,0,1); //the red color
}

János Turánszki
- 3,079
- 3
- 15
- 22
-
1Keep in mind this solution requires shader model 4.0 and Direct3D feature level 10.0+ hardware. – Chuck Walbourn Apr 12 '15 at 19:59