Hello

Hello,

Why does this code on an empty FMX3D form draw a red rectangle on Windowd, OSX and iOS Simulator but nothing on Android ? (don't have an iPhone).

In fact it's seems that the rectangle is displayed quickly and the erased ... by what ?

procedure TForm1.Form3DRender(Sender: TObject; Context: TContext3D);
type
  TVertex = record
    x,  y,  z: Single;
  end;
var
  Vertices          : TArray;
  Indices           : TArray;
  VertexDeclaration : TVertexDeclaration;
  VertexSize        : Integer;
  VertexCount       : Integer;
  IndexSize         : Integer;
  IndexCount        : Integer;
  Material          : TMaterial;
  Opacity           : Single;
begin
  SetLength(Vertices, 4);
  Vertices[0].x := Width / 2 - 100;
  Vertices[0].y := Height/ 2 - 100;
  Vertices[0].z :=    0;

  Vertices[1].x := Width / 2 + 100;
  Vertices[1].y := Height/ 2 - 100;
  Vertices[1].z :=    0;

  Vertices[2].x := Width / 2 + 100;
  Vertices[2].y := Height/ 2 + 100;
  Vertices[2].z :=    0;

  Vertices[3].x := Width / 2 - 100;
  Vertices[3].y := Height/ 2 + 100;
  Vertices[3].z :=    0;

  SetLength(Indices, 6);
  Indices[0] := 0;
  Indices[1] := 1;
  Indices[2] := 3;

  Indices[3] := 3;
  Indices[4] := 1;
  Indices[5] := 2;

  SetLength(VertexDeclaration, 1);
  VertexDeclaration[0].Format := TVertexFormat.Vertex;
  VertexDeclaration[0].Offset := 0;

  VertexSize := SizeOf(TVertex);
  VertexCount := Length(Vertices);

  IndexSize := SizeOf(Integer);
  IndexCount := Length(Indices);

  Material := nil;

  Opacity := 1;

  Context.DrawPrimitives(
    TPrimitivesKind.Triangles,
    Vertices,
    Indices,
    VertexDeclaration,
    VertexSize,
    VertexCount,
    IndexSize,
    Indexcount,
    Material,
    Opacity
  );
end;

Comments