本文整理汇总了Golang中gl.ClearColor函数的典型用法代码示例。如果您正苦于以下问题:Golang ClearColor函数的具体用法?Golang ClearColor怎么用?Golang ClearColor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ClearColor函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: display
func display() {
// Clear the background as white
gl.ClearColor(1.0, 1.0, 1.0, 1.0)
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
// Use the GLSL program
program.Use()
uniformTexture.Uniform1i(0)
attributeCoord3d.EnableArray()
vboCubeVertices.Bind(gl.ARRAY_BUFFER)
attributeCoord3d.AttribPointerOffset(3, gl.FLOAT, false, 0, 0)
texture.Bind(gl.TEXTURE_2D)
attributeTexCoord.EnableArray()
vboCubeTexCoords.Bind(gl.ARRAY_BUFFER)
attributeTexCoord.AttribPointerOffset(2, gl.FLOAT, false, 0, 0)
iboCubeElements.Bind(gl.ELEMENT_ARRAY_BUFFER)
//size := []int32{0}
//gl.GetBufferParameteriv(gl.ELEMENT_ARRAY_BUFFER, gl.BUFFER_SIZE, size)
gl.DrawElementsOffset(gl.TRIANGLES, len(cubeElements), gl.UNSIGNED_SHORT, 0)
attributeCoord3d.DisableArray()
attributeTexCoord.DisableArray()
// Display the result
glfw.SwapBuffers()
}
示例2: OnSetup
func (cmd *ChainReaction) OnSetup() {
gl.ClearColor(0.3, 0.3, 0.3, 1.0)
ls := make([]level, 20)
i := 0
ls[i] = level{5, 1}
i++
ls[i] = level{10, 5}
i++
ls[i] = level{18, 10}
i++
ls[i] = level{25, 21}
i++
ls[i] = level{30, 27}
i++
ls[i] = level{37, 32}
i++
ls[i] = level{61, 61}
i++
cmd.Levels = ls[0:i]
cmd.ActiveLevel = 0
cmd.Triggers = make([]trigger, 0, 100)
cmd.UIFont = NewFont("./Test.ttf", 32)
cmd.SpawnLevel()
}
示例3: initGL
func initGL() {
gl.ShadeModel(gl.SMOOTH)
gl.ClearColor(0, 0, 0, 0)
gl.ClearDepth(1)
gl.Enable(gl.DEPTH_TEST)
gl.DepthFunc(gl.LEQUAL)
gl.Hint(gl.PERSPECTIVE_CORRECTION_HINT, gl.NICEST)
}
示例4: 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("glew error")
}
pen := Pen{}
gl.MatrixMode(gl.PROJECTION)
gl.Viewport(0, 0, gl.GLsizei(screen.W), gl.GLsizei(screen.H))
gl.LoadIdentity()
gl.Ortho(0, gl.GLdouble(screen.W), gl.GLdouble(screen.H), 0, -1.0, 1.0)
gl.ClearColor(1, 1, 1, 0)
gl.Clear(gl.COLOR_BUFFER_BIT)
var running = true
for running {
e := &sdl.Event{}
for e.Poll() {
switch e.Type {
case sdl.QUIT:
running = false
break
case sdl.KEYDOWN:
running = false
break
case sdl.MOUSEMOTION:
me := e.MouseMotion()
if me.State != 0 {
pen.lineTo(Point{int(me.X), int(me.Y)})
} else {
pen.moveTo(Point{int(me.X), int(me.Y)})
}
break
}
}
sdl.GL_SwapBuffers()
sdl.Delay(25)
}
sdl.Quit()
}
示例5: initGL
// general OpenGL initialization
func initGL() {
LoadGLTexture("data/star.bmp")
gl.Enable(gl.TEXTURE_2D)
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE)
gl.ShadeModel(gl.SMOOTH)
gl.ClearColor(0.0, 0.0, 0.0, 0.5)
gl.ClearDepth(1.0)
gl.Hint(gl.PERSPECTIVE_CORRECTION_HINT, gl.NICEST)
}
示例6: main
func main() {
glut.Init()
glut.InitDisplayMode(glut.SINGLE | glut.RGB)
glut.InitWindowSize(465, 250)
glut.CreateWindow("GLUT bitmap & stroke font example")
gl.ClearColor(1.0, 1.0, 1.0, 1.0)
gl.Color3f(0, 0, 0)
gl.LineWidth(3.0)
glut.DisplayFunc(display)
glut.ReshapeFunc(reshape)
glut.MainLoop()
}
示例7: 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()
}
示例8: init_
func init_() {
//pos := []float64{5.0, 5.0, 10.0, 0.0}
colors := map[string][]float32{
"0": {0.7, 0.7, 0.7, 1.0},
"1": {1.0, 0.0, 0.0, 1.0},
"2": {1.0, 0.6, 0.0, 1.0},
"3": {1.0, 1.0, 0.0, 1.0},
"4": {0.0, 1.0, 0.0, 1.0},
"5": {0.0, 0.0, 1.0, 1.0},
"6": {0.0, 0.6, 1.0, 1.0},
"7": {1.0, 0.0, 1.0, 1.0},
"8": {1.0, 1.0, 1.0, 1.0},
"9": {0.3, 0.3, 0.3, 1.0},
}
fetchChunks(2, 2)
gl.ShadeModel(gl.SMOOTH)
gl.ClearColor(0.2, 0.2, 0.6, 0.0)
gl.ClearDepth(1.0)
gl.Enable(gl.DEPTH_TEST)
gl.DepthFunc(gl.LEQUAL)
gl.Enable(gl.COLOR_MATERIAL)
gl.Enable(gl.CULL_FACE)
gl.Hint(gl.PERSPECTIVE_CORRECTION_HINT, gl.NICEST)
gl.Hint(gl.LINE_SMOOTH_HINT, gl.NICEST)
gl.Lightfv(gl.LIGHT0, gl.AMBIENT, lightAmbient)
gl.Lightfv(gl.LIGHT0, gl.DIFFUSE, lightDiffuse)
gl.Lightfv(gl.LIGHT0, gl.POSITION, lightPosition)
gl.Enable(gl.LIGHT0)
gl.Enable(gl.LIGHTING)
for name, color := range colors {
/* make a cube */
cubes[name] = gl.GenLists(1)
gl.NewList(cubes[name], gl.COMPILE)
cube(color)
gl.EndList()
}
if *printInfo {
print("GL_RENDERER = ", gl.GetString(gl.RENDERER), "\n")
print("GL_VERSION = ", gl.GetString(gl.VERSION), "\n")
print("GL_VENDOR = ", gl.GetString(gl.VENDOR), "\n")
print("GL_EXTENSIONS = ", gl.GetString(gl.EXTENSIONS), "\n")
}
}
示例9: SetupVideo
func SetupVideo() {
if sdl.Init(sdl.INIT_VIDEO) < 0 {
panic("Couldn't initialize sdl")
}
w := WinW
h := WinH
var screen = sdl.SetVideoMode(w, h, 32, SDL_FLAGS)
// var screen = sdl.SetVideoMode(w, h, 32, sdl.OPENGLBLIT | sdl.DOUBLEBUF | sdl.HWSURFACE)
// var screen = sdl.SetVideoMode(w, h, 32, sdl.OPENGL)
if screen == nil {
panic("sdl error")
}
if ttf.Init() != 0 {
panic("ttf init error")
}
if gl.Init() != 0 {
panic("Couldn't init gl")
}
ResizeWindow(screen.W, screen.H)
gl.ClearColor(0, 0, 0, 0)
// gl.ClearColor(1, 1, 1, 0)
gl.ClearDepth(1.0)
gl.DepthFunc(gl.LEQUAL)
gl.Enable(gl.DEPTH_TEST)
gl.ShadeModel(gl.SMOOTH)
gl.Hint(gl.PERSPECTIVE_CORRECTION_HINT, gl.NICEST)
/*
if gl.Init() != 0 {
panic("glew error")
}
*/
// gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT )
// gl.Clear(gl.COLOR_BUFFER_BIT)
// initGL
// gl.Ortho(0, gl.GLdouble(screen.W), gl.GLdouble(screen.H), 0, -1.0, 1.0)
}
示例10: initGL
// general OpenGL initialization
func initGL() {
gl.Enable(gl.TEXTURE_2D)
gl.ShadeModel(gl.SMOOTH)
gl.ClearColor(0.0, 0.0, 0.0, 0.5)
gl.ClearDepth(1.0)
gl.Enable(gl.DEPTH_TEST)
gl.DepthFunc(gl.LEQUAL)
gl.Hint(gl.PERSPECTIVE_CORRECTION_HINT, gl.NICEST)
// Setup the light
gl.Lightfv(gl.LIGHT1, gl.AMBIENT, lightAmbient[:]) // ambient lighting
gl.Lightfv(gl.LIGHT1, gl.DIFFUSE, lightDiffuse[:]) // make it diffuse
gl.Lightfv(gl.LIGHT1, gl.POSITION, lightPosition[:]) // and place it
gl.Enable(gl.LIGHT1) // and finally turn it on.
gl.Color4f(1.0, 1.0, 1.0, 0.5) // Full Brightness, 50% Alpha ( NEW )
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE) // Blending Function For Translucency Based On Source Alpha Value ( NEW )
}
示例11: initGL
// general OpenGL initialization
func initGL() {
LoadGLTextures("data/mud.bmp")
gl.Enable(gl.TEXTURE_2D)
gl.ShadeModel(gl.SMOOTH)
gl.ClearColor(0.0, 0.0, 0.0, 0.0)
gl.ClearDepth(1.0)
gl.Enable(gl.DEPTH_TEST)
gl.DepthFunc(gl.LEQUAL)
gl.Hint(gl.PERSPECTIVE_CORRECTION_HINT, gl.NICEST)
gl.Lightfv(gl.LIGHT1, gl.AMBIENT, lightAmbient[:])
gl.Lightfv(gl.LIGHT1, gl.DIFFUSE, lightDiffuse[:])
gl.Lightfv(gl.LIGHT1, gl.POSITION, lightPosition[:])
gl.Enable(gl.LIGHT1)
gl.Color4f(1.0, 1.0, 1.0, 0.5)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE)
}
示例12: reshape
func reshape(w, h int) {
/* Because Gil specified "screen coordinates" (presumably with an
upper-left origin), this short bit of code sets up the coordinate
system to correspond to actual window coodrinates. This code
wouldn't be required if you chose a (more typical in 3D) abstract
coordinate system. */
gl.ClearColor(1, 1, 1, 1)
//fmt.Println(gl.GetString(gl.EXTENSIONS))
gl.Viewport(0, 0, w, h) /* Establish viewing area to cover entire window. */
gl.MatrixMode(gl.PROJECTION) /* Start modifying the projection matrix. */
gl.LoadIdentity() /* Reset project matrix. */
gl.Ortho(0, float64(w), 0, float64(h), -1, 1) /* Map abstract coords directly to window coords. */
gl.Scalef(1, -1, 1) /* Invert Y axis so increasing Y goes down. */
gl.Translatef(0, float32(-h), 0) /* Shift origin up to upper-left corner. */
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
gl.Disable(gl.DEPTH_TEST)
width, height = w, h
}
示例13: initGL
// general OpenGL initialization
func initGL() {
// enable smooth shading
gl.ShadeModel(gl.SMOOTH)
// Set the background to black
gl.ClearColor(0.0, 0.0, 0.0, 0.0)
// Depth buffer setup
gl.ClearDepth(1.0)
// Enable depth testing
gl.Enable(gl.DEPTH_TEST)
// The type of test
gl.DepthFunc(gl.LEQUAL)
// Nicest perspective correction
gl.Hint(gl.PERSPECTIVE_CORRECTION_HINT, gl.NICEST)
}
示例14: initGL
// general OpenGL initialization
func initGL() {
gl.Enable(gl.TEXTURE_2D)
gl.ShadeModel(gl.SMOOTH)
gl.ClearColor(0.0, 0.0, 0.0, 0.5)
gl.ClearDepth(1.0)
gl.Enable(gl.DEPTH_TEST)
gl.DepthFunc(gl.LEQUAL)
gl.Hint(gl.PERSPECTIVE_CORRECTION_HINT, gl.NICEST)
// Setup the light
gl.Lightfv(gl.LIGHT1, gl.AMBIENT, lightAmbient1[:]) // ambient lighting
gl.Lightfv(gl.LIGHT1, gl.DIFFUSE, lightDiffuse1[:]) // make it diffuse
gl.Lightfv(gl.LIGHT1, gl.POSITION, lightPosition1[:]) // and place it
gl.Enable(gl.LIGHT1) // and finally turn it on.
gl.Lightfv(gl.LIGHT2, gl.AMBIENT, lightAmbient2[:]) // ambient lighting
gl.Lightfv(gl.LIGHT2, gl.DIFFUSE, lightDiffuse2[:]) // make it diffuse
gl.Lightfv(gl.LIGHT2, gl.POSITION, lightPosition2[:]) // and place it
gl.Enable(gl.LIGHT2) // and finally turn it on.
}
示例15: main
func main() {
runtime.LockOSThread()
flag.Parse()
buildPalette()
sdl.Init(sdl.INIT_VIDEO)
defer sdl.Quit()
sdl.GL_SetAttribute(sdl.GL_SWAP_CONTROL, 1)
if sdl.SetVideoMode(512, 512, 32, sdl.OPENGL) == nil {
panic("sdl error")
}
if gl.Init() != 0 {
panic("gl error")
}
sdl.WM_SetCaption("Gomandel", "Gomandel")
gl.Enable(gl.TEXTURE_2D)
gl.Viewport(0, 0, 512, 512)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(0, 512, 512, 0, -1, 1)
gl.ClearColor(0, 0, 0, 0)
//-----------------------------------------------------------------------------
var dndDragging bool = false
var dndStart Point
var dndEnd Point
var tex gl.Texture
var tc TexCoords
var lastProgress int
initialRect := Rect{-1.5, -1.5, 3, 3}
rect := initialRect
rc := new(MandelbrotRequest)
rc.MakeRequest(512, 512, rect)
rc.WaitFor(Small, &tex, &tc)
running := true
e := new(sdl.Event)
for running {
for e.Poll() {
switch e.Type {
case sdl.QUIT:
running = false
case sdl.MOUSEBUTTONDOWN:
dndDragging = true
sdl.GetMouseState(&dndStart.X, &dndStart.Y)
dndEnd = dndStart
case sdl.MOUSEBUTTONUP:
dndDragging = false
sdl.GetMouseState(&dndEnd.X, &dndEnd.Y)
if e.MouseButton().Button == 3 {
rect = initialRect
} else {
rect = rectFromSelection(dndStart, dndEnd, 512, 512, rect)
tc = texCoordsFromSelection(dndStart, dndEnd, 512, 512, tc)
}
// make request
rc.MakeRequest(512, 512, rect)
case sdl.MOUSEMOTION:
if dndDragging {
sdl.GetMouseState(&dndEnd.X, &dndEnd.Y)
}
}
}
// if we're waiting for a result, check if it's ready
p := rc.Update(&tex, &tc)
if p != -1 {
lastProgress = p
}
gl.Clear(gl.COLOR_BUFFER_BIT)
tex.Bind(gl.TEXTURE_2D)
drawQuad(0, 0, 512, 512, tc.TX, tc.TY, tc.TX2, tc.TY2)
gl.BindTexture(gl.TEXTURE_2D, 0)
if dndDragging {
drawSelection(dndStart, dndEnd)
}
drawProgress(512, 512, lastProgress, rc.Pending)
sdl.GL_SwapBuffers()
}
}