本文整理匯總了Golang中github.com/banthar/gl.Begin函數的典型用法代碼示例。如果您正苦於以下問題:Golang Begin函數的具體用法?Golang Begin怎麽用?Golang Begin使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Begin函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Render
func (f frame) Render(w, h, d float64) {
// Draw a wireframe around the arena
gl.Color4ub(255, 255, 255, 31)
gl.LineWidth(2.0)
gl.Begin(gl.LINE_STRIP)
gl.Vertex3d(0, 0, 0)
gl.Vertex3d(w, 0, 0)
gl.Vertex3d(w, h, 0)
gl.Vertex3d(0, h, 0)
gl.Vertex3d(0, 0, 0)
gl.Vertex3d(0, 0, d)
gl.Vertex3d(0, h, d)
gl.Vertex3d(w, h, d)
gl.Vertex3d(w, 0, d)
gl.Vertex3d(0, 0, d)
gl.End()
gl.Begin(gl.LINES)
gl.Vertex3d(0, h, 0)
gl.Vertex3d(0, h, d)
gl.Vertex3d(w, 0, 0)
gl.Vertex3d(w, 0, d)
gl.Vertex3d(w, h, 0)
gl.Vertex3d(w, h, d)
gl.End()
// Render the page.
if f.renderer != nil {
f.renderer.Render(w, h, d)
}
}
示例2: drawShip
func drawShip(angle float32) {
gl.PushMatrix()
gl.Translatef(x, y, 0.0)
gl.Rotatef(angle, 0.0, 0.0, 1.0)
if thrust {
gl.Color3f(1.0, 0.0, 0.0)
gl.Begin(gl.LINE_STRIP)
gl.Vertex2f(-0.75, -0.5)
gl.Vertex2f(-1.75, 0)
gl.Vertex2f(-0.75, 0.5)
gl.End()
}
gl.Color3f(1.0, 1.0, 0.0)
gl.Begin(gl.LINE_LOOP)
gl.Vertex2f(2.0, 0.0)
gl.Vertex2f(-1.0, -1.0)
gl.Vertex2f(-0.5, 0.0)
gl.Vertex2f(-1.0, 1.0)
gl.Vertex2f(2.0, 0.0)
gl.End()
if shield {
gl.Color3f(0.1, 0.1, 1.0)
gl.Begin(gl.LINE_LOOP)
for rad := 0.0; rad < 12.0; rad += 1.0 {
gl.Vertex2f(
float32(2.3*math.Cos(2*float64(rad)/math.Pi)+0.2),
float32(2.0*math.Sin(2*float64(rad)/math.Pi)))
}
gl.End()
}
gl.PopMatrix()
}
示例3: DrawItemSlot
func (self *Inventory) DrawItemSlot(t int64, r Rect) {
gl.PushMatrix()
gl.LoadIdentity()
gl.Color4ub(16, 16, 16, 255)
gl.Begin(gl.QUADS)
gl.Vertex2d(r.x, r.y)
gl.Vertex2d(r.x+r.sizex, r.y)
gl.Vertex2d(r.x+r.sizex, r.y+r.sizey)
gl.Vertex2d(r.x, r.y+r.sizey)
gl.End()
gl.Color4ub(6, 6, 6, 255)
gl.Begin(gl.LINES)
gl.Vertex2d(r.x, r.y)
gl.Vertex2d(r.x+r.sizex, r.y)
gl.Vertex2d(r.x, r.y)
gl.Vertex2d(r.x, r.y+r.sizey)
gl.End()
gl.Color4ub(64, 64, 64, 255)
gl.Begin(gl.LINES)
gl.Vertex2d(r.x+r.sizex, r.y)
gl.Vertex2d(r.x+r.sizex, r.y+r.sizey)
gl.Vertex2d(r.x, r.y+r.sizey)
gl.Vertex2d(r.x+r.sizex, r.y+r.sizey)
gl.End()
gl.PopMatrix()
}
示例4: drawScene
func drawScene() {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.LoadIdentity()
gl.Translatef(-1.5, 0, -6)
gl.Rotatef(trisAngle, 0, 1, 0)
gl.Begin(gl.TRIANGLES)
gl.Color3f(1, 0, 0)
gl.Vertex3f(0, 1, 0)
gl.Color3f(0, 1, 0)
gl.Vertex3f(-1, -1, 0)
gl.Color3f(0, 0, 1)
gl.Vertex3f(1, -1, 0)
gl.End()
gl.LoadIdentity()
gl.Translatef(1.5, 0, -6)
gl.Rotatef(quadAngle, 1, 0, 0)
gl.Color3f(0.5, 0.5, 1.0)
gl.Begin(gl.QUADS)
gl.Vertex3f(-1, 1, 0)
gl.Vertex3f(1, 1, 0)
gl.Vertex3f(1, -1, 0)
gl.Vertex3f(-1, -1, 0)
gl.End()
trisAngle += 0.2
quadAngle -= 0.15
glfw.SwapBuffers()
}
示例5: DrawQuad
func DrawQuad(upperLeft, lowerRight vect.Vect, filled bool) {
if filled {
gl.Begin(gl.QUADS)
} else {
gl.Begin(gl.LINE_LOOP)
}
defer gl.End()
gl.Vertex2d(upperLeft.X, upperLeft.Y)
gl.Vertex2d(upperLeft.X, lowerRight.Y)
gl.Vertex2d(lowerRight.X, lowerRight.Y)
gl.Vertex2d(lowerRight.X, upperLeft.Y)
}
示例6: DrawPoly
func DrawPoly(vertices []vect.Vect, vertCount int, filled bool) {
if filled {
gl.Begin(gl.TRIANGLE_FAN)
gl.Vertex2d(vertices[0].X, vertices[0].Y)
} else {
gl.Begin(gl.LINE_LOOP)
}
defer gl.End()
for i := 0; i < vertCount; i++ {
v := vertices[i]
gl.Vertex2d(v.X, v.Y)
}
}
示例7: DrawCircle
func DrawCircle(pos vect.Vect, radius float64, filled bool) {
if filled {
gl.Begin(gl.TRIANGLE_FAN)
gl.Vertex2d(pos.X, pos.Y)
} else {
gl.Begin(gl.LINE_LOOP)
}
defer gl.End()
var d float64
for i := 0.0; i <= 360; i += circlestep {
d = deg2grad * i
gl.Vertex2d(pos.X+math.Cos(d)*radius, pos.Y+math.Sin(d)*radius)
}
}
示例8: drawGLScene
// Here goes our drawing code
func drawGLScene() {
// Clear the screen and depth buffer
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
// Move left 1.5 units and into the screen 6.0 units.
gl.LoadIdentity()
gl.Translatef(-1.5, 0.0, -6.0)
gl.Rotatef(float32(rtri), 0.0, 1.0, 0.0) // Rotate the triangle on the Y axis
gl.Begin(gl.TRIANGLES) // Draw triangles
gl.Color3f(1.0, 0.0, 0.0) // Set The Color To Red
gl.Vertex3f(0.0, 1.0, 0.0) // top
gl.Color3f(0.0, 1.0, 0.0) // Set The Color To Red
gl.Vertex3f(-1.0, -1.0, 0.0) // bottom left
gl.Color3f(0.0, 0.0, 1.0) // Set The Color To Red
gl.Vertex3f(1.0, -1.0, 0.0) // bottom right
gl.End() // finish drawing the triangle
// Move right 3 units
gl.LoadIdentity()
gl.Translatef(1.5, 0.0, -6.0)
gl.Color3f(0.5, 0.5, 1.0) // Set The Color To Blue One Time Only
gl.Rotatef(float32(rquad), 1.0, 0.0, 0.0) // rotate the quad on the X axis
gl.Begin(gl.QUADS) // draw quads
gl.Vertex3f(-1.0, 1.0, 0.0) // top left
gl.Vertex3f(1.0, 1.0, 0.0) // top right
gl.Vertex3f(1.0, -1.0, 0.0) // bottom right
gl.Vertex3f(-1.0, -1.0, 0.0) // bottom left
gl.End() // done drawing the quad
// Draw to the screen
sdl.GL_SwapBuffers()
rtri += 0.2 // Increase The Rotation Variable For The Triangle
rquad -= 0.15 // Decrease The Rotation Variable For The Quad
// Gather our frames per second
frames++
t := sdl.GetTicks()
if t-t0 >= 5000 {
seconds := (t - t0) / 1000.0
fps := frames / seconds
fmt.Println(frames, "frames in", seconds, "seconds =", fps, "FPS")
t0 = t
frames = 0
}
}
示例9: lineTo
func (pen *Pen) lineTo(p Point) {
gl.Enable(gl.BLEND)
gl.Enable(gl.POINT_SMOOTH)
gl.Enable(gl.LINE_SMOOTH)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
gl.Color4f(0.0, 0.0, 0.0, 0.1)
gl.Begin(gl.LINES)
for _, s := range pen.points {
if s.x == 0 && s.y == 0 {
continue
}
if p.distanceTo(s) < 20.0 {
gl.Vertex2i(int(p.x), int(p.y))
gl.Vertex2i(int(s.x), int(s.y))
}
}
gl.End()
pen.n = (pen.n + 1) % len(pen.points)
pen.points[pen.n] = p
pen.moveTo(p)
}
示例10: Draw
func (s *Sprite) Draw(x, y, angle, scale float32, blend bool) {
gl.Enable(gl.TEXTURE_2D)
gl.Disable(gl.COLOR_MATERIAL)
if blend {
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
gl.Enable(gl.BLEND)
} else {
gl.Disable(gl.BLEND)
gl.BlendFunc(gl.ONE, gl.ZERO)
}
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Translatef(x, y, 0)
gl.Rotatef(angle*360/(2*math.Pi), 0, 0, 1)
gl.Scalef(scale, scale, 1)
s.tex.Bind(gl.TEXTURE_2D)
gl.Begin(gl.QUADS)
gl.Color3f(1, 1, 1)
gl.TexCoord2d(0, 0)
gl.Vertex3f(-0.5*s.width, -0.5*s.height, 0)
gl.TexCoord2d(1, 0)
gl.Vertex3f(0.5*s.width, -0.5*s.height, 0)
gl.TexCoord2d(1, 1)
gl.Vertex3f(0.5*s.width, 0.5*s.height, 0)
gl.TexCoord2d(0, 1)
gl.Vertex3f(-0.5*s.width, 0.5*s.height, 0)
gl.End()
gl.Disable(gl.TEXTURE_2D)
gl.Disable(gl.BLEND)
}
示例11: lineTo
func (pen *Pen) lineTo(x, y int) {
gl.Enable(gl.BLEND)
gl.Enable(gl.POINT_SMOOTH)
gl.Enable(gl.LINE_SMOOTH)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
gl.Color4f(0.0, 0.0, 0.0, 0.1)
gl.Begin(gl.LINES)
var p [2]int
for i := range pen.points {
p = pen.points[i]
if p[0] == 0 && p[1] == 0 {
continue
}
if distanceTo(x, y, p[0], p[1]) < 10.0 {
gl.Vertex2i(x, y)
gl.Vertex2i(p[0], p[1])
}
}
gl.End()
pen.n = (pen.n + 1) % len(pen.points)
pen.points[pen.n][0] = x
pen.points[pen.n][1] = y
pen.moveTo(x, y)
}
示例12: drawLine
func drawLine(x1, y1, x2, y2 float64) {
gl.Begin(gl.LINES)
gl.Vertex2d(x1, y1)
gl.Vertex2d(x2, y2)
gl.End()
}
示例13: Draw
func (self *Picker) Draw(t int64) {
gl.MatrixMode(gl.MODELVIEW)
gl.PushMatrix()
gl.LoadIdentity()
gl.Disable(gl.DEPTH_TEST)
gl.Disable(gl.LIGHTING)
gl.Disable(gl.LIGHT0)
gl.Disable(gl.LIGHT1)
gl.Begin(gl.TRIANGLE_FAN)
gl.Color4ub(0, 0, 0, 128)
gl.Vertex2f(self.x, self.y)
for angle := float64(0); angle <= 2*math.Pi; angle += math.Pi / 2 / 10 {
gl.Vertex2f(self.x-float32(math.Sin(angle))*self.radius, self.y+float32(math.Cos(angle))*self.radius)
}
gl.End()
self.DrawItemHighlight(t, ThePlayer.currentAction)
self.DrawPlayerItems(t, true)
gl.PopMatrix()
}
示例14: Render
func (pp Points) Render() {
gl.Begin(gl.POINTS)
for _, p := range pp {
gl.Vertex2d(p.X, p.Y)
}
gl.End()
}
示例15: DrawLine
func DrawLine(start, end vect.Vect) {
gl.Begin(gl.LINES)
defer gl.End()
gl.Vertex2d(start.X, start.Y)
gl.Vertex2d(end.X, end.Y)
}