Browse Source

Add test for DrawPrim()

Beoran 6 years ago
parent
commit
cc89b7d937
1 changed files with 42 additions and 0 deletions
  1. 42 0
      al/al_test.go

+ 42 - 0
al/al_test.go

@@ -315,6 +315,48 @@ func TestPrimitives(t *testing.T) {
     display.Destroy()
 }
 
+// Test some bitmap functions 
+func TestPrimitives2(t *testing.T) {
+    InstallSystem()
+    defer UninstallSystem()
+    InitImageAddon()
+    defer ShutdownImageAddon()
+    InitPrimitivesAddon()
+    defer ShutdownPrimitivesAddon()
+
+    
+    display := makeDisplay()
+    if display == nil {
+        t.Error("Error creating display.")
+    }
+    
+    bmp := loadBitmap(t, "gin_feather.png")
+    blue := CreateColor(0.0, 0.0, 1.0, 1.0)
+    yellow := CreateColor(1.0, 1.0, 0.0, 1.0)
+    ClearToColor(blue)
+    v := make([]Vertex, 3)
+    v[0].x = 10
+    v[0].y = 20
+    v[0].color = yellow.toC()
+    v[0].u = 0.0
+    v[0].v = 0.0
+    
+    v[1].x = 110
+    v[1].y = 120
+    v[0].u = 1.0
+    v[0].v = 0.0
+
+    v[2].x = 120
+    v[2].y = 210
+    v[0].u = 0.0
+    v[0].v = 1.0
+    
+    DrawPrim(v, bmp, 0, 3, PRIM_TRIANGLE_LIST)
+    FlipDisplay()
+    Rest(1.0)
+    display.Destroy()
+}
+
 
 // Benchmark basic display function ClearToColor
 func BenchmarkClearToColor(b *testing.B) {