本文整理汇总了Golang中golang.org/x/mobile/gl.Context.UniformMatrix3fv方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.UniformMatrix3fv方法的具体用法?Golang Context.UniformMatrix3fv怎么用?Golang Context.UniformMatrix3fv使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类golang.org/x/mobile/gl.Context
的用法示例。
在下文中一共展示了Context.UniformMatrix3fv方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: onPaint
func onPaint(glctx gl.Context, sz size.Event) {
glctx.Viewport(0, 0, sz.WidthPx, sz.HeightPx)
glctx.ClearColor(0.5, 0.5, 0.5, 1)
glctx.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
glctx.UseProgram(program)
projectionMtx = mgl32.Perspective(45, float32(width)/float32(height), 0.1, 100)
arcBallMtx := arcball.getMtx()
glctx.UniformMatrix4fv(projection, projectionMtx[:])
glctx.UniformMatrix4fv(view, arcBallMtx[:])
glctx.BindBuffer(gl.ARRAY_BUFFER, triBuf)
glctx.EnableVertexAttribArray(position)
glctx.EnableVertexAttribArray(color)
glctx.EnableVertexAttribArray(normals)
vertSize := 4 * (coordsPerVertex + colorPerVertex + normalsPerVertex)
glctx.VertexAttribPointer(position, coordsPerVertex, gl.FLOAT, false, vertSize, 0)
glctx.VertexAttribPointer(color, colorPerVertex, gl.FLOAT, false, vertSize, 4*coordsPerVertex)
glctx.VertexAttribPointer(normals, normalsPerVertex, gl.FLOAT, false, vertSize, 4*(coordsPerVertex+colorPerVertex))
glctx.DepthMask(true)
glctx.Uniform3fv(lightPos, light.Pos[:])
glctx.Uniform3fv(lightIntensity, light.Intensities[:])
for _, k := range piano.Keys {
glctx.Uniform4fv(tint, k.Color[:])
mtx := k.GetMtx()
normMat := mtx.Mat3().Inv().Transpose()
glctx.UniformMatrix3fv(normalMatrix, normMat[:])
glctx.UniformMatrix4fv(model, mtx[:])
glctx.DrawArrays(gl.TRIANGLES, 0, len(triangleData)/vertSize)
}
modelMtx := mgl32.Ident4()
modelMtx = modelMtx.Mul4(mgl32.Translate3D(worldPos.X(), worldPos.Y(), worldPos.Z()))
modelMtx = modelMtx.Mul4(mgl32.Scale3D(0.5, 0.5, 0.5))
/*
glctx.Uniform4fv(tint, red[:])
// Disable depthmask so we dont get the pixel depth of the cursor cube
glctx.DepthMask(false)
glctx.UniformMatrix4fv(model, modelMtx[:])
glctx.DepthMask(true)
*/
glctx.DisableVertexAttribArray(position)
glctx.DisableVertexAttribArray(color)
glctx.DisableVertexAttribArray(normals)
fps.Draw(sz)
}
示例2: writeAffine
// writeAffine writes the contents of an Affine to a 3x3 matrix GL uniform.
func writeAffine(glctx gl.Context, u gl.Uniform, a *f32.Affine) {
var m [9]float32
m[0*3+0] = a[0][0]
m[0*3+1] = a[1][0]
m[0*3+2] = 0
m[1*3+0] = a[0][1]
m[1*3+1] = a[1][1]
m[1*3+2] = 0
m[2*3+0] = a[0][2]
m[2*3+1] = a[1][2]
m[2*3+2] = 1
glctx.UniformMatrix3fv(u, m[:])
}
示例3: writeAff3
// writeAff3 must only be called while holding windowImpl.glctxMu.
func writeAff3(glctx gl.Context, u gl.Uniform, a f64.Aff3) {
var m [9]float32
m[0*3+0] = float32(a[0*3+0])
m[0*3+1] = float32(a[1*3+0])
m[0*3+2] = 0
m[1*3+0] = float32(a[0*3+1])
m[1*3+1] = float32(a[1*3+1])
m[1*3+2] = 0
m[2*3+0] = float32(a[0*3+2])
m[2*3+1] = float32(a[1*3+2])
m[2*3+2] = 1
glctx.UniformMatrix3fv(u, m[:])
}