本文整理汇总了Golang中github.com/chsc/gogl/gl21.Float函数的典型用法代码示例。如果您正苦于以下问题:Golang Float函数的具体用法?Golang Float怎么用?Golang Float使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Float函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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}
}
开发者ID:kelly-ry4n,项目名称:glGalaxy,代码行数:30,代码来源:universe.go
示例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)
}
}
开发者ID:knickers,项目名称:GOpenGL,代码行数:34,代码来源:shapes.go
示例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)
}
}
}
开发者ID:jaredly,项目名称:rocks,代码行数:10,代码来源:game.go
示例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))
}
开发者ID:kelly-ry4n,项目名称:glGalaxy,代码行数:18,代码来源:simpleai.go
示例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
}
开发者ID:dgthunder,项目名称:glop,代码行数:10,代码来源:shader.go
示例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))
}
开发者ID:runningwild,项目名称:jota,代码行数:13,代码来源:shaders.go
示例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
}
开发者ID:velovix,项目名称:paunch,代码行数:15,代码来源:effect.go
示例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()
}
开发者ID:knickers,项目名称:GOpenGL,代码行数:13,代码来源:shapes.go
示例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()
}
开发者ID:knickers,项目名称:GOpenGL,代码行数:48,代码来源:shapes.go
示例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()
}
开发者ID:dskinner,项目名称:cell,代码行数:16,代码来源:main.go
示例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}
}
开发者ID:jaredly,项目名称:rocks,代码行数:25,代码来源:game.go
示例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)
}
开发者ID:jacereda,项目名称:webmplay,代码行数:8,代码来源:webmplay.go
示例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])))
}
开发者ID:runningwild,项目名称:jota,代码行数:18,代码来源:shaders.go
示例14: toGLFloat
func (m *Matrix3) toGLFloat() Matrix3GLFloat {
var glm Matrix3GLFloat
for i := range m {
glm[i] = gl.Float(m[i])
}
return glm
}
开发者ID:drasich,项目名称:ridley,代码行数:9,代码来源:matrix.go
示例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)
}
开发者ID:dskinner,项目名称:cell,代码行数:21,代码来源:main.go
示例16: UpdateViewpos
// Set the GL modelview matrix to match view position and orientation.
func UpdateViewpos() {
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Translatef(gl.Float(Viewpos[0]), gl.Float(Viewpos[1]), gl.Float(Viewpos[2]))
gl.Rotatef(gl.Float(Rot[0]*2), 1, 0, 0)
gl.Rotatef(gl.Float(Rot[1]*2), 0, 1, 0)
gl.Rotatef(gl.Float(Rot[2]*2), 0, 0, 1)
}
开发者ID:shenyp09,项目名称:mx3,代码行数:9,代码来源:input.go
示例17: drawGrid
func drawGrid() {
gl.Color4f(0.2, 0.2, 0.2, 1)
gl.Begin(gl.LINES)
for i := -0.5; i < Width; i += 1 {
gl.Vertex2f(gl.Float(-0.5), gl.Float(i))
gl.Vertex2f(gl.Float(life.Size), gl.Float(i))
gl.Vertex2f(gl.Float(i), -0.5)
gl.Vertex2f(gl.Float(i), gl.Float(life.Size))
}
gl.End()
}
开发者ID:dskinner,项目名称:cell,代码行数:12,代码来源:main.go
示例18: drawQuad
func drawQuad(x, y, w, h int, u, v, u2, v2 float32) {
gl.Begin(gl.QUADS)
gl.TexCoord2f(gl.Float(u), gl.Float(v))
gl.Vertex2i(gl.Int(x), gl.Int(y))
gl.TexCoord2f(gl.Float(u2), gl.Float(v))
gl.Vertex2i(gl.Int(x+w), gl.Int(y))
gl.TexCoord2f(gl.Float(u2), gl.Float(v2))
gl.Vertex2i(gl.Int(x+w), gl.Int(y+h))
gl.TexCoord2f(gl.Float(u), gl.Float(v2))
gl.Vertex2i(gl.Int(x), gl.Int(y+h))
gl.End()
}
开发者ID:nsf,项目名称:gomandel,代码行数:17,代码来源:gomandel.go
示例19: renderPts
func renderPts() {
gl.MatrixMode(gl.MODELVIEW)
for i := minPt; i <= maxPt; i++ {
if Pts[i].is == false {
continue
}
pt := &Pts[i]
gl.PopMatrix()
gl.PushMatrix()
gl.Translatef(gl.Float(pt.X), gl.Float(pt.Y), -gl.Float(pt.Z))
gl.Scalef(gl.Float(pt.R*2), gl.Float(pt.R*2), gl.Float(pt.R*2))
gl.DrawArrays(gl.QUADS, 0, 24)
}
}
开发者ID:ReneSac,项目名称:ParticleBench,代码行数:14,代码来源:Go.go
示例20: DrawStarTex
func DrawStarTex(t *data.Star) {
// Find the center point of the texture to rotate around
xav := (t.X1 + t.X2) / 2
yav := (t.Y1 + t.Y2) / 2
//Translate there, rotate, translate back
gl.MatrixMode(gl.MODELVIEW)
gl.Translatef(xav, yav, 0)
gl.Rotatef(gl.Float(t.Theta), 0, 0, 1)
gl.Translatef(-xav, -yav, 0)
//Bind our texture to be drawn by id
gl.Color3f(1, 1, 1)
gl.Enable(gl.TEXTURE_2D)
gl.BindTexture(gl.TEXTURE_2D, t.TexId)
// Draw a rectangle with the texture stretched to the corners
gl.Begin(gl.QUADS)
// Stretch the texture to its 4 corners.
gl.TexCoord2d(0, 0)
gl.Vertex2f(t.X1, t.Y1)
gl.TexCoord2d(0, 1)
gl.Vertex2f(t.X1, t.Y2)
gl.TexCoord2d(1, 1)
gl.Vertex2f(t.X2, t.Y2)
gl.TexCoord2d(1, 0)
gl.Vertex2f(t.X2, t.Y1)
gl.End()
// Unbind the texture in case something else wants to draw
gl.Disable(gl.TEXTURE_2D)
// Reset the matrix
gl.LoadIdentity()
}
开发者ID:kelly-ry4n,项目名称:glGalaxy,代码行数:42,代码来源:drawtextures.go
注:本文中的github.com/chsc/gogl/gl21.Float函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论