Browse Source

Found my bug in the bindings, it's just the version number...

Beoran 11 years ago
parent
commit
cf211d6c58
3 changed files with 25 additions and 8 deletions
  1. 2 1
      README.md
  2. 10 3
      src/algo/al/al.go
  3. 13 4
      src/algo/al/al_test.go

+ 2 - 1
README.md

@@ -1,4 +1,5 @@
 algo
 ====
 
-Go language binding to Allegro 5 (experimental)
+Go language binding to Allegro 5 (experimental, and has problems,
+full-screen windows do not work...)

+ 10 - 3
src/algo/al/al.go

@@ -22,8 +22,8 @@ func AL_ID(a, b, c, d int) int {
 }
 
 const VERSION = 5
-const SUB_VERSION = 0
-const WIP_VERSION = 7
+const SUB_VERSION = 1
+const WIP_VERSION = 5
 const RELEASE_NUMBER = 1
 const VERSION_STR = "5.0.7"
 const DATE_STR = "2012"
@@ -43,7 +43,8 @@ func GetAllegroVersion() uint32 {
 
 // Initializes the Allegro system.
 func Initialize() bool {
-	return bool(C.algo_initialize())
+	return bool(C.al_install_system(VERSION_INT, nil))
+//	return bool(C.algo_initialize())
 }
 
 // Cleans up the Allegro system. Needed after calling Initialize.
@@ -753,3 +754,9 @@ func (self *Timer) AddCount(count int) {
 func (self *Timer) GetEventSource() *EventSource {
 	return (*EventSource)(C.al_get_timer_event_source(self.handle))
 }
+
+// Do nothing function for benchmarking only
+func DoNothing() { 
+  C.algo_do_nothing()
+}
+

+ 13 - 4
src/algo/al/al_test.go

@@ -141,11 +141,12 @@ func makeDisplay() (*Display) {
   flags := 0
   // Use full screen mode if needed.
   if TEST_FULLSCREEN  { 
-    flags = FULLSCREEN | GENERATE_EXPOSE_EVENTS;
+    flags = FULLSCREEN // | GENERATE_EXPOSE_EVENTS
   } 
   SetNewDisplayFlags(flags)
   // Create a window to display things on: 640x480 pixels.
-  display := CreateDisplay(SCREEN_W, SCREEN_H)  
+  display := CreateDisplay(SCREEN_W, SCREEN_H)
+  display.Resize(SCREEN_W, SCREEN_H)
   return display
 }
 
@@ -158,7 +159,7 @@ func TestBasicDisplay(t *testing.T) {
     t.Error("Error creating display.")
   }
   /*
-  if !display.Resize(SCREEN_W, SCREEN_H) {
+  if ! {
     t.Error("Resize of display failed.")
   }
   */
@@ -167,10 +168,12 @@ func TestBasicDisplay(t *testing.T) {
   ClearToColor(blue)
   DrawPixel(20.0, 10.0, yellow)  
   FlipDisplay()
+  Rest(1.0)
   ClearToColor(yellow)
   DrawPixel(20.0, 10.0, blue)
   FlipDisplay()
   display.Destroy() 
+  Rest(1.0)
 }
 
 // Benchmark basic display function ClearToColor
@@ -207,6 +210,12 @@ func BenchmarkFlipDisplay(b *testing.B) {
     display.Destroy()
 }
 
-
+// Benchmarking of C call overhead
+// Benchmark basic display function FlipDisplay
+func BenchmarkDoNothing(b *testing.B) {
+    for i := 0; i < b.N; i++ {
+        DoNothing()
+    }
+}