当前位置: 首页>>代码示例>>Golang>>正文


Golang glfw.SetWindowSizeCallback函数代码示例

本文整理汇总了Golang中github.com/jteeuwen/glfw.SetWindowSizeCallback函数的典型用法代码示例。如果您正苦于以下问题:Golang SetWindowSizeCallback函数的具体用法?Golang SetWindowSizeCallback怎么用?Golang SetWindowSizeCallback使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SetWindowSizeCallback函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: main

func main() {
	var err error

	if err = glfw.Init(); err != nil {
		fmt.Fprintf(os.Stderr, "[e] %v\n", err)
		return
	}
	defer glfw.Terminate()

	if err = glfw.OpenWindow(Width, Height, 8, 8, 8, 8, 0, 8, glfw.Windowed); err != nil {
		fmt.Fprintf(os.Stderr, "[e] %v\n", err)
		return
	}
	defer glfw.CloseWindow()

	glfw.SetSwapInterval(1)
	glfw.SetWindowTitle(Title)
	glfw.SetWindowSizeCallback(onResize)
	glfw.SetKeyCallback(onKey)

	gl.ShadeModel(gl.SMOOTH)
	gl.ClearColor(0, 0, 0, 0)
	gl.ClearDepth(1)
	gl.Enable(gl.TEXTURE_2D)

	for running && glfw.WindowParam(glfw.Opened) == 1 {
		update()
		draw()
	}
}
开发者ID:samnardoni,项目名称:ca,代码行数:30,代码来源:ca.go

示例2: main

func main() {
	var running bool = true

	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()

	glfw.SetSwapInterval(1)
	glfw.SetWindowTitle(caption)

	if !horde3d.Init() {
		fmt.Println("Error starting Horde3D. Check Horde3d_log.html for details.")
		horde3d.DumpMessages()
		return
	}

	//horde3d.SetOption(horde3d.Options_DebugViewMode, 1)
	// Add resources
	//pipeline
	pipeRes = horde3d.AddResource(horde3d.ResTypes_Pipeline, "pipelines/hdr.pipeline.xml", 0)

	knightRes := horde3d.AddResource(horde3d.ResTypes_SceneGraph, "models/knight/knight.scene.xml", 0)

	//load resources paths separated by |
	horde3d.LoadResourcesFromDisk("../content")

	model := horde3d.RootNode.AddNodes(knightRes)
	model.SetTransform(0, 0, -30, 0, 0, 0, 0.1, 0.1, 0.1)

	// Add light source
	light := horde3d.RootNode.AddLightNode("Light1", 0, "LIGHTING", "SHADOWMAP")
	light.SetTransform(0, 20, 0, 0, 0, 0, 1, 1, 1)
	light.SetNodeParamF(horde3d.Light_RadiusF, 0, 50)

	//add camera
	cam = horde3d.RootNode.AddCameraNode("Camera", pipeRes)
	glfw.SetWindowSizeCallback(onResize)

	for running {

		horde3d.Render(cam)
		horde3d.FinalizeFrame()
		horde3d.DumpMessages()
		glfw.SwapBuffers()
		running = glfw.Key(glfw.KeyEsc) == 0 &&
			glfw.WindowParam(glfw.Opened) == 1
	}

	horde3d.Release()
}
开发者ID:floffel03,项目名称:gohorde,代码行数:60,代码来源:glfw.go

示例3: Init

func (v *Video) Init(t <-chan []uint32, d <-chan []uint32, n string) {
	v.tick = t
	v.debug = d

	if err := glfw.Init(); err != nil {
		fmt.Fprintf(os.Stderr, "[e] %v\n", err)
		return
	}

	if err := glfw.OpenWindow(512, 480, 0, 0, 0, 0, 0, 0, glfw.Windowed); err != nil {
		fmt.Fprintf(os.Stderr, "[e] %v\n", err)
		return
	}

	if gl.Init() != 0 {
		panic("gl error")
	}

	gl.Enable(gl.TEXTURE_2D)

	glfw.SetWindowTitle(fmt.Sprintf("Fergulator - %s", n))
	glfw.SetWindowSizeCallback(reshape)
	glfw.SetWindowCloseCallback(quit_event)
	glfw.SetKeyCallback(KeyListener)
	reshape(512, 480)

	v.tex = gl.GenTexture()

	v.fpsmanager = gfx.NewFramerate()
	v.fpsmanager.SetFramerate(70)
}
开发者ID:wmbest2,项目名称:Fergulator,代码行数:31,代码来源:video.go

示例4: Open

func Open(w, h int, sWin string, fullscreen bool) *Window {

	if GWindow != nil {
		panic("only one Window is allowed")
	}
	listener.GListener = listener.New()
	win := &Window{width: w, height: h, title: sWin, inputListener: listener.GListener}
	GWindow = win

	var err error
	if err = glfw.Init(); err != nil {
		panic(fmt.Sprintf("[e] %v\n", err))
	}
	mode := glfw.Windowed
	if fullscreen {
		mode = glfw.Fullscreen
	}
	if err = glfw.OpenWindow(win.width, win.height, 8, 8, 8, 0, 16, 0, mode); err != nil {
		panic(fmt.Sprintf("[e] %v\n", err))
	}
	gl.Init() //WHY?? (shader creation fails when not)

	glfw.SetSwapInterval(1)        // Enable vertical sync on cards that support it.
	glfw.SetWindowTitle(win.title) // Set window title
	//CALLBACKS
	glfw.SetWindowSizeCallback(func(w, h int) { GWindow.reshape(w, h) })
	glfw.SetWindowCloseCallback(listener.OnClose)
	glfw.SetMouseButtonCallback(listener.OnMouseButton)
	glfw.SetMouseWheelCallback(listener.OnMouseWheel)
	glfw.SetKeyCallback(listener.OnKey)
	glfw.SetCharCallback(listener.OnChar)

	win.initGL()
	return win
}
开发者ID:swantescholz,项目名称:go,代码行数:35,代码来源:window.go

示例5: main

func main() {
	var err error
	if err = glfw.Init(); err != nil {
		fmt.Fprintf(os.Stderr, "[e] %v\n", err)
		return
	}

	defer glfw.Terminate()

	if err = glfw.OpenWindow(640, 480, 8, 8, 8, 8, 0, 0, glfw.Windowed); err != nil {
		fmt.Fprintf(os.Stderr, "[e] %v\n", err)
		return
	}

	defer glfw.CloseWindow()

	glfw.SetWindowTitle("Draw")
	glfw.SetSwapInterval(1)
	glfw.SetKeyCallback(onKey)
	glfw.SetMouseButtonCallback(onMouseBtn)
	glfw.SetWindowSizeCallback(onResize)

	running = true
	for running && glfw.WindowParam(glfw.Opened) == 1 {
		if mouse[0] != 0 {
			pen.lineTo(glfw.MousePos())
		} else {
			pen.moveTo(glfw.MousePos())
		}

		glfw.SwapBuffers()
	}
}
开发者ID:sycoso,项目名称:glfw,代码行数:33,代码来源:main.go

示例6: main

func main() {
	log.Println("Starting")
	flag.Parse()

	runtime.GOMAXPROCS(4)

	initGLFW()
	initGL()

	initScene()

	initInput()

	glfw.SetWindowSizeCallback(resize)

	initLua()

	// Run the script file if we had one
	// TODO: Do this before accepting input from user...
	if fScript != "" {
		runFile(fScript)
	}

	for glfw.WindowParam(glfw.Opened) == 1 {
		display()
		glfw.SwapBuffers()
		time.Sleep(10 * time.Millisecond)
	}

}
开发者ID:vron,项目名称:fm,代码行数:30,代码来源:main.go

示例7: main

func main() {
	rand.Seed(time.Now().UnixNano())

	glfw.Init()
	defer glfw.Terminate()
	glfw.OpenWindow(Width, Height, 8, 8, 8, 8, 0, 8, glfw.Windowed)
	defer glfw.CloseWindow()

	glfw.SetSwapInterval(1)
	glfw.SetWindowTitle("Chipmunk demo")
	glfw.SetWindowSizeCallback(onResize)
	glfw.SetKeyCallback(onKey)

	initGL()
	initScene()

	Running = true

	for Running && glfw.WindowParam(glfw.Opened) == 1 {
		drawScene()
		space.Step(1.0 / 20.0 / 3.0)
		space.Step(1.0 / 20.0 / 3.0)
		space.Step(1.0 / 20.0 / 3.0)
	}
}
开发者ID:ftrvxmtrx,项目名称:gochipmunk,代码行数:25,代码来源:main.go

示例8: main

func main() {
	log.Printf("Starting glfw window")

	err := glfw.Init()
	if err != nil {
		log.Fatalf("Error while starting glfw library: %v", err)
	}
	defer glfw.Terminate()

	err = glfw.OpenWindow(256, 256, 8, 8, 8, 0, 0, 0, glfw.Windowed)
	if err != nil {
		log.Fatalf("Error while opening glfw window: %v", err)
	}
	defer glfw.CloseWindow()

	glfw.SetSwapInterval(1) //vsync on

	glfw.SetWindowTitle("Colored Triangle")

	InitGL()

	glfw.SetWindowSizeCallback(func(w, h int) { InitGLWindow(w, h) })
	glfw.SetKeyCallback(func(key, state int) { HandleKey(key, state) })

	run := true
	for run && glfw.WindowParam(glfw.Opened) == 1 {
		select {
		case exitCode := <-exit:
			log.Printf("Received exit code: %d", exitCode)
			run = false
		default:
			Draw()
		}
	}
}
开发者ID:andrebq,项目名称:tinygl,代码行数:35,代码来源:triangle.go

示例9: main

func main() {
	globalState.Mouse = make(map[int]bool)
	flag.Parse()
	var err error
	if err = glfw.Init(); err != nil {
		fmt.Fprintf(os.Stderr, "[e] %v\n", err)
		return
	}

	if len(flag.Args()) == 0 {
		old := flag.Usage
		flag.Usage = func() {
			old()
			fmt.Fprintf(os.Stderr, "You MUST pass the name of the file to view\n")
		}
		flag.Usage()
		return
	}

	mesh, err = wfobj.LoadMeshFromFile(flag.Args()[0])
	if err != nil {
		flag.Usage()
		fmt.Fprintf(os.Stderr, "[e] %v\n", err)
		return
	}

	defer glfw.Terminate()

	if err = glfw.OpenWindow(Width, Height, 8, 8, 8, 8, 0, 8, glfw.Windowed); err != nil {
		fmt.Fprintf(os.Stderr, "[e] %v\n", err)
		return
	}

	defer glfw.CloseWindow()

	glfw.SetSwapInterval(1)
	glfw.SetWindowTitle(Title)
	glfw.SetWindowSizeCallback(onResize)
	glfw.SetKeyCallback(onKey)
	glfw.SetCharCallback(onChar)
	glfw.SetMouseWheelCallback(onWheel)
	glfw.SetMouseButtonCallback(onMouseButton)
	glfw.SetMousePosCallback(onMousePos)

	initGL()

	running = true
	for running && glfw.WindowParam(glfw.Opened) == 1 {
		handleInput()
		drawScene()
	}
}
开发者ID:andrebq,项目名称:wfobj,代码行数:52,代码来源:main.go

示例10: main

func main() {
	var err error
	if err = glfw.Init(); err != nil {
		fmt.Fprintf(os.Stderr, "[e] %v\n", err)
		return
	}

	// Ensure glfw is cleanly terminated on exit.
	defer glfw.Terminate()

	if err = glfw.OpenWindow(256, 256, 8, 8, 8, 0, 0, 0, glfw.Windowed); err != nil {
		fmt.Fprintf(os.Stderr, "[e] %v\n", err)
		return
	}

	// Ensure window is cleanly closed on exit.
	defer glfw.CloseWindow()

	// Enable vertical sync on cards that support it.
	glfw.SetSwapInterval(1)

	// Set window title
	glfw.SetWindowTitle("Simple GLFW window")

	// Hook some events to demonstrate use of callbacks.
	// These are not necessary if you don't need them.
	glfw.SetWindowSizeCallback(onResize)
	glfw.SetWindowCloseCallback(onClose)
	glfw.SetMouseButtonCallback(onMouseBtn)
	glfw.SetMouseWheelCallback(onMouseWheel)
	glfw.SetKeyCallback(onKey)
	glfw.SetCharCallback(onChar)

	// Start loop
	running := true
	for running {
		// OpenGL rendering goes here.

		// Swap front and back rendering buffers. This also implicitly calls
		// glfw.PollEvents(), so we have valid key/mouse/joystick states after
		// this. This behavior can be disabled by calling glfw.Disable with the
		// argument glfw.AutoPollEvents. You must be sure to manually call
		// PollEvents() or WaitEvents() in this case.
		glfw.SwapBuffers()

		// Break out of loop when Escape key is pressed, or window is closed.
		running = glfw.Key(glfw.KeyEsc) == 0 && glfw.WindowParam(glfw.Opened) == 1
	}
}
开发者ID:andrebq,项目名称:glfw,代码行数:49,代码来源:main.go

示例11: main

func main() {
	log.Printf("Starting glfw window")

	err := glfw.Init()
	if err != nil {
		log.Fatalf("Error while starting glfw library: %v", err)
	}
	defer glfw.Terminate()

	err = glfw.OpenWindow(256, 256, 8, 8, 8, 0, 0, 0, glfw.Windowed)
	if err != nil {
		log.Fatalf("Error while opening glfw window: %v", err)
	}
	defer glfw.CloseWindow()

	glfw.SetSwapInterval(1) //vsync on

	glfw.SetWindowTitle("Colored Triangle")

	InitGL()

	glfw.SetWindowSizeCallback(func(w, h int) { InitGLWindow(w, h) })
	glfw.SetKeyCallback(func(key, state int) { HandleKey(key, state) })

	// create a mesh with 3 vertices (a triangle)
	m := &Mesh{make([]*Vector, 3)}
	m.V[0] = &Vector{0, 1, 0, color.NRGBA{1, 0, 0, 0}}
	m.V[1] = &Vector{-1, -1, 0, color.NRGBA{0, 1, 0, 0}}
	m.V[2] = &Vector{1, -1, 0, color.NRGBA{0, 0, 1, 0}}

	run := true
	for run && glfw.WindowParam(glfw.Opened) == 1 {
		select {
		case exitCode := <-exit:
			log.Printf("Received exit code: %d", exitCode)
			run = false
		default:
			Draw(m)
		}
	}
}
开发者ID:andrebq,项目名称:tinygl,代码行数:41,代码来源:scene.go

示例12: InitInputHandlers

// Sets up input handlers
func InitInputHandlers() {
	InitKeyHandlers()

	glfw.SetMousePosCallback(func(x, y int) {

		dx, dy := x-mousePrevX, y-mousePrevY
		mousePrevX, mousePrevY = x, y
		if mouseButton[0] == 0 {
			return
		}

		Rot[0] += int(deltaLook * float64(dx))
		Rot[1] += int(deltaLook * float64(dy))

		// limit viewing angles
		for i := range Rot {
			if Rot[i] > 360 {
				Rot[i] = 0
			}
			if Rot[i] < 0 {
				Rot[i] += 360
			}
		}
		log.Println("rot:", Rot)
	})

	glfw.SetMouseButtonCallback(func(button, state int) {
		//log.Println("mousebutton:", button, state)
		mouseButton[button] = state
	})

	glfw.SetMouseWheelCallback(func(delta int) {
		//log.Println("mousewheel:", delta)
		glfw.SetMouseWheel(0)
	})

	glfw.SetWindowSizeCallback(func(w, h int) {
		Width, Height = w, h
		InitViewport()
	})
}
开发者ID:shenyp09,项目名称:mx3,代码行数:42,代码来源:input.go

示例13: main

func main() {

	flag.Parse()

	var done bool

	var err os.Error
	if err = glfw.Init(); err != nil {
		fmt.Fprintf(os.Stderr, "[e] %v\n", err)
		return
	}

	defer glfw.Terminate()

	if err = glfw.OpenWindow(300, 300, 0, 0, 0, 0, 0, 0, glfw.Windowed); err != nil {
		fmt.Fprintf(os.Stderr, "[e] %v\n", err)
		return
	}

	if gl.Init() != 0 {
		panic("gl error")
	}

	defer glfw.CloseWindow()

	glfw.SetWindowTitle("gears")

	glfw.SetWindowSizeCallback(reshape)

	init_()
	reshape(300, 300)
	done = false
	for !done {
		idle()
		draw()
		done = glfw.Key(glfw.KeyEsc) != 0 || glfw.WindowParam(glfw.Opened) == 0
	}

}
开发者ID:nkostelnik,项目名称:gl,代码行数:39,代码来源:glfwgears.go

示例14: initWindow

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)
}
开发者ID:dane-unltd,项目名称:gina,代码行数:23,代码来源:gina.go

示例15: NewWindow

func NewWindow(r Renderer) (*Window, error) {
	w := &Window{r, time.Now()}
	var err error
	// Fail if the window is in use, even after its
	// finalizer has had a change to run.
	if busy {
		runtime.GC()
		runtime.GC()
		if busy {
			return nil, err
		}
	}
	if err = glfw.Init(); err != nil {
		goto abort_with_nothing
	}
	if err = glfw.OpenWindow(1024, 1024, 0, 0, 0, 0, 0, 0, glfw.Windowed); err != nil {
		goto abort_with_glfw_init
	}
	if gl.Init() != 0 {
		goto abort_with_open_window
	}
	glfw.SetWindowTitle(os.Args[0])
	glfw.SetWindowSizeCallback(reshape)
	glInit()
	reshape(1024, 1024)
	runtime.SetFinalizer(w, finalizeWindow)
	busy = true
	return w, nil

abort_with_open_window:
	glfw.CloseWindow()
abort_with_glfw_init:
	glfw.Terminate()
abort_with_nothing:
	return nil, error(err)
}
开发者ID:glenn-brown,项目名称:vu,代码行数:36,代码来源:window.go


注:本文中的github.com/jteeuwen/glfw.SetWindowSizeCallback函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。