本文整理匯總了Golang中github.com/banthar/gl.Clear函數的典型用法代碼示例。如果您正苦於以下問題:Golang Clear函數的具體用法?Golang Clear怎麽用?Golang Clear使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Clear函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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()
}
示例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)
}
示例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)
}
}
示例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()
}
示例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()
}
示例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()
}
}
}
示例7: onKey
func onKey(key, state int) {
switch key {
case glfw.KeyEsc:
running = state == 0
case 67: // 'c'
gl.Clear(gl.COLOR_BUFFER_BIT)
}
}
示例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()
}
示例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()
}
示例10: display
func display() {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
positionCamera()
gl.Begin(gl.QUADS)
drawTerrain()
gl.End()
gl.Flush()
}
示例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()
}
}
示例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. */
}
示例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()
}
示例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")
}
}
示例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()
}