本文整理汇总了Golang中github.com/banthar/gl.Clear函数的典型用法代码示例。如果您正苦于以下问题:Golang Clear函数的具体用法?Golang Clear怎么用?Golang Clear使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Clear函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: 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()
}
开发者ID:sycoso,项目名称:glfw,代码行数:33,代码来源:main.go
示例2: initScreen
func initScreen() {
sdl.Init(sdl.INIT_VIDEO)
const (
resx int = 640
resy int = 480
)
var (
screen = sdl.SetVideoMode(resx, resy, 16, sdl.OPENGL)
)
if screen == nil {
sdl.Quit()
panic("Couldn't set GL video mode: " + sdl.GetError() + "\n")
}
if gl.Init() != 0 {
panic("gl error")
}
gl.MatrixMode(gl.PROJECTION)
//gl.MatrixMode(gl.MODELVIEW)
gl.Viewport(0, 0, int(screen.W), int(screen.H))
gl.LoadIdentity()
gl.Ortho(0, float64(screen.W), float64(screen.H), 0, -1.0, 1.0)
//gl.DepthRange(-1, 1)
gl.ClearColor(0, 0, 0, 0)
gl.Clear(gl.COLOR_BUFFER_BIT)
}
开发者ID:charlieb,项目名称:gostrange,代码行数:30,代码来源:main.go
示例3: Render
// Render draws the contents of the window, but no more than 30
// times per second.
func (w *Window) Render() {
// Don't render more than 30 times per second.
t := time.Now()
if time.Since(w.lastRender).Seconds() < 1.0/30.0 {
return
}
w.lastRender = t
// Retrieve the view width and height, in pixels.
params := make([]int32, 4)
gl.GetIntegerv(gl.VIEWPORT, params)
// Infer the rendering volume from the viewport size, so the
// the rendering code can assume that the width of a pixel is
// ~1.0. This is important when rendering text. This must
// match the gl.Frustum configuration.
width := float64(params[2])
height := float64(params[3])
depth := (width + height) / 2
// Redraw the window, but not too often.
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
w.renderer.Render(width, height, depth)
glfw.SwapBuffers()
// Exit if the user presses escape or the window was closed.
if glfw.Key(glfw.KeyEsc) != 0 || glfw.WindowParam(glfw.Opened) == 0 {
os.Exit(0)
}
}
开发者ID:glenn-brown,项目名称:vu,代码行数:32,代码来源:window.go
示例4: Draw
func Draw() {
gl.Clear(gl.COLOR_BUFFER_BIT)
gl.PushMatrix()
defer gl.PopMatrix()
gl.Color4f(0, 1, 0, .5)
DrawCircle(vect.Vect{ScreenSize.X / 2, ScreenSize.Y / 2}, ScreenSize.Y/2.0-5.0, false)
if Settings.Paused {
gl.Color3f(1, 1, 1)
RenderFontAt("Paused", 20, 30)
}
//draw collision objects
gl.PushMatrix()
gl.Translated(ScreenSize.X/2, ScreenSize.Y/2, 0)
gl.Scaled(Settings.Scale, Settings.Scale, 1)
DrawDebugData(space)
gl.PopMatrix()
}
开发者ID:githubnemo,项目名称:mater,代码行数:25,代码来源:render.go
示例5: display
func display() {
gl.Clear(gl.COLOR_BUFFER_BIT)
bitmap_output(40, 35, "This is written in a GLUT bitmap font.", glut.BITMAP_TIMES_ROMAN_24)
bitmap_output(30, 210, "More bitmap text is a fixed 9 by 15 font.", glut.BITMAP_9_BY_15)
bitmap_output(70, 240, " Helvetica is yet another bitmap font.", glut.BITMAP_HELVETICA_18)
gl.MatrixMode(gl.PROJECTION)
gl.PushMatrix()
gl.LoadIdentity()
glu.Perspective(40.0, 1.0, 0.1, 20.0)
gl.MatrixMode(gl.MODELVIEW)
gl.PushMatrix()
glu.LookAt(0.0, 0.0, 4.0, /* eye is at (0,0,30) */
0.0, 0.0, 0.0, /* center is at (0,0,0) */
0.0, 1.0, 0.0) /* up is in postivie Y direction */
gl.PushMatrix()
gl.Translatef(0, 0, -4)
gl.Rotatef(50, 0, 1, 0)
stroke_output(-2.5, 1.1, " This is written in a", glut.STROKE_ROMAN)
stroke_output(-2.5, 0, " GLUT stroke font.", glut.STROKE_ROMAN)
stroke_output(-2.5, -1.1, "using 3D perspective.", glut.STROKE_ROMAN)
gl.PopMatrix()
gl.MatrixMode(gl.MODELVIEW)
gl.PopMatrix()
gl.MatrixMode(gl.PROJECTION)
gl.PopMatrix()
gl.MatrixMode(gl.MODELVIEW)
gl.Flush()
}
开发者ID:tmc,项目名称:glut,代码行数:29,代码来源:fontdemo.go
示例6: main
func main() {
glfw.Init()
defer glfw.Terminate()
glfw.OpenWindow(640, 480, 8, 8, 8, 8, 0, 0, glfw.Windowed)
defer glfw.CloseWindow()
glfw.SetWindowTitle("Tile test")
glfw.Enable(glfw.StickyKeys)
glfw.SetSwapInterval(1)
glfw.SetKeyCallback(inputCallback)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(0, GridWidth, GridHeight, 0, -1, 1)
gl.MatrixMode(gl.MODELVIEW)
gl.Disable(gl.DEPTH_TEST)
gl.Enable(gl.TEXTURE_2D)
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
gl.ClearColor(0.0, 0.0, 0.0, 1.0)
initResources()
initWorld()
for Running {
if (time.Since(DT).Nanoseconds() / 1000000) > 15 { //don't loop faster than every 15ms
DT = time.Now()
gl.Clear(gl.COLOR_BUFFER_BIT)
player.update()
renderScene()
glfw.SwapBuffers()
}
}
}
开发者ID:remirisque,项目名称:miniworld,代码行数:35,代码来源:main.go
示例7: onKey
func onKey(key, state int) {
switch key {
case glfw.KeyEsc:
running = state == 0
case 67: // 'c'
gl.Clear(gl.COLOR_BUFFER_BIT)
}
}
开发者ID:sycoso,项目名称:glfw,代码行数:8,代码来源:main.go
示例8: drawScene
func drawScene() {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Color3f(1, 1, 1)
drawShapes(space)
glfw.SwapBuffers()
}
开发者ID:ftrvxmtrx,项目名称:gochipmunk,代码行数:10,代码来源:main.go
示例9: onResize
func onResize(w, h int) {
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Viewport(0, 0, w, h)
gl.Ortho(0, float64(w), float64(h), 0, -1.0, 1.0)
gl.ClearColor(1, 1, 1, 0)
gl.Clear(gl.COLOR_BUFFER_BIT)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
}
开发者ID:sycoso,项目名称:glfw,代码行数:10,代码来源:main.go
示例10: display
func display() {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
positionCamera()
gl.Begin(gl.QUADS)
drawTerrain()
gl.End()
gl.Flush()
}
开发者ID:Nightgunner5,项目名称:mmgo,代码行数:11,代码来源:driver.go
示例11: main
func main() {
var err error
if err = glfw.Init(); err != nil {
fmt.Fprintf(os.Stderr, "[e] %v\n", err)
return
}
defer glfw.Terminate()
// Open window with FSAA samples (if possible).
glfw.OpenWindowHint(glfw.FsaaSamples, 4)
if err = glfw.OpenWindow(400, 400, 0, 0, 0, 0, 0, 0, glfw.Windowed); err != nil {
fmt.Fprintf(os.Stderr, "[e] %v\n", err)
return
}
defer glfw.CloseWindow()
glfw.SetWindowTitle("Aliasing Detector")
glfw.SetSwapInterval(1)
if samples := glfw.WindowParam(glfw.FsaaSamples); samples != 0 {
fmt.Fprintf(os.Stdout, "Context reports FSAA is supported with %d samples\n", samples)
} else {
fmt.Fprintf(os.Stdout, "Context reports FSAA is unsupported\n")
}
gl.MatrixMode(gl.PROJECTION)
glu.Perspective(0, 1, 0, 1)
for glfw.WindowParam(glfw.Opened) == 1 {
time := float32(glfw.Time())
gl.Clear(gl.COLOR_BUFFER_BIT)
gl.LoadIdentity()
gl.Translatef(0.5, 0, 0)
gl.Rotatef(time, 0, 0, 1)
gl.Enable(GL_MULTISAMPLE_ARB)
gl.Color3f(1, 1, 1)
gl.Rectf(-0.25, -0.25, 0.25, 0.25)
gl.LoadIdentity()
gl.Translatef(-0.5, 0, 0)
gl.Rotatef(time, 0, 0, 1)
gl.Disable(GL_MULTISAMPLE_ARB)
gl.Color3f(1, 1, 1)
gl.Rectf(-0.25, -0.25, 0.25, 0.25)
glfw.SwapBuffers()
}
}
开发者ID:sycoso,项目名称:glfw,代码行数:54,代码来源:main.go
示例12: 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. */
}
开发者ID:tmc,项目名称:glut,代码行数:12,代码来源:simple.go
示例13: main
func main() {
sdl.Init(sdl.INIT_VIDEO)
var screen = sdl.SetVideoMode(640, 480, 32, sdl.OPENGL)
if screen == nil {
panic("sdl error")
}
if gl.Init() != 0 {
panic("gl error")
}
pen := Pen{}
gl.MatrixMode(gl.PROJECTION)
gl.Viewport(0, 0, int(screen.W), int(screen.H))
gl.LoadIdentity()
gl.Ortho(0, float64(screen.W), float64(screen.H), 0, -1.0, 1.0)
gl.ClearColor(1, 1, 1, 0)
gl.Clear(gl.COLOR_BUFFER_BIT)
var running = true
for running {
for e := sdl.PollEvent(); e != nil; e = sdl.PollEvent() {
switch ev := e.(type) {
case *sdl.QuitEvent:
running = false
case *sdl.KeyboardEvent:
if ev.Keysym.Sym == sdl.K_ESCAPE {
running = false
}
case *sdl.MouseMotionEvent:
if ev.State != 0 {
pen.lineTo(Point{int(ev.X), int(ev.Y)})
} else {
pen.moveTo(Point{int(ev.X), int(ev.Y)})
}
}
}
sdl.GL_SwapBuffers()
sdl.Delay(25)
}
sdl.Quit()
}
开发者ID:nkostelnik,项目名称:gl,代码行数:53,代码来源:draw.go
示例14: draw
func draw() {
t := float32(sdl.GetTicks()) / 500.0
time := prg.GetUniformLocation("time")
time.Uniform1f(t)
gl.Clear(gl.COLOR_BUFFER_BIT)
gl.DrawArrays(gl.TRIANGLE_STRIP, 0, 4)
if gl.GetError() != gl.NO_ERROR {
panic("draw error")
}
}
开发者ID:shogg,项目名称:gltoy,代码行数:13,代码来源:gltoy.go
示例15: general_render
func general_render(s *list.List, c *camera) {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.PushMatrix()
//gl.Translatef(float32(c.X), float32(c.Y), float32(c.Z))
glu.LookAt(c.pos.X, c.pos.Y, c.pos.Z, c.front.X, c.front.Y, c.front.Z, c.top.X, c.top.Y, c.top.Z)
for e := s.Front(); e != nil; e = e.Next() {
gl.PushMatrix()
v := e.Value.(*sprite)
v.render()
gl.PopMatrix()
}
gl.PopMatrix()
}
开发者ID:esnowkropla,项目名称:dep,代码行数:14,代码来源:render.go
示例16: loop
func loop() {
e := initTriangleShaders()
if e != nil {
log.Fatalln(e.Error())
}
for esc {
gl.ClearColor(0.0, 0.0, 0.0, 0.0)
gl.Clear(gl.COLOR_BUFFER_BIT)
drawTriangle()
glfw.SwapBuffers()
timeSince()
}
}
开发者ID:simonz05,项目名称:draw,代码行数:15,代码来源:draw.go
示例17: 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
}
}
开发者ID:navneet1v,项目名称:opengl-go-tutorials,代码行数:49,代码来源:lesson04.go
示例18: Draw
// Render stuff
func Draw() {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.LoadIdentity()
gl.Translatef(-1.5, 0, -6)
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()
glfw.SwapBuffers()
}
开发者ID:andrebq,项目名称:tinygl,代码行数:17,代码来源:triangle.go
示例19: drawScene
func drawScene() {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.LoadIdentity()
gl.Translatef(0, 0, -20+globalState.MousePos.Z*globalState.speed)
gl.Rotatef(globalState.Rot.X, 1, 0, 0)
gl.Rotatef(globalState.Rot.Y, 0, 1, 0)
gl.Rotatef(globalState.Rot.Z, 0, 0, 1)
if globalState.speed != 1 {
gl.Scalef(globalState.speed, globalState.speed, globalState.speed)
}
gl.RenderMode(gl.RENDER)
gl.Begin(gl.QUADS)
for i, _ := range mesh.Faces {
if colors, ok := faceColor[i]; ok {
gl.Color3f(colors[0], colors[1], colors[2])
} else {
faceColor[i] = make([]float32, 3)
faceColor[i][0] = rand.Float32()
faceColor[i][1] = rand.Float32()
faceColor[i][2] = rand.Float32()
gl.Color3f(faceColor[i][0], faceColor[i][1], faceColor[i][2])
}
face := &mesh.Faces[i]
for j, _ := range face.Vertices {
var v *wfobj.Vertex
if len(face.Normals) > 0 {
v = &face.Normals[j]
gl.Normal3f(v.X, v.Y, v.Z)
}
v = &face.Vertices[j]
gl.Vertex3f(v.X, v.Y, v.Z)
}
}
gl.End()
gl.Finish()
gl.Flush()
sdl.GL_SwapBuffers()
}
开发者ID:andrebq,项目名称:wfobj,代码行数:46,代码来源:main.go
示例20: 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
}
}
开发者ID:navneet1v,项目名称:opengl-go-tutorials,代码行数:46,代码来源:lesson10.go
注:本文中的github.com/banthar/gl.Clear函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论