il faut créer un quad (4 vertices) avec comme format de vertex: TransformedColoredTextured
en vb.net ça donne un truc du genre:
Private Sub Create_Quad2D(ByVal X As Single, ByVal Y As Single, ByVal Width As Single, ByVal Height As Single, ByVal Color As Integer) Remplir_Vertex(PointSprite(0), X, Y, 1, 0, 0, Color) Remplir_Vertex(PointSprite(1), X + Width, Y, 1, 1, 0, Color) Remplir_Vertex(PointSprite(2), 0, Y + Height, 1, 0, 1, Color) Remplir_Vertex(PointSprite(3), X + Width, Y + Height, 1, 1, 1, Color) End Sub
Private Sub Remplir_Vertex(ByRef Vertex As CustomVertex.TransformedColoredTextured, ByRef X As Single, ByRef Y As Single, ByRef Z As Single, ByVal Tu As Single, ByVal Tv As Single, ByVal Color As Integer) Vertex.X = X Vertex.Y = Y Vertex.Z = Z Vertex.Tu = Tu Vertex.Tv = Tv Vertex.Rhw = 1 Vertex.Color = Color End Sub
et pour le rendu: Public Sub Render_Texture_Quad(ByVal Texture As Integer, ByVal X As Single, ByVal Y As Single, ByVal Width As Single, ByVal Height As Single, ByVal Color As Integer) Create_Quad2D(X, Y, Width, Height, Color) device.VertexFormat = CustomVertex.TransformedColoredTextured.Format mTex.Set_Texture(0, Texture, 0) device.DrawUserPrimitives(PrimitiveType.TriangleStrip, 2, PointSprite) End Sub
|