打扮家viewport视频
2022-04-06 18:37 kk20161206 阅读(52) 评论(0) 收藏 举报



if和else


viewport相关类型

gameviewportClient









template<ESlateVertexRounding Rounding>
void FSlateElementBatcher::AddViewportElement( const FSlateDrawElement& DrawElement )
{
const FSlateRenderTransform& RenderTransform = DrawElement.GetRenderTransform();
const FVector2D& LocalSize = DrawElement.GetLocalSize();
const FSlateViewportPayload& DrawElementPayload = DrawElement.GetDataPayload<FSlateViewportPayload>();
ESlateDrawEffect InDrawEffects = DrawElement.GetDrawEffects();
const int32 Layer = DrawElement.GetLayer();
const FColor FinalColor = PackVertexColor(DrawElementPayload.GetTint());
ESlateBatchDrawFlag DrawFlags = DrawElement.GetBatchFlags();
FSlateShaderResource* ViewportResource = DrawElementPayload.RenderTargetResource;
ESlateShader ShaderType = ESlateShader::Default;
if(DrawElementPayload.bViewportTextureAlphaOnly )
{
// This is a slight hack, but the grayscale font shader is the same as the general shader except it reads alpha only textures and doesn't support tiling
ShaderType = ESlateShader::GrayscaleFont;
}
FSlateRenderBatch& RenderBatch = CreateRenderBatch( Layer, FShaderParams(), ViewportResource, ESlateDrawPrimitive::TriangleList, ShaderType, InDrawEffects, DrawFlags, DrawElement);
// Tag this batch as requiring vsync if the viewport requires it.
if( ViewportResource != nullptr && !DrawElementPayload.bAllowViewportScaling )
{
bRequiresVsync |= DrawElementPayload.bRequiresVSync;
}
// Do pixel snapping
FVector2D TopLeft(0,0);
FVector2D BotRight(LocalSize);
// If the viewport disallows scaling, force size to current texture size.
if (ViewportResource != nullptr && !DrawElementPayload.bAllowViewportScaling)
{
const float ElementScale = DrawElement.GetScale();
BotRight = FVector2D(ViewportResource->GetWidth() / ElementScale, ViewportResource->GetHeight() / ElementScale);
}
FVector2D TopRight = FVector2D( BotRight.X, TopLeft.Y);
FVector2D BotLeft = FVector2D( TopLeft.X, BotRight.Y);
// The start index of these vertices in the index buffer
const uint32 IndexStart = 0;
// Add four vertices to the list of verts to be added to the vertex buffer
RenderBatch.AddVertex( FSlateVertex::Make<Rounding>( RenderTransform, TopLeft, FVector2D(0.0f,0.0f), FinalColor ) );
RenderBatch.AddVertex( FSlateVertex::Make<Rounding>( RenderTransform, TopRight, FVector2D(1.0f,0.0f), FinalColor ) );
RenderBatch.AddVertex( FSlateVertex::Make<Rounding>( RenderTransform, BotLeft, FVector2D(0.0f,1.0f), FinalColor ) );
RenderBatch.AddVertex( FSlateVertex::Make<Rounding>( RenderTransform, BotRight, FVector2D(1.0f,1.0f), FinalColor ) );
// Add 6 indices to the vertex buffer. (2 tri's per quad, 3 indices per tri)
RenderBatch.AddIndex( IndexStart + 0 );
RenderBatch.AddIndex( IndexStart + 1 );
RenderBatch.AddIndex( IndexStart + 2 );
RenderBatch.AddIndex( IndexStart + 2 );
RenderBatch.AddIndex( IndexStart + 1 );
RenderBatch.AddIndex( IndexStart + 3 );
}


浙公网安备 33010602011771号