Exemple #1
0
func (w *window) SetKeyRepeat(enable bool) {
	if enable {
		glfw.Enable(glfw.KeyRepeat)
		return
	}
	glfw.Disable(glfw.KeyRepeat)
}
Exemple #2
0
func (w *window) SetSystemKeys(enable bool) {
	if enable {
		glfw.Enable(glfw.SystemKeys)
		return
	}
	glfw.Disable(glfw.SystemKeys)
}
Exemple #3
0
func (w *window) SetStickyMouseButtons(enable bool) {
	if enable {
		glfw.Enable(glfw.StickyMouseButtons)
		return
	}
	glfw.Disable(glfw.StickyMouseButtons)
}
Exemple #4
0
func (w *window) SetMouseCursor(enable bool) {
	if enable {
		glfw.Enable(glfw.MouseCursor)
		return
	}
	glfw.Disable(glfw.MouseCursor)
}
Exemple #5
0
func main() {
	glfw.Init()
	defer glfw.Terminate()

	glfw.OpenWindow(640, 480, 8, 8, 8, 8, 0, 0, glfw.Windowed)
	defer glfw.CloseWindow()

	glfw.SetWindowTitle("Tile test")
	glfw.Enable(glfw.StickyKeys)
	glfw.SetSwapInterval(1)
	glfw.SetKeyCallback(inputCallback)

	gl.MatrixMode(gl.PROJECTION)
	gl.LoadIdentity()
	gl.Ortho(0, GridWidth, GridHeight, 0, -1, 1)
	gl.MatrixMode(gl.MODELVIEW)
	gl.Disable(gl.DEPTH_TEST)
	gl.Enable(gl.TEXTURE_2D)
	gl.Enable(gl.BLEND)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)

	gl.ClearColor(0.0, 0.0, 0.0, 1.0)
	initResources()
	initWorld()

	for Running {
		if (time.Since(DT).Nanoseconds() / 1000000) > 15 { //don't loop faster than every 15ms
			DT = time.Now()
			gl.Clear(gl.COLOR_BUFFER_BIT)
			player.update()
			renderScene()
			glfw.SwapBuffers()
		}
	}
}
Exemple #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
}
Exemple #7
0
func BindKeyboard() {
	glfw.SetCharCallback(takeKeyAction)
	glfw.Enable(glfw.KeyRepeat)
}