Exemplo n.º 1
0
func (w *window) SetKeyRepeat(enable bool) {
	if enable {
		glfw.Enable(glfw.KeyRepeat)
		return
	}
	glfw.Disable(glfw.KeyRepeat)
}
Exemplo n.º 2
0
func (w *window) SetSystemKeys(enable bool) {
	if enable {
		glfw.Enable(glfw.SystemKeys)
		return
	}
	glfw.Disable(glfw.SystemKeys)
}
Exemplo n.º 3
0
func (w *window) SetStickyMouseButtons(enable bool) {
	if enable {
		glfw.Enable(glfw.StickyMouseButtons)
		return
	}
	glfw.Disable(glfw.StickyMouseButtons)
}
Exemplo n.º 4
0
func (w *window) SetMouseCursor(enable bool) {
	if enable {
		glfw.Enable(glfw.MouseCursor)
		return
	}
	glfw.Disable(glfw.MouseCursor)
}
Exemplo n.º 5
0
func initWindow(caption string) {
	//glfw stuff
	err := glfw.Init()
	if err != nil {
		panic(err)
	}

	_w = 500
	_h = 500

	glfw.OpenWindowHint(glfw.OpenGLVersionMinor, 2)
	glfw.OpenWindowHint(glfw.OpenGLVersionMajor, 3)
	glfw.OpenWindowHint(glfw.OpenGLProfile, 0) //glfw.OpenGLCoreProfile)

	err = glfw.OpenWindow(_w, _h, 0, 0, 0, 0, 0, 0, glfw.Windowed)
	if err != nil {
		panic(err)
	}
	glfw.SetWindowTitle(caption)
	glfw.Disable(glfw.AutoPollEvents)

	glfw.SetWindowSizeCallback(onResize)
}
Exemplo n.º 6
0
func main() {
	// Initialize GLFW
	glfw.Init()
	glfw.Enable(glfw.StickyKeys)
	if !setupWindow(appWidth, appHeight, fullScreen) {
		return
	}

	// Initialize application and engine
	app = new(Application)
	if !app.init() {
		fmt.Println("Error starting Horde3d")
		horde3d.DumpMessages()
	}
	if !fullScreen {
		glfw.SetWindowTitle(app.title)
	}

	app.resize(appWidth, appHeight)

	glfw.Disable(glfw.MouseCursor)

	var frames float32 = 0
	var fps float32 = 30.0
	t0 = glfw.Time()
	running = true

	// Game loop
	for running {
		// Calc FPS
		frames++
		if frames >= 3 {
			t := glfw.Time()
			fps = frames / float32(t-t0)
			if fps < 5 {
				fps = 30 // Handle breakpoints
			}
			frames = 0
			t0 = t
		}

		// Update key states
		for i := 0; i < 320; i++ {
			app.setKeyState(i, glfw.Key(i) == glfw.KeyPress)
		}
		app.keyStateHandler()

		// Render
		app.mainLoop(fps)
		glfw.SwapBuffers()

	}

	glfw.Enable(glfw.MouseCursor)

	// Quit
	app.release()
	glfw.Terminate()

	return
}