func main() { if err := glfw.Init(); err != nil { fmt.Fprintf(os.Stderr, "[e] %v\n", err) return } defer glfw.Terminate() if err := glfw.OpenWindow(appWidth, appHeight, 8, 8, 8, 8, 24, 8, glfw.Windowed); err != nil { fmt.Fprintf(os.Stderr, "[e] %v\n", err) return } defer glfw.CloseWindow() if err := gl.Init(); err != 0 { fmt.Fprintf(os.Stderr, "[e] %v\n", err) return } glfw.SetWindowTitle(title) fps := fps.NewFPS(glfw.Time()) blocks.Init(appWidth, appHeight) for glfw.WindowParam(glfw.Opened) == 1 { blocks.Tick() fps.Tick(glfw.Time()) if glfw.WindowParam(glfw.Active) == 1 { glfw.Sleep(0.001) } else { glfw.Sleep(0.05) } } }
func main() { sys := Make() sys.Startup() defer sys.Shutdown() // InitQueue() sys.CreateWindow(1024, 768, "Gexic") gl.ClearColor(1, 1, 1, 0.) initGL() prevSelectPos = []int{0, 0, 0} // PurgeQueue() // genHexMap() hexMap2 = GenHexMap() // for matches := checkHexMap(); len(matches) > 0; matches = checkHexMap() { // removeHexAndGenNew(matches) // } glfw.SetMouseButtonCallback(MouseButtonCallback) glfw.SetCharCallback(charCallback) glfw.SetMousePosCallback(MousePosCallback) currExX = -1 currExY = -1 for sys.CheckExitMainLoop() { start := glfw.Time() wait := float64(1) / float64(30) gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT) gl.Enable(gl.TEXTURE_2D) gl.Enable(gl.BLEND) gl.Disable(gl.DEPTH_TEST) // renderHexMap() wallpaper.Bind(gl.TEXTURE_2D) gl.TexEnvf(gl.TEXTURE_ENV, gl.TEXTURE_ENV_MODE, gl.REPLACE) gl.Begin(gl.QUADS) gl.TexCoord2f(0, 0) gl.Vertex2i(0, 0) gl.TexCoord2f(0, 1) gl.Vertex2i(0, 768) gl.TexCoord2f(1, 1) gl.Vertex2i(1024, 768) gl.TexCoord2f(1, 0) gl.Vertex2i(1024, 0) gl.End() hexMap2.Render() hexRotate.AnimateAndExecute() hexShrink.AnimateAndExecute() hexFall.AnimateAndExecute() if !mouse.locked { x, y := mouse.GetXY() hexMap2.CalcClosestCenter(x, y) } gl.Flush() gl.Disable(gl.TEXTURE_2D) gl.Disable(gl.BLEND) sys.Refresh() diff := glfw.Time() - start if diff < wait { glfw.Sleep(wait - diff) } } }