本文整理汇总了C++中FRHICommandList::DrawIndexedPrimitive方法的典型用法代码示例。如果您正苦于以下问题:C++ FRHICommandList::DrawIndexedPrimitive方法的具体用法?C++ FRHICommandList::DrawIndexedPrimitive怎么用?C++ FRHICommandList::DrawIndexedPrimitive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FRHICommandList
的用法示例。
在下文中一共展示了FRHICommandList::DrawIndexedPrimitive方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawRectangle
void DrawRectangle(
FRHICommandList& RHICmdList,
float X,
float Y,
float SizeX,
float SizeY,
float U,
float V,
float SizeU,
float SizeV,
FIntPoint TargetSize,
FIntPoint TextureSize,
FShader* VertexShader,
EDrawRectangleFlags Flags
)
{
float ClipSpaceQuadZ = 0.0f;
DoDrawRectangleFlagOverride(Flags);
// triangle if extending to left and top of the given rectangle, if it's not left top of the viewport it can cause artifacts
if(X > 0.0f || Y > 0.0f)
{
// don't use triangle optimization
Flags = EDRF_Default;
}
// Set up vertex uniform parameters for scaling and biasing the rectangle.
// Note: Use DrawRectangle in the vertex shader to calculate the correct vertex position and uv.
FDrawRectangleParameters Parameters;
Parameters.PosScaleBias = FVector4(SizeX, SizeY, X, Y);
Parameters.UVScaleBias = FVector4(SizeU, SizeV, U, V);
Parameters.InvTargetSizeAndTextureSize = FVector4(
1.0f / TargetSize.X, 1.0f / TargetSize.Y,
1.0f / TextureSize.X, 1.0f / TextureSize.Y);
SetUniformBufferParameterImmediate(RHICmdList, VertexShader->GetVertexShader(), VertexShader->GetUniformBufferParameter<FDrawRectangleParameters>(), Parameters);
if(Flags == EDRF_UseTesselatedIndexBuffer)
{
// no vertex buffer needed as we compute it in VS
RHICmdList.SetStreamSource(0, NULL, 0, 0);
RHICmdList.DrawIndexedPrimitive(
GTesselatedScreenRectangleIndexBuffer.IndexBufferRHI,
PT_TriangleList,
/*BaseVertexIndex=*/ 0,
/*MinIndex=*/ 0,
/*NumVertices=*/ GTesselatedScreenRectangleIndexBuffer.NumVertices(),
/*StartIndex=*/ 0,
/*NumPrimitives=*/ GTesselatedScreenRectangleIndexBuffer.NumPrimitives(),
/*NumInstances=*/ 1
);
}
else
{
RHICmdList.SetStreamSource(0, GScreenRectangleVertexBuffer.VertexBufferRHI, sizeof(FFilterVertex), 0);
if (Flags == EDRF_UseTriangleOptimization)
{
// A single triangle spans the entire viewport this results in a quad that fill the viewport. This can increase rasterization efficiency
// as we do not have a diagonal edge (through the center) for the rasterizer/span-dispatch. Although the actual benefit of this technique is dependent upon hardware.
// We offset into the index buffer when using the triangle optimization to access the correct vertices.
RHICmdList.DrawIndexedPrimitive(
GScreenRectangleIndexBuffer.IndexBufferRHI,
PT_TriangleList,
/*BaseVertexIndex=*/ 0,
/*MinIndex=*/ 0,
/*NumVertices=*/ 3,
/*StartIndex=*/ 6,
/*NumPrimitives=*/ 1,
/*NumInstances=*/ 1
);
}
else
{
RHICmdList.SetStreamSource(0, GScreenRectangleVertexBuffer.VertexBufferRHI, sizeof(FFilterVertex), 0);
RHICmdList.DrawIndexedPrimitive(
GScreenRectangleIndexBuffer.IndexBufferRHI,
PT_TriangleList,
/*BaseVertexIndex=*/ 0,
/*MinIndex=*/ 0,
/*NumVertices=*/ 4,
/*StartIndex=*/ 0,
/*NumPrimitives=*/ 2,
/*NumInstances=*/ 1
);
}
}
}