Frisker
11-30-2005, 10:11 AM
I'm new to DirectX and i tried to make a pong game (2 learn) but i cant paint more than one object here is the source i think there's something wrong with:
First I create my vertices using this function :
Private Sub SquareVertices(ByVal Vertices() As StructCustomVertex)
' Create Squares, Composed by two triangles
Vertices(0) = CreateFlexVertex(Ball.X, Ball.Y, 0, 1, 0, 0)
Vertices(1) = CreateFlexVertex(Ball.X + Ball.Width, Ball.Y, 0, 1, 1, 0)
Vertices(2) = CreateFlexVertex(Ball.X, Ball.Y + Ball.Heigth, 0, 1, 0, 1)
Vertices(3) = CreateFlexVertex(Ball.X + Ball.Width, Ball.Y + Ball.Heigth, 0, 1, 1, 1)
Vertices(4) = CreateFlexVertex(YPaddle.X, YPaddle.Y, 0, 1, 0, 0)
Vertices(5) = CreateFlexVertex(YPaddle.X + YPaddle.Width, YPaddle.Y, 0, 1, 1, 0)
Vertices(6) = CreateFlexVertex(YPaddle.X, YPaddle.Y + YPaddle.Heigth, 0, 1, 0, 1)
Vertices(7) = CreateFlexVertex(YPaddle.X + YPaddle.Width, YPaddle.Y + YPaddle.Heigth, 0, 1, 1, 1)
Vertices(8) = CreateFlexVertex(Epaddle.X, Epaddle.Y, 0, 1, 0, 0)
Vertices(9) = CreateFlexVertex(Epaddle.X + Epaddle.Width, Epaddle.Y, 0, 1, 1, 0)
Vertices(10) = CreateFlexVertex(Epaddle.X, Epaddle.Y + Epaddle.Heigth, 0, 1, 0, 1)
Vertices(11) = CreateFlexVertex(Epaddle.X + Epaddle.Width, Epaddle.Y + Epaddle.Heigth, 0, 1, 1, 1)
End Sub 'SquareVertices
I create 11 vertices (3 triangles).
And the rendering code
Private Sub Render()
If Device Is Nothing Then
Return
End If
' Clears The Device With Black Color
Device.Clear(ClearFlags.Target, System.Drawing.Color.FromArgb(0, 0, 0).ToArgb(), 1.0F, 0)
Device.BeginScene()
Device.SetTexture(0, texTexture)
Device.SetStreamSource(0, VertBuffer, 0)
Device.VertexFormat = CustomVertexFlags
Device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, Numverts - 2)
Device.DrawPrimitives(PrimitiveType.TriangleStrip, 5, NumVerts - 2)
Device.DrawPrimitives(PrimitiveType.TriangleStrip, 8, NumVerts - 2)
Device.EndScene()
Try
Device.Present()
Catch
End Try
End Sub 'Render
Numverts = 4
Can any1 tell me what i'm doing wrong!? i'm going crazy
First I create my vertices using this function :
Private Sub SquareVertices(ByVal Vertices() As StructCustomVertex)
' Create Squares, Composed by two triangles
Vertices(0) = CreateFlexVertex(Ball.X, Ball.Y, 0, 1, 0, 0)
Vertices(1) = CreateFlexVertex(Ball.X + Ball.Width, Ball.Y, 0, 1, 1, 0)
Vertices(2) = CreateFlexVertex(Ball.X, Ball.Y + Ball.Heigth, 0, 1, 0, 1)
Vertices(3) = CreateFlexVertex(Ball.X + Ball.Width, Ball.Y + Ball.Heigth, 0, 1, 1, 1)
Vertices(4) = CreateFlexVertex(YPaddle.X, YPaddle.Y, 0, 1, 0, 0)
Vertices(5) = CreateFlexVertex(YPaddle.X + YPaddle.Width, YPaddle.Y, 0, 1, 1, 0)
Vertices(6) = CreateFlexVertex(YPaddle.X, YPaddle.Y + YPaddle.Heigth, 0, 1, 0, 1)
Vertices(7) = CreateFlexVertex(YPaddle.X + YPaddle.Width, YPaddle.Y + YPaddle.Heigth, 0, 1, 1, 1)
Vertices(8) = CreateFlexVertex(Epaddle.X, Epaddle.Y, 0, 1, 0, 0)
Vertices(9) = CreateFlexVertex(Epaddle.X + Epaddle.Width, Epaddle.Y, 0, 1, 1, 0)
Vertices(10) = CreateFlexVertex(Epaddle.X, Epaddle.Y + Epaddle.Heigth, 0, 1, 0, 1)
Vertices(11) = CreateFlexVertex(Epaddle.X + Epaddle.Width, Epaddle.Y + Epaddle.Heigth, 0, 1, 1, 1)
End Sub 'SquareVertices
I create 11 vertices (3 triangles).
And the rendering code
Private Sub Render()
If Device Is Nothing Then
Return
End If
' Clears The Device With Black Color
Device.Clear(ClearFlags.Target, System.Drawing.Color.FromArgb(0, 0, 0).ToArgb(), 1.0F, 0)
Device.BeginScene()
Device.SetTexture(0, texTexture)
Device.SetStreamSource(0, VertBuffer, 0)
Device.VertexFormat = CustomVertexFlags
Device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, Numverts - 2)
Device.DrawPrimitives(PrimitiveType.TriangleStrip, 5, NumVerts - 2)
Device.DrawPrimitives(PrimitiveType.TriangleStrip, 8, NumVerts - 2)
Device.EndScene()
Try
Device.Present()
Catch
End Try
End Sub 'Render
Numverts = 4
Can any1 tell me what i'm doing wrong!? i'm going crazy