本文整理匯總了Golang中github.com/gopherjs/webgl.Context.Call方法的典型用法代碼示例。如果您正苦於以下問題:Golang Context.Call方法的具體用法?Golang Context.Call怎麽用?Golang Context.Call使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/gopherjs/webgl.Context
的用法示例。
在下文中一共展示了Context.Call方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: setupConnection
func setupConnection(gl *webgl.Context) {
document := js.Global.Get("document")
location := document.Get("location")
ws, err := websocket.New(fmt.Sprintf("ws://%s/render", location.Get("host")))
assert(err)
renderer := make(chan struct{})
onOpen := func(ev *js.Object) {
setup := setupMessage{
Resolution: imgCmResolution,
ClearColor: [4]byte{127, 127, 127, 255},
}
msg, err := json.Marshal(setup)
assert(err)
assert(ws.Send(string(msg)))
go updateCamera(ws, gl, renderer)
}
onMessage := func(ev *js.Object) {
face := frameId % 6
fmt.Println("Received face:", face)
data := js.Global.Get("Uint8Array").New(ev.Get("data"))
gl.Call("texImage2D", gl.TEXTURE_CUBE_MAP_POSITIVE_X+face, 0, gl.RGBA, imgCmResolution, imgCmResolution, 0, gl.RGBA, gl.UNSIGNED_BYTE, data)
frameId++
select {
case renderer <- struct{}{}:
default:
}
}
ws.BinaryType = "arraybuffer"
ws.AddEventListener("open", false, onOpen)
ws.AddEventListener("message", false, onMessage)
}
示例2: setupTextures
func setupTextures(gl *webgl.Context, program *js.Object) {
gl.ActiveTexture(gl.TEXTURE0)
gl.BindTexture(gl.TEXTURE_CUBE_MAP, gl.CreateTexture())
for i := 0; i < 6; i++ {
gl.Call("texImage2D", gl.TEXTURE_CUBE_MAP_POSITIVE_X+i, 0, gl.RGBA, imgCmResolution, imgCmResolution, 0, gl.RGBA, gl.UNSIGNED_BYTE, nil)
}
gl.TexParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR)
gl.TexParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.LINEAR)
/*
gl.TexParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.NEAREST)
gl.TexParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.NEAREST)
*/
gl.TexParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE)
gl.TexParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE)
gl.Uniform1i(gl.GetUniformLocation(program, "s_texture"), 0)
}