当前位置: 首页>>代码示例>>Golang>>正文


Golang gl21.LoadIdentity函数代码示例

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


在下文中一共展示了LoadIdentity函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: run

func (w *Window) run() {
	runtime.LockOSThread()
	glfw.MakeContextCurrent(w.w)
	defer glfw.MakeContextCurrent(nil)

	// glfw should fire initial resize events to avoid this duplication (https://github.com/glfw/glfw/issues/62)
	width, height := w.w.Size()
	gl.MatrixMode(gl.PROJECTION)
	gl.LoadIdentity()
	gl.Ortho(0, gl.Double(width), 0, gl.Double(height), -1, 1)
	Resize(w, Pt(float64(width), float64(height)))
	width, height = w.w.FramebufferSize()
	gl.Viewport(0, 0, gl.Sizei(width), gl.Sizei(height))

	gl.Enable(gl.BLEND)
	gl.Enable(gl.POINT_SMOOTH)
	gl.Enable(gl.LINE_SMOOTH)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)

	for !w.close {
		select {
		case f := <-w.do:
			f()
		case <-w.paint:
			gl.MatrixMode(gl.MODELVIEW)
			gl.LoadIdentity()

			gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
			w.base().paint()
			w.w.SwapBuffers()
		}
	}
}
开发者ID:gordonklaus,项目名称:flux,代码行数:33,代码来源:window.go

示例2: Draw

func (g *Gui) Draw() {
	gl.MatrixMode(gl.PROJECTION)
	gl.LoadIdentity()
	gl.Ortho(gl.Double(g.region.X), gl.Double(g.region.X+g.region.Dx), gl.Double(g.region.Y+g.region.Dy), gl.Double(g.region.Y), 1000, -1000)
	gl.ClearColor(0, 0, 0, 1)
	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
	gl.MatrixMode(gl.MODELVIEW)
	gl.LoadIdentity()
	g.root.Draw(g.region, &styleStack{})
}
开发者ID:runningwild,项目名称:jota,代码行数:10,代码来源:gui.go

示例3: set2dView

func (o *OpenGl) set2dView() {
	gl.Disable(gl.TEXTURE_2D)
	gl.Disable(gl.DEPTH_TEST)
	gl.Disable(gl.LIGHTING)
	gl.Disable(gl.LIGHT0)
	gl.MatrixMode(gl.PROJECTION)
	gl.LoadIdentity()
	gl.Ortho(0, gl.Double(o.width), 0, gl.Double(o.height), -1, 1)
	gl.MatrixMode(gl.MODELVIEW)
	gl.LoadIdentity()
}
开发者ID:knickers,项目名称:GOpenGL,代码行数:11,代码来源:GOpenGL.go

示例4: Draw

func (g *Gui) Draw() {
	gl.MatrixMode(gl.PROJECTION)
	gl.LoadIdentity()
	region := g.root.Render_region
	gl.Ortho(gl.Double(region.X), gl.Double(region.X+region.Dx), gl.Double(region.Y), gl.Double(region.Y+region.Dy), 1000, -1000)
	gl.ClearColor(0, 0, 0, 1)
	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
	gl.MatrixMode(gl.MODELVIEW)
	gl.LoadIdentity()
	g.root.Draw(region)
	if g.FocusWidget() != nil {
		g.FocusWidget().DrawFocused(region)
	}
}
开发者ID:dgthunder,项目名称:glop,代码行数:14,代码来源:gui.go

示例5: drawScene

func drawScene() {
	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

	gl.MatrixMode(gl.MODELVIEW)
	gl.LoadIdentity()
	gl.Rotated(-90, 1, 0, 0)
	//gl.Rotated(90, 0, 0, 1)
	gl.Rotated(gl.Double(-viewAngles[2]), 1, 0, 0)
	gl.Rotated(gl.Double(-viewAngles[0]), 0, 1, 0)
	gl.Rotated(gl.Double(-viewAngles[1]), 0, 0, 1)
	gl.Translated(gl.Double(viewOrg[0]), gl.Double(viewOrg[1]), gl.Double(viewOrg[2]))

	var r, g, b gl.Ubyte

	for i, face := range model.Faces {
		r = gl.Ubyte(i) + 100
		g = gl.Ubyte(i>>1) + 100
		b = gl.Ubyte(i>>2) + 100

		if model.Triangle {
			gl.Begin(gl.TRIANGLES)
		} else {
			gl.Begin(gl.LINES)
		}

		gl.Color4ub(r, g, b, 0xff)
		for _, v := range face.Verts {
			gl.Vertex3d(gl.Double(v.Pos[0]), gl.Double(v.Pos[1]), gl.Double(v.Pos[2]))
		}

		gl.End()
	}
}
开发者ID:jayschwa,项目名称:groke,代码行数:33,代码来源:bspview.go

示例6: InitViewport

func InitViewport() {
	gl.Viewport(0, 0, gl.Sizei(Width), gl.Sizei(Height))
	gl.MatrixMode(gl.PROJECTION)
	gl.LoadIdentity()
	x := gl.Double(float64(Height) / float64(Width))
	gl.Frustum(-1./2., 1./2., -x/2, x/2, 10, 100)
}
开发者ID:shenyp09,项目名称:mx3,代码行数:7,代码来源:input.go

示例7: drawScene

func drawScene() {
	fps()
	gl.Clear(gl.COLOR_BUFFER_BIT)

	gl.MatrixMode(gl.PROJECTION)
	gl.LoadIdentity()
	if input.Zoom > 0 {
		gl.Ortho(0, gl.Double(float64(*flagSize)/input.Zoom), gl.Double(float64(*flagSize)/input.Zoom), 0, -1, 1.0)
	}

	gl.MatrixMode(gl.MODELVIEW)
	gl.LoadIdentity()
	gl.Translatef(gl.Float(input.TransX*1), gl.Float(input.TransY*1), 0)
	drawGrid()
	drawCells()
}
开发者ID:dskinner,项目名称:cell,代码行数:16,代码来源:main.go

示例8: run

func (w *Window) run(init func(w *Window)) {
	runtime.LockOSThread()
	glfw.MakeContextCurrent(w.w)
	defer glfw.MakeContextCurrent(nil)

	init(w)

	// glfw should fire initial resize events to avoid this duplication (https://github.com/glfw/glfw/issues/62)
	w.resized(w.w.Size())
	w.framebufferResized(w.w.FramebufferSize())

	gl.Enable(gl.SCISSOR_TEST)
	gl.Enable(gl.BLEND)
	gl.Enable(gl.POINT_SMOOTH)
	gl.Enable(gl.LINE_SMOOTH)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)

	for !w.close {
		select {
		case f := <-w.do:
			f()
		case <-w.paint:
			gl.MatrixMode(gl.MODELVIEW)
			gl.LoadIdentity()

			gl.Scissor(0, 0, w.bufWidth, w.bufHeight)
			gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
			w.base().paint()
			w.w.SwapBuffers()
		}
	}
}
开发者ID:gordonklaus,项目名称:gui,代码行数:32,代码来源:window.go

示例9: resize

// resize resizes the window to the specified dimensions.
func resize(width, height int) {
	gl.Viewport(0, 0, gl.Sizei(width), gl.Sizei(height))
	gl.MatrixMode(gl.PROJECTION)
	gl.LoadIdentity()
	gl.Ortho(-30.0, 30.0, -30.0, 30.0, -30.0, 30.0)
	gl.MatrixMode(gl.MODELVIEW)
}
开发者ID:travis1230,项目名称:RosettaCodeData,代码行数:8,代码来源:opengl.go

示例10: getPlayers

func getPlayers(console *base.Console) []gin.DeviceId {
	var ct controllerTracker
	gin.In().RegisterEventListener(&ct)
	defer gin.In().UnregisterEventListener(&ct)
	ticker := time.Tick(time.Millisecond * 17)
	start := time.Time{}
	readyDuration := time.Second * 2
	for start.IsZero() || time.Now().Sub(start) < readyDuration {
		<-ticker
		sys.Think()
		if ct.Ready() && start.IsZero() {
			start = time.Now()
		}
		if !ct.Ready() {
			start = time.Time{}
		}
		render.Queue(func() {
			defer console.Draw(0, 0, wdx, wdy)
			gl.Clear(gl.COLOR_BUFFER_BIT)
			gl.Disable(gl.DEPTH_TEST)
			gui.SetFontColor(1, 1, 1, 1)
			gl.Disable(gl.TEXTURE_2D)
			gl.MatrixMode(gl.PROJECTION)
			gl.LoadIdentity()
			gl.Ortho(gl.Double(0), gl.Double(wdx), gl.Double(wdy), gl.Double(0), 1000, -1000)
			gl.ClearColor(0, 0, 0, 1)
			gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
			gl.MatrixMode(gl.MODELVIEW)
			gl.LoadIdentity()
			base.GetDictionary("crackin").RenderString(fmt.Sprintf("Num players: %d", len(ct.ids)), float64(wdx)/2, 300, 0, 100, gui.Center)
			base.GetDictionary("crackin").RenderString(fmt.Sprintf("Num ready: %d", ct.NumReady()), float64(wdx)/2, 400, 0, 100, gui.Center)
			if !start.IsZero() {
				base.GetDictionary("crackin").RenderString(fmt.Sprintf("Starting in %2.2f", (readyDuration-time.Now().Sub(start)).Seconds()), float64(wdx)/2, 500, 0, 100, gui.Center)
			}
		})
		render.Queue(func() {
			sys.SwapBuffers()
		})
		render.Purge()
	}
	var devices []gin.DeviceId
	for id := range ct.ids {
		devices = append(devices, id)
	}
	return devices
}
开发者ID:runningwild,项目名称:jbot,代码行数:46,代码来源:main.go

示例11: SetUpCamera

func SetUpCamera(
	screenWidth int32,
	screenHeight int32,
	lb *LevelBlueprint,
	playerIndex int32) {
	pb := &lb.Players[playerIndex]

	// Calculate the distance between the near plane and the camera. We want
	// (PaddleAreaWidth / 2) / cameraDist = tan(CameraHorzFovDegrees / 2)
	t := math.Tan(math.Pi * Config.CameraHorzFovDegrees / 360)
	cameraDist := pb.PaddleAreaWidth / (2 * t)
	cameraPos := pb.PaddleAreaCenter.Minus(
		pb.Orientation.Forward.Times(cameraDist))

	// Set up the projection matrix.
	gl.MatrixMode(gl.PROJECTION)
	gl.LoadIdentity()
	gl.Viewport(0, 0, gl.Sizei(screenWidth), gl.Sizei(screenHeight))
	gl.Frustum(
		gl.Double(-pb.PaddleAreaWidth/2), gl.Double(pb.PaddleAreaWidth/2),
		gl.Double(-pb.PaddleAreaHeight/2), gl.Double(pb.PaddleAreaHeight/2),
		gl.Double(cameraDist), gl.Double(cameraDist+Config.ViewDepth))

	// Set up the modelview matrix.
	gl.MatrixMode(gl.MODELVIEW)
	gl.LoadIdentity()
	transformation := [16]gl.Double{
		gl.Double(pb.Orientation.Right.X),
		gl.Double(pb.Orientation.Up.X),
		gl.Double(-pb.Orientation.Forward.X),
		gl.Double(0.0),
		gl.Double(pb.Orientation.Right.Y),
		gl.Double(pb.Orientation.Up.Y),
		gl.Double(-pb.Orientation.Forward.Y),
		gl.Double(0.0),
		gl.Double(pb.Orientation.Right.Z),
		gl.Double(pb.Orientation.Up.Z),
		gl.Double(-pb.Orientation.Forward.Z),
		gl.Double(0.0),
		gl.Double(0.0), gl.Double(0.0), gl.Double(0.0), gl.Double(1.0)}
	gl.MultMatrixd(&transformation[0])
	gl.Translated(
		gl.Double(-cameraPos.X),
		gl.Double(-cameraPos.Y),
		gl.Double(-cameraPos.Z))
}
开发者ID:runningwild,项目名称:arkanoid,代码行数:46,代码来源:level-blueprint.go

示例12: UpdateViewpos

// Set the GL modelview matrix to match view position and orientation.
func UpdateViewpos() {
	gl.MatrixMode(gl.MODELVIEW)
	gl.LoadIdentity()
	gl.Translatef(gl.Float(Viewpos[0]), gl.Float(Viewpos[1]), gl.Float(Viewpos[2]))
	gl.Rotatef(gl.Float(Rot[0]*2), 1, 0, 0)
	gl.Rotatef(gl.Float(Rot[1]*2), 0, 1, 0)
	gl.Rotatef(gl.Float(Rot[2]*2), 0, 0, 1)
}
开发者ID:shenyp09,项目名称:mx3,代码行数:9,代码来源:input.go

示例13: mainLoop

func mainLoop(client sgf.ClientEngine, controllers []gin.DeviceId, console *base.Console) {
	client.MakeRequest(game.Join{Rebels: make([]*game.RebelPlayer, 2)})
	ticker := time.Tick(time.Millisecond * 17)
	render.Queue(func() {
		gl.Enable(gl.BLEND)
		gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
	})
	for {
		<-ticker
		if gin.In().GetKey(gin.AnyEscape).FramePressCount() != 0 {
			return
		}
		sys.Think()
		render.Queue(func() {
			gl.Clear(gl.COLOR_BUFFER_BIT)
			gl.Disable(gl.DEPTH_TEST)
			gui.SetFontColor(1, 1, 1, 1)
			gl.Disable(gl.TEXTURE_2D)
			gl.MatrixMode(gl.PROJECTION)
			gl.LoadIdentity()
			gl.Ortho(gl.Double(0), gl.Double(wdx), gl.Double(wdy), gl.Double(0), 1000, -1000)
			gl.ClearColor(0, 0, 0, 1)
			gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
			gl.MatrixMode(gl.MODELVIEW)
			gl.LoadIdentity()
			base.GetDictionary("crackin").RenderString("Waiting on some nubs", float64(wdx)/2, 300, 0, 100, gui.Center)
		})

		client.RLock()
		g := client.Game().(*game.Game)
		mode := g.Mode
		client.RUnlock()
		if mode == game.ModeWaiting {
		} else if mode == game.ModeProgram {
			programLoop(client, controllers, console)
		} else if mode == game.ModeRun {

		}

		render.Queue(func() {
			sys.SwapBuffers()
		})
		render.Purge()
	}
}
开发者ID:runningwild,项目名称:jbot,代码行数:45,代码来源:main.go

示例14: Enable2d

func Enable2d(x1, y1, w, h gl.Double) {

	// Save a copy of the proj matrix so we can restore it
	// when we want to do more 3d rendering
	gl.MatrixMode(gl.PROJECTION)
	gl.LoadIdentity()

	// Set up orthographic projection
	gl.Ortho(x1, x1+w, y1, y1+h, 0.0, 1)
	gl.MatrixMode(gl.MODELVIEW)
	gl.LoadIdentity()

	// Make sure depth testing and lighting are disabled for 2d redering
	// until we are fninished rendering in 2d
	gl.PushAttrib(gl.DEPTH_BUFFER_BIT | gl.LIGHTING_BIT)
	gl.Disable(gl.DEPTH_TEST)
	gl.Disable(gl.LIGHTING)
}
开发者ID:kelly-ry4n,项目名称:glGalaxy,代码行数:18,代码来源:texloader.go

示例15: resized

func (w *Window) resized(width, height int) {
	wid, hei := float64(width), float64(height)
	gl.MatrixMode(gl.PROJECTION)
	gl.LoadIdentity()
	gl.Ortho(0, gl.Double(wid), 0, gl.Double(hei), -1, 1)
	w.Self.Resize(wid, hei)
	if w.centralView != nil {
		w.centralView.Resize(wid, hei)
	}
}
开发者ID:gordonklaus,项目名称:gui,代码行数:10,代码来源:window.go


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