本文整理匯總了Golang中github.com/gopherjs/webgl.Context.DrawArrays方法的典型用法代碼示例。如果您正苦於以下問題:Golang Context.DrawArrays方法的具體用法?Golang Context.DrawArrays怎麽用?Golang Context.DrawArrays使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/gopherjs/webgl.Context
的用法示例。
在下文中一共展示了Context.DrawArrays方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: updateCamera
func updateCamera(ws *websocket.WebSocket, gl *webgl.Context, renderer <-chan struct{}) {
const tick30hz = (1000 / 30) * time.Millisecond
var (
camera trace.FreeFlightCamera
oldPos [3]float32
positions = make(chan [3]float32, 1)
)
positions <- oldPos
go func() {
for {
pos := <-positions
fmt.Println("New position:", pos)
m, err := json.Marshal(updateMessage{Position: pos})
assert(err)
assert(ws.Send(string(m)))
<-renderer
}
}()
for _ = range time.Tick(tick30hz) {
switch {
case keys[38]: // Up
camera.YRot += cameraSpeed
case keys[40]: // Down
camera.YRot -= cameraSpeed
case keys[37]: // Left
camera.XRot += cameraSpeed
case keys[39]: // Right
camera.XRot -= cameraSpeed
case keys[87]: // W
camera.Move(cameraSpeed)
case keys[83]: // S
camera.Move(-cameraSpeed)
case keys[65]: // A
camera.Strafe(cameraSpeed)
case keys[68]: // D
camera.Strafe(-cameraSpeed)
case keys[69]: // E
camera.Lift(cameraSpeed)
case keys[81]: // Q
camera.Lift(-cameraSpeed)
}
if oldPos != camera.Pos {
select {
case positions <- camera.Pos:
oldPos = camera.Pos
default:
}
}
mat := mat4.Ident
mat.AssignEulerRotation(camera.XRot, camera.YRot, 0)
mat.Transpose()
gl.UniformMatrix4fv(uniformViewLocation, false, mat.Slice())
gl.DrawArrays(gl.TRIANGLES, 0, 6)
}
}