• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang gl.ClearColor函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中gl.ClearColor函数的典型用法代码示例。如果您正苦于以下问题:Golang ClearColor函数的具体用法?Golang ClearColor怎么用?Golang ClearColor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ClearColor函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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()
}
开发者ID:pdelbarba,项目名称:gl3-examples,代码行数:31,代码来源:main.go


示例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()
}
开发者ID:jcd,项目名称:go-gamelib,代码行数:29,代码来源:chain-reaction.go


示例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)
}
开发者ID:nightkidfifa,项目名称:poly2tri.golang,代码行数:8,代码来源:main.go


示例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()

}
开发者ID:krakensden,项目名称:Go-OpenGL,代码行数:57,代码来源:draw.go


示例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)
}
开发者ID:PragmaticCypher,项目名称:opengl-go-tutorials,代码行数:12,代码来源:lesson09.go


示例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()
}
开发者ID:brownman,项目名称:Go-GLUT,代码行数:12,代码来源:fontdemo.go


示例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()

}
开发者ID:losinggeneration,项目名称:opengl,代码行数:53,代码来源:draw.go


示例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")
	}

}
开发者ID:yohcop,项目名称:cubopolis.go,代码行数:51,代码来源:main.go


示例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)

}
开发者ID:jcd,项目名称:go-gamelib,代码行数:50,代码来源:video.go


示例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 )
}
开发者ID:shogg,项目名称:opengl-go-tutorials,代码行数:19,代码来源:lesson08.go


示例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)
}
开发者ID:PragmaticCypher,项目名称:opengl-go-tutorials,代码行数:20,代码来源:lesson10.go


示例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
}
开发者ID:xushiwei,项目名称:draw2d,代码行数:19,代码来源:draw2dgl.go


示例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)
}
开发者ID:PragmaticCypher,项目名称:opengl-go-tutorials,代码行数:20,代码来源:lesson01.go


示例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.
}
开发者ID:shogg,项目名称:opengl-go-tutorials,代码行数:21,代码来源:lesson07.go


示例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()
	}
}
开发者ID:saschpe,项目名称:Go-OpenGL,代码行数:88,代码来源:gomandel.go


示例16: Clear

func (gd *openGLGraphicsDevice) Clear() {
	gl.ClearColor(0.0, 0.0, 1.0, 0.5)
	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
}
开发者ID:chsc,项目名称:g3,代码行数:4,代码来源:ogl_graphics.go


示例17: main

func main() {
	//ABSPTest()
	//return
	glfw.Init(800, 600)
	InitPhysics()

	world := new(World)
	world.Init()
	world.GameObjects = new(list.List)
	player := MakeMan(Vec3{10, 20, 10})

	world.Add(player)
	world.Add(ropetest(Vec3{0, 40, 0}, 4, 4))
	world.Add(treeThing(Vec3{20, 20, 20}, 3))
	world.Add(MakePlayer(Vec3{-20, 20, 0}).Body)
	world.Add(MakePlayer(Vec3{-20, 50, 0}).Body)

	world.Add(MakePlayer(Vec3{-20, 70, 0}).Body)
	world.Add(MakePlayer(Vec3{-20, 90, 0}).Body)
	world.Add(MakePlayer(Vec3{-20, 110, 0}).Body)
	/*for i := 0; i < 100; i++ {
		world.Add(SetPlayerAnimation(MakePlayer(Vec3{float32(int(i%10))*50,0,float32(i*2) - 200})).Body)
	}*/
	world.Add(NewGameObj(Vec3{0, -20, 0}, Vec3{10000, 10, 10000}, Vec3{0, 0.5, 0.1}, float32(math.Inf(1)), 10, nil))

	//world.Add(SetPlayerAnimation(MakePlayer(Vec3{-20,120,0})).Body)

	qtn := new(ABSPNode)
	qtn.Root = qtn
	//qtn.Position = Vec3{-10000,-10000,-10000}
	//qtn.Size = Vec3{20000,20000,20000}
	for i := world.GameObjects.Front(); i != nil; i = i.Next() {
		gobj := i.Value.(*GameObj)
		all := gobj.GetSubs()
		for i := 0; i < len(all); i++ {
			qtn.Insert(all[i])
		}
	}
	world.GameObjectTree = qtn
	fmt.Println("Total:", len(qtn.Data))
	qtn.Divide()
	cols := 0
	qtn.cd(func(obj1, obj2 SPData) {
		cols += 1
	})
	fmt.Println(cols)
	//qtn.Traverse(0)
	//return
	gl.Init()
	vs := gl.CreateShader(gl.VERTEX_SHADER)
	vs.Source(
		LoadFileToString("s1.vert"))
	vs.Compile()

	fs := gl.CreateShader(gl.FRAGMENT_SHADER)
	fs.Source(LoadFileToString("s1.frag"))
	fs.Compile()

	pg := gl.CreateProgram()
	pg.AttachShader(vs)
	pg.AttachShader(fs)
	pg.Link()
	pg.Validate()

	pg.Use()
	fmt.Println("**Shader log**")
	fmt.Println(fs.GetInfoLog())
	fmt.Println(vs.GetInfoLog())
	fmt.Println(pg.GetInfoLog())
	fmt.Println("******END*****")

	gl.ClearColor(0.5, 0.5, 1, 0)
	gl.Enable(gl.DEPTH_TEST)
	gl.Enable(gl.BLEND)
	gl.Enable(gl.POLYGON_SMOOTH)
	gl.Hint(gl.POLYGON_SMOOTH_HINT, gl.NICEST)

	var t float64
	t = float64(time.Nanoseconds()) / 1000000000
	cam1 := Camera{player, 100, Vec3{0, 0, 0}}
	glfw.AddListener(func(m glfw.MouseMoveEvent) {
		cam1.Angle.X = float32(m.X-400) / 400 * 3.14 * 2
		cam1.Angle.Y = float32(m.Y-300) / 300 * 3.14 * 2
		//player.Rotation = Vec3{cam1.Angle.X,cam1.Angle.Y,0}
	})
	glfw.AddListener(func(mw glfw.MouseWheelEvent) {
		cam1.Distance = 100 + float32(mw.Pos*mw.Pos*mw.Pos)
	})

	world.CompilePhysicsObjects()
	for it := 0; it < 10000; it += 1 {
		cam1.Setup()
		dt := float32(0.005)
		t = float64(float64(time.Nanoseconds()) / 1000000000)
		UpdatePositions(world.PhysicsObjects, dt)

		UpdateModelStates(world.PhysicsObjects)

		UpdateCollisions(world.GameObjectTree, dt)
		UpdateModelStates(world.PhysicsObjects)
//.........这里部分代码省略.........
开发者ID:rolfrm,项目名称:boxworld,代码行数:101,代码来源:main.go


示例18: main

func main() {
	runtime.LockOSThread()
	flag.Parse()
	sdl.Init(sdl.INIT_VIDEO)
	defer sdl.Quit()

	sdl.GL_SetAttribute(sdl.GL_SWAP_CONTROL, 1)

	if sdl.SetVideoMode(640, 480, 32, sdl.OPENGL) == nil {
		panic("sdl error")
	}

	sdl.WM_SetCaption("Gotris", "Gotris")
	sdl.EnableKeyRepeat(250, 45)

	gl.Enable(gl.TEXTURE_2D)
	gl.Enable(gl.BLEND)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
	gl.Viewport(0, 0, 640, 480)
	gl.MatrixMode(gl.PROJECTION)
	gl.LoadIdentity()
	gl.Ortho(0, 640, 480, 0, -1, 1)

	gl.ClearColor(0, 0, 0, 0)

	//-----------------------------------------------------------------------------

	font, err := LoadFontFromFile("dejavu.font")
	if err != nil {
		panic(err)
	}

	rand.Seed(int64(sdl.GetTicks()))

	gs := NewGameSession(*initLevel, font)
	lastTime := sdl.GetTicks()

	running := true
	for running {
		for ev := sdl.PollEvent(); ev != nil; ev = sdl.PollEvent() {
			switch e := ev.(type) {
			case *sdl.QuitEvent:
				running = false
			case *sdl.KeyboardEvent:
				if e.Type == sdl.KEYDOWN {
					running = gs.HandleKey(e.Keysym.Sym)
				}
			}
		}

		now := sdl.GetTicks()
		delta := now - lastTime
		lastTime = now

		gs.Update(delta)

		gl.Clear(gl.COLOR_BUFFER_BIT)
		font.Draw(5, 5, fmt.Sprintf("Level: %d | Score: %d", gs.Level, gs.Score))
		gs.Draw()
		gl.Color3ub(255, 255, 255)
		sdl.GL_SwapBuffers()
	}
}
开发者ID:sonald,项目名称:gotris,代码行数:63,代码来源:gotris.go



注:本文中的gl.ClearColor函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang gl.Enable函数代码示例发布时间:2022-05-28
下一篇:
Golang gl.Clear函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap