From 5236bb92a4ebea1de6852b8b23df85d6ac069783 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Mon, 17 Jun 2013 23:51:15 +0900 Subject: [PATCH] Double buffering --- examples/glut/main.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/examples/glut/main.go b/examples/glut/main.go index fb5b6ec0d..d82296a26 100644 --- a/examples/glut/main.go +++ b/examples/glut/main.go @@ -6,11 +6,16 @@ package main // #include // // void display(void); +// void idle(void); // // static void setDisplayFunc(void) { // glutDisplayFunc(display); // } // +// static void setIdleFunc(void) { +// glutIdleFunc(idle); +// } +// import "C" import ( "image/color" @@ -34,6 +39,12 @@ func (game *DemoGame) Draw(g *graphics.GraphicsContext, offscreen *graphics.Text //export display func display() { device.Update() + C.glutSwapBuffers() +} + +//export idle +func idle() { + C.glutPostRedisplay() } func main() { @@ -62,6 +73,7 @@ func main() { C.glutCreateWindow(title) C.setDisplayFunc() + C.setIdleFunc() game := &DemoGame{} device = graphics.NewDevice(screenWidth, screenHeight, screenScale,