本文整理汇总了Golang中gl.End函数的典型用法代码示例。如果您正苦于以下问题:Golang End函数的具体用法?Golang End怎么用?Golang End使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了End函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: drawMap
func drawMap(cx, cy, zoom float64, triangles p2t.TriArray) {
for i := 0; i < len(triangles); i++ {
t := triangles[i]
a := t.Point[0]
b := t.Point[1]
c := t.Point[2]
//constrainedColor(t.constrained_edge[2])
gl.Begin(gl.LINES)
gl.Vertex2f(float32(a.X), float32(a.Y))
gl.Vertex2f(float32(b.X), float32(b.Y))
gl.End()
//constrainedColor(t.constrained_edge[0])
gl.Begin(gl.LINES)
gl.Vertex2f(float32(b.X), float32(b.Y))
gl.Vertex2f(float32(c.X), float32(c.Y))
gl.End()
//constrainedColor(t.constrained_edge[1])
gl.Begin(gl.LINES)
gl.Vertex2f(float32(c.X), float32(c.Y))
gl.Vertex2f(float32(a.X), float32(a.Y))
gl.End()
}
}
示例2: drawShip
func drawShip(angle gl.GLfloat) {
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(
gl.GLfloat(2.3*math.Cos(2*float64(rad)/math.Pi)+0.2),
gl.GLfloat(2.0*math.Sin(2*float64(rad)/math.Pi)))
}
gl.End()
}
gl.PopMatrix()
}
示例3: 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
}
}
示例4: 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)
}
示例5: DrawText2D
func (f *Font) DrawText2D(x int, y int, color [3]byte, scale float, txt string) (endw int, endh int) {
gl.LoadIdentity()
// gl.Translatef(0.0, 0.0, -2.0);
glEnable2D()
gl.Disable(gl.DEPTH_TEST)
texture, initial, intermediarya, intermediary, w, h := f.setupTextRendering(color, txt)
locX := gl.GLfloat(x)
locY := gl.GLfloat(y)
wi := gl.GLfloat(w) * gl.GLfloat(scale)
he := gl.GLfloat(h) * gl.GLfloat(scale)
/* Draw a quad at location */
gl.Begin(gl.QUADS)
/* Recall that the origin is in the lower-left corner
That is why the TexCoords specify different corners
than the Vertex coors seem to. */
gl.TexCoord2f(0.0, 1.0)
gl.Vertex2f(locX, locY)
gl.TexCoord2f(1.0, 1.0)
gl.Vertex2f(locX+wi, locY)
gl.TexCoord2f(1.0, 0.0)
gl.Vertex2f(locX+wi, locY+he)
gl.TexCoord2f(0.0, 0.0)
gl.Vertex2f(locX, locY+he)
gl.End()
endw, endh = f.teardownTextRendering(texture, initial, intermediarya, intermediary)
gl.Enable(gl.DEPTH_TEST)
glDisable2D()
return
}
示例6: main
func main() {
ret := glfw.Init()
print(ret)
ret = glfw.OpenWindow(300, 300, 0, 0, 0, 0, 0, 0, glfw.WINDOW)
print(ret)
if gl.Init() != 0 {
panic("glew error")
}
running := true
for running {
gl.Begin(gl.TRIANGLES)
gl.Vertex3f(0, 0, 0)
gl.Vertex3f(0, 1, 0)
gl.Vertex3f(1, 1, 0)
gl.End()
glfw.SwapBuffers()
running = glfw.GetKey(glfw.KEY_ESC) == 0 && glfw.GetWindowParam(glfw.OPENED) != 0
}
}
示例7: drawFrame
func drawFrame() {
gl.LoadIdentity()
gl.LineWidth(5.0)
gl.Enable(gl.POINT_SMOOTH)
gl.Enable(gl.LINE_SMOOTH)
gl.Color4f(gl.GLfloat(FrameColor[0]), gl.GLfloat(FrameColor[1]), gl.GLfloat(FrameColor[2]), 0.1)
m := PlayArea
t := 1.0 * m
b := -1.0 * m
r := 1.0 * m
l := -1.0 * m
gl.Begin(gl.LINE_STRIP)
zo := -5.0
gl.Vertex3f(gl.GLfloat(l), gl.GLfloat(t), gl.GLfloat(zo))
gl.Vertex3f(gl.GLfloat(r), gl.GLfloat(t), gl.GLfloat(zo))
gl.Vertex3f(gl.GLfloat(r), gl.GLfloat(b), gl.GLfloat(zo))
gl.Vertex3f(gl.GLfloat(l), gl.GLfloat(b), gl.GLfloat(zo))
gl.Vertex3f(gl.GLfloat(l), gl.GLfloat(t), gl.GLfloat(zo))
gl.End()
}
示例8: drawBullets
func drawBullets() {
gl.Begin(gl.POINTS)
gl.Color3f(1.0, 0.0, 1.0)
for i := 0; i < MAX_BULLETS; i++ {
if bullet[i].inuse {
gl.Vertex2f(bullet[i].x, bullet[i].y)
}
}
gl.End()
}
示例9: display
func display() {
gl.Clear(gl.COLOR_BUFFER_BIT)
gl.Begin(gl.TRIANGLES)
gl.Color3f(0.0, 0.0, 1.0) /* blue */
gl.Vertex2i(0, 0)
gl.Color3f(0.0, 1.0, 0.0) /* green */
gl.Vertex2i(200, 200)
gl.Color3f(1.0, 0.0, 0.0) /* red */
gl.Vertex2i(20, 200)
gl.End()
gl.Flush() /* Single buffered, so needs a flush. */
}
示例10: 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.Begin(gl.TRIANGLES) // Draw triangles
gl.Vertex3f(0.0, 1.0, 0.0) // top
gl.Vertex3f(-1.0, -1.0, 0.0) // bottom left
gl.Vertex3f(1.0, -1.0, 0.0) // bottom right
gl.End() // finish drawing the triangle
// Move right 3 units
gl.Translatef(3.0, 0.0, 0.0)
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()
// 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
}
}
示例11: drawBlock
func drawBlock(x, y int, color TetrisBlockColor) {
glx := gl.GLint(x)
gly := gl.GLint(y)
gl.Color3ub(color.R/2, color.G/2, color.B/2)
gl.Begin(gl.QUADS)
gl.Vertex2i(int(glx), int(gly))
gl.Vertex2i(int(glx+blockSize), int(gly))
gl.Vertex2i(int(glx+blockSize), int(gly+blockSize))
gl.Vertex2i(int(glx), int(gly+blockSize))
gl.Color3ub(color.R, color.G, color.B)
gl.Vertex2i(int(glx+smallBlockOffset), int(gly+smallBlockOffset))
gl.Vertex2i(int(glx+blockSize-smallBlockOffset), int(gly+smallBlockOffset))
gl.Vertex2i(int(glx+blockSize-smallBlockOffset), int(gly+blockSize-smallBlockOffset))
gl.Vertex2i(int(glx+smallBlockOffset), int(gly+blockSize-smallBlockOffset))
gl.End()
}
示例12: drawQuad
func drawQuad(x, y, w, h int, u, v, u2, v2 float32) {
gl.Begin(gl.QUADS)
gl.TexCoord2f(float32(u), float32(v))
gl.Vertex2i(int(x), int(y))
gl.TexCoord2f(float32(u2), float32(v))
gl.Vertex2i(int(x+w), int(y))
gl.TexCoord2f(float32(u2), float32(v2))
gl.Vertex2i(int(x+w), int(y+h))
gl.TexCoord2f(float32(u), float32(v2))
gl.Vertex2i(int(x), int(y+h))
gl.End()
}
示例13: drawQuad
func drawQuad(x, y, w, h int, u, v, u2, v2 float) {
gl.Begin(gl.QUADS)
gl.TexCoord2f(gl.GLfloat(u), gl.GLfloat(v))
gl.Vertex2i(gl.GLint(x), gl.GLint(y))
gl.TexCoord2f(gl.GLfloat(u2), gl.GLfloat(v))
gl.Vertex2i(gl.GLint(x+w), gl.GLint(y))
gl.TexCoord2f(gl.GLfloat(u2), gl.GLfloat(v2))
gl.Vertex2i(gl.GLint(x+w), gl.GLint(y+h))
gl.TexCoord2f(gl.GLfloat(u), gl.GLfloat(v2))
gl.Vertex2i(gl.GLint(x), gl.GLint(y+h))
gl.End()
}
示例14: drawGLScene
// Here goes our drawing code
func drawGLScene(sector Sector) {
xtrans := gl.GLfloat(-xpos)
ztrans := gl.GLfloat(-zpos)
ytrans := gl.GLfloat(-walkbias - 0.25)
scenroty := gl.GLfloat(360.0 - yrot)
// Clear the screen and depth buffer
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
// reset the view
gl.LoadIdentity()
// Rotate up and down to look up and down
gl.Rotatef(float32(lookupdown), 1.0, 0.0, 0.0)
// Rotate depending on direction player is facing
gl.Rotatef(float32(scenroty), 0.0, 1.0, 0.0)
// translate the scene based on player position
gl.Translatef(float32(xtrans), float32(ytrans), float32(ztrans))
gl.BindTexture(gl.TEXTURE_2D, uint(textures[filter]))
for _, vertices := range sector {
gl.Begin(gl.TRIANGLES)
for _, triangle := range *vertices {
gl.Normal3f(0.0, 0.0, 1.0)
gl.TexCoord2f(float32(triangle.u), float32(triangle.v))
gl.Vertex3f(float32(triangle.x), float32(triangle.y), float32(triangle.z))
}
gl.End()
}
// Draw to the screen
sdl.GL_SwapBuffers()
// 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
}
}
示例15: drawSelection
func drawSelection(p1, p2 Point) {
min, max := minMaxPoints(p1, p2)
gl.Color3ub(255, 0, 0)
gl.Begin(gl.LINES)
gl.Vertex2i(int(min.X), int(min.Y))
gl.Vertex2i(int(max.X), int(min.Y))
gl.Vertex2i(int(min.X), int(min.Y))
gl.Vertex2i(int(min.X), int(max.Y))
gl.Vertex2i(int(max.X), int(max.Y))
gl.Vertex2i(int(max.X), int(min.Y))
gl.Vertex2i(int(max.X), int(max.Y))
gl.Vertex2i(int(min.X), int(max.Y))
gl.End()
gl.Color3ub(255, 255, 255)
}