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


Golang gl.LoadIdentity函数代码示例

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


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

示例1: resizeWindow

// reset our viewport after a window resize
func resizeWindow(width, height int) {
	// protect against a divide by zero
	if height == 0 {
		height = 1
	}

	// Setup our viewport
	gl.Viewport(0, 0, width, height)

	// change to the projection matrix and set our viewing volume.
	gl.MatrixMode(gl.PROJECTION)
	gl.LoadIdentity()

	// aspect ratio
	aspect := gl.GLdouble(width / height)

	// Set our perspective.
	// This code is equivalent to using gluPerspective as in the original tutorial.
	var fov, near, far gl.GLdouble
	fov = 45.0
	near = 0.1
	far = 100.0
	top := gl.GLdouble(math.Tan(float64(fov*math.Pi/360.0))) * near
	bottom := -top
	left := aspect * bottom
	right := aspect * top
	gl.Frustum(float64(left), float64(right), float64(bottom), float64(top), float64(near), float64(far))

	// Make sure we're changing the model view and not the projection
	gl.MatrixMode(gl.MODELVIEW)

	// Reset the view
	gl.LoadIdentity()
}
开发者ID:PragmaticCypher,项目名称:opengl-go-tutorials,代码行数:35,代码来源:lesson01.go

示例2: main

func main() {
	var err os.Error
	if err = glfw.Init(); err != nil {
		fmt.Fprintf(os.Stderr, "%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, "%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:skelterjohn,项目名称:glfw,代码行数:54,代码来源:main.go

示例3: reshape

/* new window size or exposure */
func reshape(width int, height int) {

	h := float64(height) / float64(width)

	gl.Viewport(0, 0, width, height)
	gl.MatrixMode(gl.PROJECTION)
	gl.LoadIdentity()
	gl.Frustum(-1.0, 1.0, -h, h, 5.0, 60.0)
	gl.MatrixMode(gl.MODELVIEW)
	gl.LoadIdentity()
	gl.Translatef(0.0, 0.0, -40.0)
}
开发者ID:DeedleFake,项目名称:Go-OpenGL,代码行数:13,代码来源:gogears.go

示例4: reshape

func reshape(w, h int) {
	if h == 0 {
		h = 1
	}
	gl.Viewport(0, 0, w, h)
	gl.MatrixMode(gl.PROJECTION)
	gl.LoadIdentity()
	glu.Perspective(45.0, float64(w)/float64(h), 0.1, 100.0)
	gl.MatrixMode(gl.MODELVIEW)
	gl.LoadIdentity()
	resetZoom()
}
开发者ID:nightkidfifa,项目名称:poly2tri.golang,代码行数:12,代码来源:main.go

示例5: resetZoom

func resetZoom() {
	// Reset viewport
	gl.LoadIdentity()
	gl.MatrixMode(gl.PROJECTION)
	gl.LoadIdentity()

	// Reset ortho view
	gl.Ortho(left, right, bottom, top, 1, -1)
	gl.Rotatef(180, 0, 0, 0)
	gl.Translatef(float32(-*cx), float32(-*cy), 0)
	gl.MatrixMode(gl.MODELVIEW)
	gl.Disable(gl.DEPTH_TEST)
	gl.LoadIdentity()
}
开发者ID:nightkidfifa,项目名称:poly2tri.golang,代码行数:14,代码来源:main.go

示例6: glEnable2D

func glEnable2D() {

	var vPort [4]gl.GLint

	gl.GetIntegerv(gl.VIEWPORT, &vPort[0])

	gl.MatrixMode(gl.PROJECTION)
	gl.PushMatrix()
	gl.LoadIdentity()

	gl.Ortho(0.0, gl.GLdouble(vPort[2]), 0.0, gl.GLdouble(vPort[3]), -1.0, 1.0)
	gl.MatrixMode(gl.MODELVIEW)
	gl.PushMatrix()
	gl.LoadIdentity()
}
开发者ID:jcd,项目名称:go-gamelib,代码行数:15,代码来源:draw_font.go

示例7: 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:PragmaticCypher,项目名称:opengl-go-tutorials,代码行数:49,代码来源:lesson04.go

示例8: DrawText2D

func (f *Font) DrawText2D(x int, y int, color [3]byte, scale float, txt string) (endw int, endh int) {
	gl.LoadIdentity()
	//	gl.Translatef(0.0, 0.0, -2.0);

	glEnable2D()
	gl.Disable(gl.DEPTH_TEST)

	texture, initial, intermediarya, intermediary, w, h := f.setupTextRendering(color, txt)

	locX := gl.GLfloat(x)
	locY := gl.GLfloat(y)
	wi := gl.GLfloat(w) * gl.GLfloat(scale)
	he := gl.GLfloat(h) * gl.GLfloat(scale)

	/* Draw a quad at location */
	gl.Begin(gl.QUADS)
	/* Recall that the origin is in the lower-left corner
	   That is why the TexCoords specify different corners
	   than the Vertex coors seem to. */
	gl.TexCoord2f(0.0, 1.0)
	gl.Vertex2f(locX, locY)
	gl.TexCoord2f(1.0, 1.0)
	gl.Vertex2f(locX+wi, locY)
	gl.TexCoord2f(1.0, 0.0)
	gl.Vertex2f(locX+wi, locY+he)
	gl.TexCoord2f(0.0, 0.0)
	gl.Vertex2f(locX, locY+he)
	gl.End()

	endw, endh = f.teardownTextRendering(texture, initial, intermediarya, intermediary)

	gl.Enable(gl.DEPTH_TEST)
	glDisable2D()
	return
}
开发者ID:jcd,项目名称:go-gamelib,代码行数:35,代码来源:draw_font.go

示例9: drawFrame

func drawFrame() {

	gl.LoadIdentity()
	gl.LineWidth(5.0)
	gl.Enable(gl.POINT_SMOOTH)
	gl.Enable(gl.LINE_SMOOTH)

	gl.Color4f(gl.GLfloat(FrameColor[0]), gl.GLfloat(FrameColor[1]), gl.GLfloat(FrameColor[2]), 0.1)

	m := PlayArea

	t := 1.0 * m
	b := -1.0 * m
	r := 1.0 * m
	l := -1.0 * m

	gl.Begin(gl.LINE_STRIP)

	zo := -5.0

	gl.Vertex3f(gl.GLfloat(l), gl.GLfloat(t), gl.GLfloat(zo))
	gl.Vertex3f(gl.GLfloat(r), gl.GLfloat(t), gl.GLfloat(zo))
	gl.Vertex3f(gl.GLfloat(r), gl.GLfloat(b), gl.GLfloat(zo))
	gl.Vertex3f(gl.GLfloat(l), gl.GLfloat(b), gl.GLfloat(zo))
	gl.Vertex3f(gl.GLfloat(l), gl.GLfloat(t), gl.GLfloat(zo))

	gl.End()

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

示例10: 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()
	// Banthar's glu doesn't have this right now.
	// 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.) /* 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:brownman,项目名称:Go-GLUT,代码行数:30,代码来源:fontdemo.go

示例11: reshape

func reshape(w, h int) {
	gl.Viewport(0, 0, w, h)
	gl.MatrixMode(gl.PROJECTION)
	gl.LoadIdentity()
	gl.Ortho(0, float64(w), 0, float64(h), -1, 1)
	gl.Scalef(1, -1, 1)
	gl.Translatef(0, float32(-h), 0)
	gl.MatrixMode(gl.MODELVIEW)
}
开发者ID:awpr,项目名称:Go-GLUT,代码行数:9,代码来源:fontdemo.go

示例12: 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

示例13: reshape

func reshape(w, h int) {
	gl.Viewport(0, 0, gl.GLsizei(w), gl.GLsizei(h))
	gl.MatrixMode(gl.PROJECTION)
	gl.LoadIdentity()
	gl.Ortho(0, gl.GLdouble(w), 0, gl.GLdouble(h), -1, 1)
	gl.Scalef(1, -1, 1)
	gl.Translatef(0, gl.GLfloat(-h), 0)
	gl.MatrixMode(gl.MODELVIEW)
}
开发者ID:brownman,项目名称:Go-GLUT,代码行数:9,代码来源:fontdemo.go

示例14: Setup

func (self *Camera) Setup() {
	d := self.Distance
	Angle := self.Angle
	Angle360 := Angle.Scale(1 / math.Pi * 180)
	TargetPos := self.Target.Pos

	gl.MatrixMode(gl.PROJECTION)
	gl.LoadIdentity()
	gl.Viewport(0, 0, 800, 600)
	gl.Frustum(-1, 1, -1, 1, 4, 1000)

	gl.MatrixMode(gl.MODELVIEW)
	gl.LoadIdentity()
	gl.Translatef(0, 0, -d)
	gl.Rotatef(Angle360.Y, 1, 0, 0)
	gl.Rotatef(Angle360.X, 0, 1, 0)
	gl.Translatef(-TargetPos.X, -TargetPos.Y, -TargetPos.Z)

}
开发者ID:rolfrm,项目名称:boxworld,代码行数:19,代码来源:graphics.go

示例15: draw

func draw() {
	xtrans := -xpos
	ztrans := -zpos
	ytrans := -walkbias - 0.25
	scenroty := 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(lookupdown, 1.0, 0.0, 0.0)
	// Rotate depending on direction player is facing
	gl.Rotatef(scenroty, 0.0, 1.0, 0.0)
	// translate the scene based on player position
	gl.Translatef(xtrans, ytrans-1.75, ztrans)

	for _, chunk := range chunks {
		for y := 0; y < 16; y++ {
			for x := 0; x < 16; x++ {
				for z := 0; z <= 16; z++ {
					if len(chunk.Data[y][x]) > z && chunk.Data[y][x][z] != "" {
						gl.PushMatrix()
						gl.Translated(
							float64(16*chunk.X+x),
							float64(z),
							float64(16*chunk.Y+y))
						gl.CallList(cubes[chunk.Data[y][x][z]])
						gl.PopMatrix()
					}
				}
			}
		}
	}

	gl.PopMatrix()

	sdl.GL_SwapBuffers()

	Frames++
	{
		t := sdl.GetTicks()
		if t-T0 >= 5000 {
			seconds := (t - T0) / 1000.0
			fps := Frames / seconds
			print(Frames, " frames in ", seconds, " seconds = ", fps, " FPS\n")
			T0 = t
			Frames = 0
		}
	}
}
开发者ID:yohcop,项目名称:cubopolis.go,代码行数:53,代码来源:main.go


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