/** Initialize the RHI for this rendering resource */ void InitRHI() override { TResourceArray<FFilterVertex, VERTEXBUFFER_ALIGNMENT> Vertices; Vertices.SetNumUninitialized(6); Vertices[0].Position = FVector4(1, 1, 0, 1); Vertices[0].UV = FVector2D(1, 1); Vertices[1].Position = FVector4(0, 1, 0, 1); Vertices[1].UV = FVector2D(0, 1); Vertices[2].Position = FVector4(1, 0, 0, 1); Vertices[2].UV = FVector2D(1, 0); Vertices[3].Position = FVector4(0, 0, 0, 1); Vertices[3].UV = FVector2D(0, 0); //The final two vertices are used for the triangle optimization (a single triangle spans the entire viewport ) Vertices[4].Position = FVector4(-1, 1, 0, 1); Vertices[4].UV = FVector2D(-1, 1); Vertices[5].Position = FVector4(1, -1, 0, 1); Vertices[5].UV = FVector2D(1, -1); // Create vertex buffer. Fill buffer with initial data upon creation FRHIResourceCreateInfo CreateInfo(&Vertices); VertexBufferRHI = RHICreateVertexBuffer(Vertices.GetResourceDataSize(), BUF_Static, CreateInfo); }
/** * Initialize the RHI for this rendering resource */ void InitRHI() override { const int32 NumVerts = 8; TResourceArray<FVector4, VERTEXBUFFER_ALIGNMENT> Verts; Verts.SetNumUninitialized(NumVerts); for (uint32 Z = 0; Z < 2; Z++) { for (uint32 Y = 0; Y < 2; Y++) { for (uint32 X = 0; X < 2; X++) { const FVector4 Vertex = FVector4( (X ? -1 : 1), (Y ? -1 : 1), (Z ? -1 : 1), 1.0f ); Verts[GetCubeVertexIndex(X, Y, Z)] = Vertex; } } } uint32 Size = Verts.GetResourceDataSize(); // Create vertex buffer. Fill buffer with initial data upon creation FRHIResourceCreateInfo CreateInfo(&Verts); VertexBufferRHI = RHICreateVertexBuffer(Size, BUF_Static, CreateInfo); }