Example #1
0
// NewWindow returns a new window. It initializes GLFW and GLEW, creates a new
// GLFW window with given width, height and title, initializes the texture
// data.
func NewWindow(
	width, height int,
	title string,
	visible bool,
) (*Window, error) {
	if width < 0 {
		return nil, errors.New("Width must not be < 0")
	}
	if height < 0 {
		return nil, errors.New("Height must not be < 0")
	}
	err := ensGlfwInit()
	if err != nil {
		return nil, err
	}
	var v = 0
	if visible {
		v = 1
	}
	glfwWin := C.createWin(
		C.int(width),
		C.int(height),
		C.CString(title),
		C.int(v),
	)
	if glfwWin == nil {
		Terminate()
		return nil, errors.New("Failed to create window")
	}
	errno := int(C.initGlew(glfwWin))
	if errno != 1 {
		return nil, errors.New("Failed to init GLEW")
	}
	C.initWin(glfwWin, C.int(width), C.int(height))
	tex := newTex(width, height)
	texId := C.createTex(
		glfwWin,
		unsafe.Pointer(&tex),
		C.int(width),
		C.int(height),
	)
	C.glfwSetInputMode(glfwWin, C.GLFW_CURSOR, C.GLFW_CURSOR_DISABLED)
	return &Window{width, height, glfwWin, texId, tex}, nil
}
Example #2
0
// Sets an input option for the window.
func (w *Window) SetInputMode(mode InputMode, value int) {
	C.glfwSetInputMode(w.data, C.int(mode), C.int(value))
	panicError()
}
Example #3
0
File: glfw.go Project: maun/glfw
func SetInputMode(window Window, mode, value int) {
	C.glfwSetInputMode(C.GLFWwindow(window), C.int(mode), C.int(value))
}