代码拉取完成,页面将自动刷新
// +build !android
package main
import (
"log"
"runtime"
"github.com/go-gl/glfw/v3.2/glfw"
)
var wMouseLeft = false
func CursorPosCallback(w *glfw.Window, x float64, y float64) {
mouseEvent(int(float32(x)/WINDOWSCALE), int(float32(y)/WINDOWSCALE), wMouseLeft)
}
func MouseButtonCallback(w *glfw.Window, button glfw.MouseButton, action glfw.Action, mod glfw.ModifierKey) {
x, y := w.GetCursorPos()
if button == glfw.MouseButtonLeft {
switch action {
case glfw.Press, glfw.Repeat:
wMouseLeft = true
case glfw.Release:
wMouseLeft = false
}
mouseEvent(int(float32(x)/WINDOWSCALE), int(float32(y)/WINDOWSCALE), wMouseLeft)
}
}
func FocusCallback(w *glfw.Window, focused bool) {
if !focused {
//destroyed()
} else {
//redraw()
}
}
func main() {
runtime.LockOSThread()
log.Printf("main ...")
if err := glfw.Init(); err != nil {
panic(err)
}
defer glfw.Terminate()
glfw.WindowHint(glfw.ContextVersionMajor, 2)
glfw.WindowHint(glfw.ContextVersionMinor, 0)
glfw.WindowHint(glfw.OpenGLProfile, glfw.OpenGLCoreProfile)
// 以下是指定用 EGL 和 OpenGL ES
glfw.WindowHint(glfw.ContextCreationAPI, glfw.EGLContextAPI)
glfw.WindowHint(glfw.ClientAPI, glfw.OpenGLESAPI)
w, err := glfw.CreateWindow(width, height, "Record", nil, nil)
if err != nil {
panic(err)
}
w.MakeContextCurrent()
curWin = w
width, height = w.GetSize()
preCreate(nil)
create()
postCreate(nil)
initEGL()
w.SetCursorPosCallback(CursorPosCallback)
w.SetMouseButtonCallback(MouseButtonCallback)
w.SetFocusCallback(FocusCallback)
for !w.ShouldClose() {
glfw.WaitEvents()
draw()
}
releaseEGL()
destroyed()
log.Printf("done")
}
var curWin *glfw.Window
const RECORDPATH = "./sdcard/records"
func getDensity() int { return density }
func SwapBuffers() { curWin.SwapBuffers() }
func Wake() { glfw.PostEmptyEvent() }
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。