本文整理匯總了Golang中github.com/chsc/gogl/gl21.Float函數的典型用法代碼示例。如果您正苦於以下問題:Golang Float函數的具體用法?Golang Float怎麽用?Golang Float使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Float函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: NewSystem
// Creates a new system using (temorarily) hard-coded constants
func NewSystem(X, Y int) System {
numStars := 1
numPlanets := rand.Int() % 12
// Make the slice of Planet
planets := make([]*data.Planet, numPlanets+1)
// TODO get rid of hard coded constants
for i := 0; i <= numPlanets; i++ {
orbitSizeX := rand.Float64()*4000 + 2000
orbitSizeY := rand.Float64()*4000 + 2000
orbitSpeed := rand.Float64() / ((orbitSizeX + orbitSizeY) / 10)
size := gl.Float(rand.Float64() * 100)
planets[i] = &data.Planet{data.GameObject{PlanetTextures[0], 0, 0, size, size, 0},
orbitSizeX, orbitSizeY, orbitSpeed, float64(X), float64(Y)}
}
// Make the slice of Stars for each system
stars := make([]*data.Star, numStars+1)
for i := 0; i <= numStars; i++ {
stars[i] = &data.Star{data.GameObject{PlanetTextures[0], gl.Float(X), gl.Float(Y), gl.Float(X + 300), gl.Float(Y + 300), 0}}
}
return System{X, Y, numStars, numPlanets, planets, stars}
}
示例2: Cylinder
func Cylinder(r, h gl.Float, slices int, hollow, solid bool) {
res := 2 * math.Pi / float64(slices)
mode := gl.LINE_LOOP
if solid {
mode = gl.QUADS
}
gl.Begin(gl.Enum(mode))
for a := 0.0; a < 2*math.Pi; a += res {
gl.Normal3f(gl.Float(math.Cos(a)), gl.Float(math.Sin(a)), 0)
gl.Vertex3f(r*gl.Float(math.Cos(a)), r*gl.Float(math.Sin(a)), 0)
gl.Vertex3f(r*gl.Float(math.Cos(a)), r*gl.Float(math.Sin(a)), h)
a += res
gl.Vertex3f(r*gl.Float(math.Cos(a)), r*gl.Float(math.Sin(a)), h)
gl.Vertex3f(r*gl.Float(math.Cos(a)), r*gl.Float(math.Sin(a)), 0)
}
gl.End()
if !hollow {
// X Y plane
if h < 0 {
gl.Normal3f(0, 0, 1)
} else {
gl.Normal3f(0, 0, -1)
}
Circle(r, slices, solid)
// Top (or bottom)
if h < 0 {
gl.Normal3f(0, 0, -1)
} else {
gl.Normal3f(0, 0, 1)
}
gl.Translatef(0, 0, h)
Circle(r, slices, solid)
}
}
示例3: drawMatrix
func drawMatrix(m *[][]Point, xby, yby gl.Float) {
for x, row := range *m {
for y, p := range row {
UseColor(PointColor(p))
// fmt.Println(p, PointColor(p))
// gl.Color4f(1, 0, 0, 1)
gl.Vertex2f(gl.Float(x)*xby, gl.Float(y)*yby)
}
}
}
示例4: PlanetOrbit
/* Updates o's position using its movement function.
The movemet function looks something like
(x,y) = (f(t),g(t)) where for elliptic orbits
f = Acos(t)
g = Bsin(t)
*/
func PlanetOrbit(o *data.Planet, t float64) {
A := o.OrbitParam1
B := o.OrbitParam2
C := o.OrbitParam3
x0 := o.OrbitParam4
y0 := o.OrbitParam5
o.AbsMove(gl.Float(A*math.Sin(t*C)+x0), gl.Float(B*math.Cos(t*C)+y0))
}
示例5: SetUniform4F
func SetUniform4F(shader, variable string, vs []float32) error {
prog, ok := shader_progs[shader]
if !ok {
return shaderError(fmt.Sprintf("Tried to set a uniform in an unknown shader '%s'", shader))
}
bvariable := []byte(fmt.Sprintf("%s\x00", variable))
loc := gl.GetUniformLocation(prog, (*gl.Char)(unsafe.Pointer(&bvariable[0])))
gl.Uniform4f(loc, gl.Float(vs[0]), gl.Float(vs[1]), gl.Float(vs[2]), gl.Float(vs[3]))
return nil
}
示例6: SetUniformV2
func SetUniformV2(shader, variable string, v linear.Vec2) {
prog, ok := shader_progs[shader]
if !ok {
if !warned_names[shader] {
Warn().Printf("Tried to set a uniform in an unknown shader '%s'", shader)
warned_names[shader] = true
}
return
}
bvariable := []byte(fmt.Sprintf("%s\x00", variable))
loc := gl.GetUniformLocation(prog, (*gl.Char)(unsafe.Pointer(&bvariable[0])))
gl.Uniform2f(loc, gl.Float(v.X), gl.Float(v.Y))
}
示例7: SetVariable4f
// SetVariable4f sets a specified variable to the four supplied integers to
// be passed into an effect.
func (effect *Effect) SetVariable4f(variable string, val1 float32, val2 float32, val3 float32, val4 float32) error {
var currEffect gl.Int
gl.GetIntegerv(gl.CURRENT_PROGRAM, &currEffect)
if gl.Uint(currEffect) != effect.program {
return errors.New("effect is not currently in use")
}
effect.checkUniformVariable(variable)
gl.Uniform4f(effect.uniforms[variable], gl.Float(val1), gl.Float(val2), gl.Float(val3), gl.Float(val4))
return nil
}
示例8: Ellipse
func Ellipse(rX, rY gl.Float, slices int, solid bool) {
mode := gl.LINE_LOOP
if solid {
mode = gl.POLYGON
}
res := 2 * math.Pi / float64(slices)
gl.Begin(gl.Enum(mode))
gl.Vertex2f(0, 0)
for a := 0.0; a < 2*math.Pi; a += res {
gl.Vertex2f(rX*gl.Float(math.Cos(a)), rY*gl.Float(math.Sin(a)))
}
gl.End()
}
示例9: Box
func Box(x, y, z float32, solid bool) {
mode := gl.LINE_LOOP
if solid {
mode = gl.QUADS
}
X := gl.Float(x) / 2
Y := gl.Float(y) / 2
Z := gl.Float(z) / 2
gl.Begin(gl.Enum(mode))
gl.Normal3f(0, 0, 1) // Positive Z Face
gl.Vertex3f(-X, -Y, Z)
gl.Vertex3f(X, -Y, Z)
gl.Vertex3f(X, Y, Z)
gl.Vertex3f(-X, Y, Z)
gl.Normal3f(0, 0, -1) // Negative Z Face
gl.Vertex3f(-X, -Y, -Z)
gl.Vertex3f(-X, Y, -Z)
gl.Vertex3f(X, Y, -Z)
gl.Vertex3f(X, -Y, -Z)
gl.Normal3f(0, 1, 0) // Positive Y Face
gl.Vertex3f(-X, Y, -Z)
gl.Vertex3f(-X, Y, Z)
gl.Vertex3f(X, Y, Z)
gl.Vertex3f(X, Y, -Z)
gl.Normal3f(0, -1, 0) // Negative Y Face
gl.Vertex3f(-X, -Y, -Z)
gl.Vertex3f(X, -Y, -Z)
gl.Vertex3f(X, -Y, Z)
gl.Vertex3f(-X, -Y, Z)
gl.Normal3f(1, 0, 0) // Positive X Face
gl.Vertex3f(X, -Y, -Z)
gl.Vertex3f(X, Y, -Z)
gl.Vertex3f(X, Y, Z)
gl.Vertex3f(X, -Y, Z)
gl.Normal3f(-1, 0, 0) // Negative X Face
gl.Vertex3f(-X, -Y, -Z)
gl.Vertex3f(-X, -Y, Z)
gl.Vertex3f(-X, Y, Z)
gl.Vertex3f(-X, Y, -Z)
gl.End()
}
示例10: drawScene
func drawScene() {
fps()
gl.Clear(gl.COLOR_BUFFER_BIT)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
if input.Zoom > 0 {
gl.Ortho(0, gl.Double(float64(*flagSize)/input.Zoom), gl.Double(float64(*flagSize)/input.Zoom), 0, -1, 1.0)
}
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Translatef(gl.Float(input.TransX*1), gl.Float(input.TransY*1), 0)
drawGrid()
drawCells()
}
示例11: PointColor
func PointColor(p Point) Color {
n := gl.Float(float64(p.Intensity) / 10.0)
/*
if p.Color == WHITE {
return Color{1.0, 1.0, 1.0, 1}
}
if p.Color == RED {
return Color{1, 1-n, 1-n, 1}
}
if p.Color == GREEN {
return Color{1-n, 1, 1-n, 1}
}
return Color{1-n, 1-n, 1, 1}
*/
if p.Color == WHITE {
return Color{0, 0, 0, 1}
}
if p.Color == RED {
return Color{n, 0, 0, 1}
}
if p.Color == GREEN {
return Color{0, n, 0, 1}
}
return Color{0, 0, n, 1}
}
示例12: factor
func factor(t time.Time, tc0 time.Time, tc1 time.Time) gl.Float {
num := t.Sub(tc0)
den := tc1.Sub(tc0)
res := num.Seconds() / den.Seconds()
res = math.Max(res, 0)
res = math.Min(res, 1)
return gl.Float(res)
}
示例13: SetUniformV2Array
func SetUniformV2Array(shader, variable string, vs []linear.Vec2) {
prog, ok := shader_progs[shader]
if !ok {
if !warned_names[shader] {
Warn().Printf("Tried to set a uniform in an unknown shader '%s'", shader)
warned_names[shader] = true
}
return
}
bvariable := []byte(fmt.Sprintf("%s\x00", variable))
loc := gl.GetUniformLocation(prog, (*gl.Char)(unsafe.Pointer(&bvariable[0])))
var fs []gl.Float
for i := range vs {
fs = append(fs, gl.Float(vs[i].X))
fs = append(fs, gl.Float(vs[i].Y))
}
gl.Uniform2fv(loc, gl.Sizei(len(vs)), (*gl.Float)(unsafe.Pointer(&fs[0])))
}
示例14: toGLFloat
func (m *Matrix3) toGLFloat() Matrix3GLFloat {
var glm Matrix3GLFloat
for i := range m {
glm[i] = gl.Float(m[i])
}
return glm
}
示例15: drawCells
func drawCells() {
if input.Zoom > 0 {
gl.PointSize(gl.Float(float64(Width) / float64(*flagSize) * input.Zoom))
}
gl.Color4f(1, 1, 1, 1)
gl.Enable(gl.POINT_SMOOTH)
gl.Begin(gl.POINTS)
for i, j := 0, 0; i < (life.Size * life.Size); i, j = i+life.Size, j+1 {
for k, v := range life.Cells[i : i+life.Size] {
if v {
gl.Vertex2f(gl.Float(k), gl.Float(j))
}
}
}
gl.End()
gl.Disable(gl.POINT_SMOOTH)
}