本文整理汇总了Golang中github.com/go-gl/gl/v2/1/gl.Clear函数的典型用法代码示例。如果您正苦于以下问题:Golang Clear函数的具体用法?Golang Clear怎么用?Golang Clear使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Clear函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: drawBaseGame
func (ui *gameUI) drawBaseGame() {
gl.Clear(gl.COLOR_BUFFER_BIT)
ui.graphics.drawBackground()
// draw roads first
for _, p := range ui.game.GetPlayers() {
for _, r := range p.GetBuiltRoads() {
x, y := edgeToScreen(r.Position)
ui.graphics.drawRoadAt(x, y, r.Position, p.Color)
}
}
// draw buildings above the roads
for _, p := range ui.game.GetPlayers() {
for _, s := range p.GetBuiltSettlements() {
x, y := cornerToScreen(s.Position)
ui.graphics.drawSettlementAt(x, y, p.Color)
}
for _, c := range p.GetBuiltCities() {
x, y := cornerToScreen(c.Position)
ui.graphics.drawCityAt(x, y, p.Color)
}
}
ui.graphics.drawRobber(tileToScreen(ui.game.Robber.Position))
}
开发者ID:gonutz,项目名称:settlers,代码行数:25,代码来源:game_ui.go
示例2: drawSlide
func drawSlide() {
gl.Clear(gl.COLOR_BUFFER_BIT)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Translatef(0, 0, -3.0)
gl.Begin(gl.QUADS)
//top left
gl.TexCoord2f(0, 0)
gl.Vertex3f(-1, 1, 0)
//top right
gl.TexCoord2f(1, 0)
gl.Vertex3f(1, 1, 0)
//bottom right
gl.TexCoord2f(1, 1)
gl.Vertex3f(1, -1, 0)
//bottom left
gl.TexCoord2f(0, 1)
gl.Vertex3f(-1, -1, 0)
gl.End()
}
开发者ID:lordwelch,项目名称:PresentationApp,代码行数:27,代码来源:glfw.go
示例3: main
func main() {
err := glfw.Init()
if err != nil {
panic(err)
}
defer glfw.Terminate()
window, err := glfw.CreateWindow(640, 480, "Testing", nil, nil)
if err != nil {
panic(err)
}
window.MakeContextCurrent()
if err := gl.Init(); err != nil {
panic(err)
}
// int width, height
// glfw.GetFramebufferSize(window, &width, &height)
for !window.ShouldClose() {
// Do OpenGL stuff.
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.Color3f(1, 1, 0)
gl.Rectf(-0.75, 0.75, 0.75, -0.75)
gl.Color3f(1, 0, 1)
gl.Rectf(-0.5, 0.5, 0.5, -0.5)
window.SwapBuffers()
glfw.PollEvents()
}
}
开发者ID:broderickhyman,项目名称:GoStuff,代码行数:32,代码来源:hello.go
示例4: FillFramebuffer
func (c *Context) FillFramebuffer(r, g, b, a float64) error {
return c.runOnContextThread(func() error {
gl.ClearColor(float32(r), float32(g), float32(b), float32(a))
gl.Clear(gl.COLOR_BUFFER_BIT)
return nil
})
}
开发者ID:hajimehoshi,项目名称:ebiten,代码行数:7,代码来源:context_desktop.go
示例5: drawHud
func (ctx *DrawContext) drawHud(o *orrery.Orrery, frametime time.Duration) {
txt, size, err := ctx.createHudTexture(o, frametime)
if err != nil {
log.Fatalf(`can't create texture from text surface: %s`, err)
}
defer gl.DeleteTextures(1, &txt)
gl.MatrixMode(gl.PROJECTION)
gl.PushMatrix()
gl.LoadIdentity()
gl.Ortho(0.0, float64(ctx.width), float64(ctx.height), 0.0, -1.0, 1.0)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Clear(gl.DEPTH_BUFFER_BIT)
gl.BindTexture(gl.TEXTURE_2D, txt)
gl.Enable(gl.TEXTURE_2D)
defer gl.Disable(gl.TEXTURE_2D)
gl.Color3f(1, 1, 1)
gl.Begin(gl.QUADS)
gl.TexCoord2f(0, 0)
gl.Vertex2f(0.0, 0.0)
gl.TexCoord2f(1, 0)
gl.Vertex2f(float32(size[0]), 0.0)
gl.TexCoord2f(1, 1)
gl.Vertex2f(float32(size[0]), float32(size[1]))
gl.TexCoord2f(0, 1)
gl.Vertex2f(0.0, float32(size[1]))
gl.End()
gl.PopMatrix()
}
开发者ID:farhaven,项目名称:universe,代码行数:33,代码来源:drawing.go
示例6: draw
// OpenGL draw function
func draw() {
gl.Clear(gl.COLOR_BUFFER_BIT)
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.LoadIdentity()
gl.Begin(gl.LINES)
gl.Color3f(.2, .2, .2)
for i := range staticLines {
x := staticLines[i].GetAsSegment().A.X
y := staticLines[i].GetAsSegment().A.Y
gl.Vertex3f(float32(x), float32(y), 0)
x = staticLines[i].GetAsSegment().B.X
y = staticLines[i].GetAsSegment().B.Y
gl.Vertex3f(float32(x), float32(y), 0)
}
gl.End()
gl.Color4f(.3, .3, 1, .8)
// draw balls
for _, ball := range balls {
gl.PushMatrix()
pos := ball.Body.Position()
rot := ball.Body.Angle() * chipmunk.DegreeConst
gl.Translatef(float32(pos.X), float32(pos.Y), 0.0)
gl.Rotatef(float32(rot), 0, 0, 1)
drawCircle(float64(ballRadius), 60)
gl.PopMatrix()
}
}
开发者ID:TheZeroSlave,项目名称:chipmunk,代码行数:33,代码来源:bouncing_balls.go
示例7: main
func main() {
err := glfw.Init()
if err != nil {
panic(err)
}
defer glfw.Terminate()
fp, err := os.Open("example.tmx")
if err != nil {
panic(err)
}
m, err := tmx.NewMap(fp)
if err != nil {
panic(err)
}
var monitor *glfw.Monitor
window, err := glfw.CreateWindow(screenWidth, screenHeight, "Map Renderer", monitor, nil)
if err != nil {
panic(err)
}
window.MakeContextCurrent()
if err := gl.Init(); err != nil {
panic(err)
}
width, height := window.GetFramebufferSize()
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.ClearColor(1.0, 1.0, 1.0, 1.0)
gl.Viewport(0, 0, int32(width), int32(height))
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(0, float64(width), float64(height), 0, -1, 1)
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
canvas := newOpenGLCanvas(width, height, float32(width)/float32(screenWidth), float32(height)/float32(screenHeight))
renderer := tmx.NewRenderer(*m, canvas)
fps := 0
startTime := time.Now().UnixNano()
timer := tmx.CreateTimer()
timer.Start()
for !window.ShouldClose() {
elapsed := float64(timer.GetElapsedTime()) / (1000 * 1000)
renderer.Render(int64(math.Ceil(elapsed)))
fps++
if time.Now().UnixNano()-startTime > 1000*1000*1000 {
log.Println(fps)
startTime = time.Now().UnixNano()
fps = 0
}
window.SwapBuffers()
glfw.PollEvents()
timer.UpdateTime()
}
}
开发者ID:manyminds,项目名称:tmx,代码行数:58,代码来源:opengl.go
示例8: Step
func (d *Director) Step() {
gl.Clear(gl.COLOR_BUFFER_BIT)
timestamp := glfw.GetTime()
dt := timestamp - d.timestamp
d.timestamp = timestamp
if d.view != nil {
d.view.Update(timestamp, dt)
}
}
开发者ID:cherrybob,项目名称:nes,代码行数:9,代码来源:director.go
示例9: drawScene
func drawScene(w *glfw.Window) {
width, height := w.GetFramebufferSize()
ratio := float32(width) / float32(height)
var x1, x2, y1, y2 float32
if ratio > 1 {
x1, x2, y1, y2 = -ratio, ratio, -1, 1
} else {
x1, x2, y1, y2 = -1, 1, -1/ratio, 1/ratio
}
gl.Viewport(0, 0, int32(width), int32(height))
gl.Clear(gl.COLOR_BUFFER_BIT)
// Applies subsequent matrix operations to the projection matrix stack
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity() // replace the current matrix with the identity matrix
gl.Ortho(float64(x1), float64(x2), float64(y1), float64(y2), 1, -1) // multiply the current matrix with an orthographic matrix
// Applies subsequent matrix operations to the modelview matrix stack
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.LineWidth(1)
gl.Begin(gl.LINE) // delimit the vertices of a primitive or a group of like primitives
gl.Color3f(0, 0, 0) // set the current color
gl.Vertex3f(0, y1, 0)
gl.Vertex3f(0, y2, 0)
gl.Vertex3f(x1, 0, 0)
gl.Vertex3f(x2, 0, 0)
gl.End()
gl.Rotatef(float32(glfw.GetTime()*50), 0, 0, 1) // multiply the current matrix by a rotation matrix
s := float32(.95)
gl.Begin(gl.TRIANGLES)
gl.Color3f(1, 0, 0) // set the current color
gl.Vertex3f(0, s, 0) // specify a vertex
gl.Color3f(0, 1, 0)
gl.Vertex3f(s*.866, s*-0.5, 0)
gl.Color3f(0, 0, 1)
gl.Vertex3f(s*-.866, s*-0.5, 0)
gl.End()
gl.LineWidth(5)
gl.Begin(gl.LINE_LOOP)
for i := float64(0); i < 2*math.Pi; i += .05 {
r, g, b := hsb2rgb(float32(i/(2*math.Pi)), 1, 1)
gl.Color3f(r, g, b)
gl.Vertex3f(s*float32(math.Sin(i)), s*float32(math.Cos(i)), 0)
}
gl.End()
}
开发者ID:rdterner,项目名称:gl,代码行数:56,代码来源:demo.go
示例10: main
func main() {
runtime.LockOSThread()
if err := glfw.Init(); err != nil {
panic(err)
}
defer glfw.Terminate()
window, err := glfw.CreateWindow(800, 600, "fontstash example", nil, nil)
if err != nil {
panic(err)
}
window.MakeContextCurrent()
glfw.SwapInterval(1)
gl.Init()
data, err := ioutil.ReadFile(filepath.Join("..", "ClearSans-Regular.ttf"))
if err != nil {
panic(err)
}
gl.Enable(gl.TEXTURE_2D)
tmpBitmap := make([]byte, 512*512)
cdata, err, _, tmpBitmap := truetype.BakeFontBitmap(data, 0, 32, tmpBitmap, 512, 512, 32, 96)
var ftex uint32
gl.GenTextures(1, &ftex)
gl.BindTexture(gl.TEXTURE_2D, ftex)
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR)
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR)
gl.TexImage2D(gl.TEXTURE_2D, 0, gl.ALPHA, 512, 512, 0,
gl.ALPHA, gl.UNSIGNED_BYTE, unsafe.Pointer(&tmpBitmap[0]))
gl.ClearColor(0.3, 0.3, 0.32, 1.)
for !window.ShouldClose() {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(0, 800, 600, 0, 0, 1)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Disable(gl.DEPTH_TEST)
gl.Color4ub(255, 255, 255, 255)
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
my_print(100, 100, "The quick brown fox jumps over the fence", ftex, cdata)
window.SwapBuffers()
glfw.PollEvents()
}
}
开发者ID:shibukawa,项目名称:fontstash.go,代码行数:54,代码来源:truetype.go
示例11: draw
func draw() {
gl.Clear(gl.COLOR_BUFFER_BIT)
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.LoadIdentity()
//Transform screen to keep player in middle. Added intentation to make obvious the push matrix is like a block
gl.PushMatrix()
// gl.Translatef((1280/2)-float32(player.x), 0, 0.0)
// gl.Begin(gl.LINES)
// gl.Color3f(.2, .5, .2)
// for i := range staticLines {
// x := staticLines[i].GetAsSegment().A.X
// y := staticLines[i].GetAsSegment().A.Y
// gl.Vertex3f(float32(x), float32(y), 0)
// x = staticLines[i].GetAsSegment().B.X
// y = staticLines[i].GetAsSegment().B.Y
// gl.Vertex3f(float32(x), float32(y), 0)
// }
// gl.End()
gl.Color4f(player.color_r, player.color_g, player.color_b, player.color_a)
//Draw Player
gl.PushMatrix()
rot := player.rot
pos_x := player.x
pos_y := player.y
gl.Translatef(pos_x, pos_y, 0.0)
gl.Rotatef(float32(rot), 0, 0, 1)
drawCircle(float64(BALL_RADIUS), 20)
gl.PopMatrix()
//Draw the grapple
gl.PushMatrix()
gl.Translatef(player.hook.x_end, player.hook.y_end, 0.0)
drawCircle(float64(5), 5)
gl.PopMatrix()
//Grapple Line
gl.LineWidth(2.5)
gl.Color3f(1.0, 0.0, 0.0)
gl.Begin(gl.LINES)
gl.Vertex3f(player.x, player.y, 0.0)
gl.Vertex3f(player.hook.x_end, player.hook.y_end, 0)
gl.End()
//Second Pop
gl.PopMatrix()
}
开发者ID:jhautefeuille,项目名称:hellochipmunk,代码行数:54,代码来源:glfwtest.go
示例12: drawgl
func drawgl() {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.Begin(gl.TRIANGLES)
gl.Color3f(1.0, 0.0, 0.0)
gl.Vertex2f(0.5, 0.0)
gl.Color3f(0.0, 1.0, 0.0)
gl.Vertex2f(-0.5, -0.5)
gl.Color3f(0.0, 0.0, 1.0)
gl.Vertex2f(-0.5, 0.5)
gl.End()
}
开发者ID:emlai,项目名称:go-sdl2,代码行数:12,代码来源:opengl.go
示例13: Reset
func (state *State) Reset(window *glfw.Window) {
gl.ClearColor(1, 1, 1, 1)
gl.Clear(gl.COLOR_BUFFER_BIT)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Disable(gl.DEPTH)
gl.Enable(gl.FRAMEBUFFER_SRGB)
width, height := window.GetSize()
gl.Viewport(0, 0, int32(width), int32(height))
gl.Ortho(0, float64(width), float64(height), 0, 30, -30)
}
开发者ID:egonelbre,项目名称:spector,代码行数:13,代码来源:ui.go
示例14: render
func render(w *Window) {
for !w.GlWindow.ShouldClose() {
//Reset?
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
if w.DrawFunc != nil {
w.DrawFunc()
}
// Maintenance
w.GlWindow.SwapBuffers()
glfw.PollEvents()
}
}
开发者ID:XO-Lib,项目名称:GCXO,代码行数:14,代码来源:Window.go
示例15: draw
// OpenGL draw function
func draw() {
gl.Clear(gl.COLOR_BUFFER_BIT)
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.LoadIdentity()
player := game.Player
//Transform screen.
gl.PushMatrix()
gl.Translatef((1280/2)-float32((player.Body.Position().X)), 0, 0.0)
gl.Begin(gl.LINES)
gl.Color3f(.2, .5, .2)
for _, segment := range game.Level.GetChipmunkSegments() {
x := segment.GetAsSegment().A.X
y := segment.GetAsSegment().A.Y
gl.Vertex3f(float32(x), float32(y), 0)
x = segment.GetAsSegment().B.X
y = segment.GetAsSegment().B.Y
gl.Vertex3f(float32(x), float32(y), 0)
}
gl.End()
gl.Color4f(.9, .1, 1, .9)
// draw balls
for _, enemy := range game.Enemies {
gl.PushMatrix()
pos := enemy.Body.Position()
rot := enemy.Body.Angle() * game.DegreeConst
gl.Translatef(float32(pos.X), float32(pos.Y), 0.0)
gl.Rotatef(float32(rot), 0, 0, 1)
drawCircle(float64(enemy.Radius), 60)
gl.PopMatrix()
}
gl.Color4f(.3, .3, 1, .8)
//Draw Player
gl.PushMatrix()
pos := player.Body.Position()
rot := player.Body.Angle() * game.DegreeConst
gl.Translatef(float32(pos.X), float32(pos.Y), 0.0)
gl.Rotatef(float32(rot), 0, 0, 1)
drawCircle(float64(player.Radius), 60)
gl.PopMatrix()
gl.PopMatrix()
}
开发者ID:jhautefeuille,项目名称:hellochipmunk,代码行数:50,代码来源:main.go
示例16: onDisplay
func onDisplay(program uint32, coords uint32) {
gl.ClearColor(1.0, 1.0, 1.0, 1.0)
gl.Clear(gl.COLOR_BUFFER_BIT)
gl.UseProgram(program)
gl.EnableVertexAttribArray(coords)
triangleVertices := []float32{
0.0, 0.8,
-0.8, -0.8,
0.8, -0.8}
gl.VertexAttribPointer(coords, 2, gl.FLOAT, false, 0, gl.Ptr(triangleVertices))
gl.DrawArrays(gl.TRIANGLES, 0, 3)
gl.DisableVertexAttribArray(coords)
}
开发者ID:eklitzke,项目名称:go-opengl-tutorial,代码行数:15,代码来源:main.go
示例17: drawScene
func drawScene() {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.LineWidth(1)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Translatef(0, 0, 0.0)
//gl.Rotatef(rotationX, 1, 0, 0)
//gl.Rotatef(rotationY, 0, 1, 0)
//rotationX += 0.5
//rotationY += 0.5
//gl.BindTexture(gl.TEXTURE_2D, texture)
}
开发者ID:nightowlware,项目名称:gooey,代码行数:17,代码来源:gooey.go
示例18: draw
// general draw function
func draw() {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT) // CARGOCULT
gl.PushMatrix() // CARGOCULT
gl.Rotated(view_rotx, 1.0, 0.0, 0.0)
gl.Rotated(view_roty, 0.0, 1.0, 0.0)
gl.Rotated(view_rotz, 0.0, 0.0, 1.0)
gl.Translated(0.0, 0.0, view_z)
for i := range boxes {
gl.PushMatrix() // CARGOCULT
gl.CallList(boxes[i])
gl.PopMatrix() // CARGOCULT
}
gl.PopMatrix() // CARGOCULT
sdl.GL_SwapBuffers() // CARGOCULT
}
开发者ID:pietdaniel,项目名称:gl_maze,代码行数:19,代码来源:main.go
示例19: display
func display() {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.LineWidth(1)
gc := draw2dgl.NewGraphicContext(width, height)
gc.SetFontData(draw2d.FontData{
Name: "luxi",
Family: draw2d.FontFamilyMono,
Style: draw2d.FontStyleBold | draw2d.FontStyleItalic})
gc.BeginPath()
draw2dkit.RoundedRectangle(gc, 200, 200, 600, 600, 100, 100)
gc.SetFillColor(color.RGBA{0, 0, 0, 0xff})
gc.Fill()
gl.Flush() /* Single buffered, so needs a flush. */
}
开发者ID:maleck13,项目名称:jigsaws,代码行数:18,代码来源:helloworldgl.go
示例20: Render
func Render() {
gl.ClearColor(0, 0, 0, 1)
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.Color4f(1, 1, 1, 1)
gl.BindTexture(gl.TEXTURE_2D, game.Texture)
gl.PushMatrix()
gl.Translatef(20-float32(game.PlayerX), 15-float32(game.PlayerY), 0)
gl.Begin(gl.TRIANGLES)
for i := 0; i < game.Width; i++ {
for j := 0; j < game.Height; j++ {
renderTile(game.Tiles[(j*game.Width)+i], float32(i), float32(j))
}
}
// Player
gl.Color4f(1, 0, 0, 1)
renderTile(4, float32(game.PlayerX), float32(game.PlayerY))
gl.End()
gl.PopMatrix()
}
开发者ID:Geemili,项目名称:maze-rogue,代码行数:21,代码来源:maze-rogue.go
注:本文中的github.com/go-gl/gl/v2/1/gl.Clear函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论