本文整理汇总了Golang中github.com/jteeuwen/glfw.Terminate函数的典型用法代码示例。如果您正苦于以下问题:Golang Terminate函数的具体用法?Golang Terminate怎么用?Golang Terminate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Terminate函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: 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
示例2: 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)
initGL()
running = true
for running && glfw.WindowParam(glfw.Opened) == 1 {
drawScene()
}
}
开发者ID:sycoso,项目名称:glfw,代码行数:28,代码来源:main.go
示例3: 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
示例4: 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
示例5: main
func main() {
if err := glfw.Init(); err != nil {
fmt.Fprintf(os.Stderr, "glfw: %s\n", err)
return
}
defer glfw.Terminate()
glfw.OpenWindowHint(glfw.WindowNoResize, 0)
if err := glfw.OpenWindow(Width, Height, 0, 0, 0, 0, 16, 0, glfw.Windowed); err != nil {
fmt.Fprintf(os.Stderr, "glfw: %s\n", err)
return
}
defer glfw.CloseWindow()
glfw.SetSwapInterval(60)
glfw.SetWindowTitle(Title)
if err := gl.Init(); err != nil {
fmt.Fprintf(os.Stderr, "gl: %s\n", err)
}
keybindings.BindKeyboard()
gl.ClearColor(0, 0, 0, 1)
GameLoop()
}
开发者ID:kelly-ry4n,项目名称:glGalaxy,代码行数:29,代码来源:gameloop.go
示例6: main
func main() {
flag.Parse()
Load(flag.Args())
Init(800, 600, *flag_smooth, *flag_multisample, true)
InitInputHandlers()
defer glfw.CloseWindow()
defer glfw.Terminate()
start := time.Now()
frames := 0
Viewpos[2] = -20
for glfw.WindowParam(glfw.Opened) == 1 { // window open
Render()
frames++
if Wantscrot {
Screenshot()
Wantscrot = false
}
glfw.WaitEvents()
}
fps := int((float64(frames) / float64(time.Since(start))) * float64(time.Second))
log.Println("average FPS:", fps)
}
开发者ID:shenyp09,项目名称:mx3,代码行数:28,代码来源:interactive.go
示例7: main
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()
}
}
}
开发者ID:remirisque,项目名称:miniworld,代码行数:35,代码来源:main.go
示例8: main
func main() {
if err := glfw.Init(); err != nil {
fmt.Fprintf(os.Stderr, "glfw: %s\n", err)
return
}
defer glfw.Terminate()
glfw.OpenWindowHint(glfw.WindowNoResize, 1)
if err := glfw.OpenWindow(Width, Height, 0, 0, 0, 0, 0, 0, glfw.Windowed); err != nil {
fmt.Fprintf(os.Stderr, "glfw: %s\n", err)
return
}
defer glfw.CloseWindow()
glfw.SetSwapInterval(1)
glfw.SetWindowTitle(Title)
if err := gl.Init(); err != nil {
fmt.Fprintf(os.Stderr, "gl: %s\n", err)
}
if err := initScene(); err != nil {
fmt.Fprintf(os.Stderr, "init: %s\n", err)
return
}
defer destroyScene()
for glfw.WindowParam(glfw.Opened) == 1 {
drawScene()
glfw.SwapBuffers()
}
}
开发者ID:sserafimescu,项目名称:gogl,代码行数:33,代码来源:gopher.go
示例9: 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
示例10: main
func main() {
// We need to lock the goroutine to one thread due time.Ticker
runtime.LockOSThread()
var err os.Error
err = glfw.Init()
if err != nil {
fmt.Printf("GLFW: %s\n", err)
return
}
defer glfw.Terminate()
// You could probably change the required versions down
glfw.OpenWindowHint(glfw.OpenGLVersionMajor, 3)
glfw.OpenWindowHint(glfw.OpenGLVersionMinor, 3)
glfw.OpenWindowHint(glfw.OpenGLProfile, 1)
// Open Window with 8 bit Alpha
err = glfw.OpenWindow(ScreenWidth, ScreenHeight, 0, 0, 0, 8, 0, 0, glfw.Windowed)
if err != nil {
fmt.Printf("GLFW: %s\n", err)
return
}
defer glfw.CloseWindow()
glfw.SetWindowTitle(WindowTitle)
major, minor, rev := glfw.GLVersion()
if major < 3 {
fmt.Printf("Error your graphic card does not support OpenGL 3.3\n Your GL-Version is: %d, %d, %d\n", major, minor, rev)
fmt.Println("You can try to lower the settings in glfw.OpenWindowHint(glfw.OpenGLVersionMajor/Minor.")
}
initStatus := gl.Init() // Init glew
if initStatus != 0 {
fmt.Printf("Error-code: %d Init-Status: %d\n", gl.GetError(), initStatus)
}
// Enable transparency in OpenGL
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
initResources()
// We are limiting the calls to display() (frames per second) to 60. This prevents the 100% cpu usage.
ticker := time.NewTicker(int64(second) / 60) // max 60 fps
for {
<-ticker.C
move := float32(math.Sin(glfw.Time()))
angle := float32(glfw.Time())
matrix = math3d.MakeTranslationMatrix(move, 0.0, 0.0)
matrix = matrix.Multiply(math3d.MakeZRotationMatrix(angle)).Transposed()
display()
}
// Free resources
free()
runtime.UnlockOSThread()
}
开发者ID:pdelbarba,项目名称:gl3-examples,代码行数:59,代码来源:main.go
示例11: 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
示例12: keyPressListener
func keyPressListener(key int, action int) {
if !running {
return
}
if action == glfw.KeyPress {
width := appWidth
height := appHeight
switch key {
case glfw.KeyEsc:
running = false
case glfw.KeyF1:
app.release()
glfw.CloseWindow()
// Toggle fullscreen mode
fullScreen = !fullScreen
if fullScreen {
mode := glfw.DesktopMode()
aspect := float32(mode.W) / float32(mode.H)
if int(aspect*100) == 133 || int(aspect*100) == 125 { // Standard
width = 1280
height = 1024
} else if int(aspect*100) == 177 { // Widescreen 16:9
width = 1280
height = 720
} else if int(aspect*100) == 160 { // Widescreen 16:10
width = 1280
height = 800
} else { // Unknown
// Use desktop resolution
width = mode.W
height = mode.H
}
}
if !setupWindow(width, height, fullScreen) {
glfw.Terminate()
//exit( -1 );
}
app.init()
app.resize(width, height)
t0 = glfw.Time()
}
}
}
开发者ID:floffel03,项目名称:gohorde,代码行数:50,代码来源:knight.go
示例13: Live
func Live(in_ nimble.ChanN) {
go func() {
in := in_.NewReader()
Frame = new(dump.Frame)
Frame.Components = in.NComp()
Frame.MeshSize = in.Mesh().Size()
Frame.MeshStep = in.Mesh().CellSize()
Crop2 = Frame.MeshSize
ncell := in.Mesh().NCell()
n := ncell * in.NComp()
Frame.Data = make([]float32, n)
Init(800, 600, true, 2, true)
InitInputHandlers()
defer glfw.CloseWindow()
defer glfw.Terminate()
Viewpos[2] = -20
wantframe := new(atomicbool)
wantframe.set(true)
go func() {
gpu.LockCudaThread()
for {
data := in.ReadNext(ncell)
if wantframe.get() {
for i, d := range data {
d.Device().CopyDtoH(Frame.Data[i*ncell : (i+1)*ncell])
}
wantframe.set(false)
}
in.ReadDone()
}
}()
for glfw.WindowParam(glfw.Opened) == 1 { // window open
Render()
if Wantscrot {
Screenshot()
Wantscrot = false
}
if wantframe.get() == false {
PreRender(Frame)
wantframe.set(true)
}
}
}()
}
开发者ID:shenyp09,项目名称:mx3,代码行数:49,代码来源:live.go
示例14: 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
示例15: main
func main() {
Load(os.Args[1:])
Init(800, 600, true, Multi, false)
defer glfw.CloseWindow()
defer glfw.Terminate()
Viewpos[2] = -20
for {
Render()
time.Sleep(1 * time.Second)
Screenshot()
NextFrame()
}
}
开发者ID:shenyp09,项目名称:mx3,代码行数:16,代码来源:animate.go
示例16: main
func main() {
flag.Parse()
if *cpuprofile != "" {
f, err := os.Create(*cpuprofile)
if err != nil {
log.Fatal(err)
}
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
}
if err := readModel(); err != nil {
log.Fatal(err)
}
if err := glfw.Init(); err != nil {
log.Fatal(err)
}
defer glfw.Terminate()
glfw.OpenWindowHint(glfw.WindowNoResize, 1)
if err := glfw.OpenWindow(Width, Height, 0, 0, 0, 0, 16, 0, glfw.Windowed); err != nil {
log.Fatal(err)
return
}
defer glfw.CloseWindow()
glfw.SetSwapInterval(1)
glfw.SetWindowTitle(Title)
glfw.SetKeyCallback(onKey)
if err := gl.Init(); err != nil {
log.Fatal(err)
}
initScene()
defer destroyScene()
for glfw.WindowParam(glfw.Opened) == 1 {
applyMove()
drawScene()
glfw.SwapBuffers()
}
}
开发者ID:jayschwa,项目名称:groke,代码行数:47,代码来源:bspview.go
示例17: Init
func (o *OpenGl) Init() {
if err := glfw.Init(); err != nil {
fmt.Fprintf(os.Stderr, "glfw: %s\n", err)
return
}
defer glfw.Terminate()
if err := glfw.OpenWindow(o.width, o.height, 0, 0, 0, 0, 16, 0, glfw.Windowed); err != nil {
fmt.Fprintf(os.Stderr, "glfw: %s\n", err)
return
}
defer glfw.CloseWindow()
glfw.SetSwapInterval(1)
glfw.SetWindowTitle(o.title)
if err := gl.Init(); err != nil {
fmt.Fprintf(os.Stderr, "gl: %s\n", err)
}
glfw.SetKeyCallback(glfw.KeyHandler(o.keyboard))
glfw.SetMouseButtonCallback(glfw.MouseButtonHandler(o.mouseClick))
glfw.SetMousePosCallback(glfw.MousePosHandler(o.mouseMove))
glfw.SetMouseWheelCallback(glfw.MouseWheelHandler(o.mouseWheel))
if err := o.initScene(); err != nil {
fmt.Fprintf(os.Stderr, "init: %s\n", err)
return
}
for glfw.WindowParam(glfw.Opened) == 1 {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
if o.display3d != nil {
o.set3dView()
o.display3d()
}
if o.display2d != nil {
o.set2dView()
o.display2d()
}
glfw.SwapBuffers()
time.Sleep(20 * time.Millisecond)
//<-o.redisplay
}
}
开发者ID:knickers,项目名称:GOpenGL,代码行数:47,代码来源:GOpenGL.go
示例18: main
func main() {
// Setup the window
if err := glfw.Init(); err != nil {
fmt.Fprintf(os.Stderr, "glfw: %s\n", err)
return
}
// Close glfw at the end of main()
defer glfw.Terminate()
// Set window properties
glfw.OpenWindowHint(glfw.WindowNoResize, 0)
//glfw.OpenWindowHint(glfw.OpenGLForwardCompat, gl.TRUE)
glfw.OpenWindowHint(glfw.OpenGLDebugContext, gl.TRUE)
// Actually open the window
if err := glfw.OpenWindow(initial_width, initial_height, 0, 0, 0, 0, 16, 0, glfw.Windowed); err != nil {
fmt.Fprintf(os.Stderr, "glfw: %s\n", err)
return
}
// Close the window at the end of main()
defer glfw.CloseWindow()
// Only swap buffer once/ draw cycle (30 or 60 fps)
glfw.SetSwapInterval(1)
glfw.SetWindowTitle(Title)
// Apply those settings
if err := gl.Init(); err != nil {
fmt.Fprintf(os.Stderr, "gl: %s\n", err)
}
// While glfw.Opened is 1 (the window is open), keep swapping buffers
for glfw.WindowParam(glfw.Opened) == 1 {
glfw.SwapBuffers()
}
setCallbacks()
// Initialize the openGL settings
Initialize()
}
开发者ID:kelly-ry4n,项目名称:go-particles,代码行数:45,代码来源:render.go
示例19: main
func main() {
if e := glfw.Init(); e != nil {
panic(e.Error())
}
defer glfw.Terminate()
if e := glfw.OpenWindow(468, 320, 0, 0, 0, 0, 0, 0, glfw.Windowed); e != nil {
panic(e.Error())
}
if gl.Init() != 0 {
panic("GL Err")
}
glfw.SetKeyCallback(escHandler)
loop()
}
开发者ID:simonz05,项目名称:draw,代码行数:19,代码来源:draw.go
示例20: 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
注:本文中的github.com/jteeuwen/glfw.Terminate函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论