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


Golang gl.Translatef函数代码示例

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


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

示例1: draw

func draw() {
	gl.Clear(gl.COLOR_BUFFER_BIT)
	gl.Enable(gl.BLEND)
	gl.Enable(gl.POINT_SMOOTH)
	gl.Enable(gl.LINE_SMOOTH)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
	gl.LoadIdentity()

	//Transform screen to keep player in middle. Added intentation to make obvious the push matrix is like a block
	gl.PushMatrix()
	// gl.Translatef((1280/2)-float32(player.x), 0, 0.0)

	// gl.Begin(gl.LINES)
	// gl.Color3f(.2, .5, .2)
	// for i := range staticLines {
	// 	x := staticLines[i].GetAsSegment().A.X
	// 	y := staticLines[i].GetAsSegment().A.Y
	// 	gl.Vertex3f(float32(x), float32(y), 0)
	// 	x = staticLines[i].GetAsSegment().B.X
	// 	y = staticLines[i].GetAsSegment().B.Y
	// 	gl.Vertex3f(float32(x), float32(y), 0)
	// }
	// gl.End()

	gl.Color4f(player.color_r, player.color_g, player.color_b, player.color_a)

	//Draw Player
	gl.PushMatrix()
	rot := player.rot
	pos_x := player.x
	pos_y := player.y

	gl.Translatef(pos_x, pos_y, 0.0)
	gl.Rotatef(float32(rot), 0, 0, 1)
	drawCircle(float64(BALL_RADIUS), 20)
	gl.PopMatrix()

	//Draw the grapple
	gl.PushMatrix()
	gl.Translatef(player.hook.x_end, player.hook.y_end, 0.0)
	drawCircle(float64(5), 5)
	gl.PopMatrix()

	//Grapple Line
	gl.LineWidth(2.5)
	gl.Color3f(1.0, 0.0, 0.0)
	gl.Begin(gl.LINES)
	gl.Vertex3f(player.x, player.y, 0.0)
	gl.Vertex3f(player.hook.x_end, player.hook.y_end, 0)
	gl.End()

	//Second Pop
	gl.PopMatrix()
}
开发者ID:jhautefeuille,项目名称:hellochipmunk,代码行数:54,代码来源:glfwtest.go

示例2: draw

// OpenGL draw function
func draw() {
	gl.Clear(gl.COLOR_BUFFER_BIT)
	gl.Enable(gl.BLEND)
	gl.Enable(gl.POINT_SMOOTH)
	gl.Enable(gl.LINE_SMOOTH)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
	gl.LoadIdentity()

	player := game.Player

	//Transform screen.
	gl.PushMatrix()
	gl.Translatef((1280/2)-float32((player.Body.Position().X)), 0, 0.0)

	gl.Begin(gl.LINES)
	gl.Color3f(.2, .5, .2)
	for _, segment := range game.Level.GetChipmunkSegments() {
		x := segment.GetAsSegment().A.X
		y := segment.GetAsSegment().A.Y
		gl.Vertex3f(float32(x), float32(y), 0)
		x = segment.GetAsSegment().B.X
		y = segment.GetAsSegment().B.Y
		gl.Vertex3f(float32(x), float32(y), 0)
	}
	gl.End()

	gl.Color4f(.9, .1, 1, .9)
	// draw balls
	for _, enemy := range game.Enemies {
		gl.PushMatrix()
		pos := enemy.Body.Position()
		rot := enemy.Body.Angle() * game.DegreeConst
		gl.Translatef(float32(pos.X), float32(pos.Y), 0.0)
		gl.Rotatef(float32(rot), 0, 0, 1)
		drawCircle(float64(enemy.Radius), 60)
		gl.PopMatrix()
	}
	gl.Color4f(.3, .3, 1, .8)
	//Draw Player
	gl.PushMatrix()
	pos := player.Body.Position()
	rot := player.Body.Angle() * game.DegreeConst
	gl.Translatef(float32(pos.X), float32(pos.Y), 0.0)
	gl.Rotatef(float32(rot), 0, 0, 1)
	drawCircle(float64(player.Radius), 60)
	gl.PopMatrix()

	gl.PopMatrix()
}
开发者ID:jhautefeuille,项目名称:hellochipmunk,代码行数:50,代码来源:main.go

示例3: drawSpinner

func drawSpinner(spinner int) {
	gl.LoadIdentity()
	gl.Translatef(30.5, 30.5, 0)
	gl.Rotatef(float32(spinner), 0, 0, 1)
	gl.Color3d(0, 0, 0)
	gl.Rectd(-0.5, -10.5, 0.5, 10.5)
}
开发者ID:taliszhou,项目名称:Conception-go,代码行数:7,代码来源:main.go

示例4: drawSlide

func drawSlide() {
	gl.Clear(gl.COLOR_BUFFER_BIT)

	gl.MatrixMode(gl.MODELVIEW)
	gl.LoadIdentity()
	gl.Translatef(0, 0, -3.0)

	gl.Begin(gl.QUADS)

	//top left
	gl.TexCoord2f(0, 0)
	gl.Vertex3f(-1, 1, 0)
	//top right
	gl.TexCoord2f(1, 0)
	gl.Vertex3f(1, 1, 0)

	//bottom right
	gl.TexCoord2f(1, 1)
	gl.Vertex3f(1, -1, 0)

	//bottom left
	gl.TexCoord2f(0, 1)
	gl.Vertex3f(-1, -1, 0)

	gl.End()

}
开发者ID:lordwelch,项目名称:PresentationApp,代码行数:27,代码来源:glfw.go

示例5: draw

// OpenGL draw function
func draw() {
	gl.Clear(gl.COLOR_BUFFER_BIT)
	gl.Enable(gl.BLEND)
	gl.Enable(gl.POINT_SMOOTH)
	gl.Enable(gl.LINE_SMOOTH)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
	gl.LoadIdentity()

	gl.Begin(gl.LINES)
	gl.Color3f(.2, .2, .2)
	for i := range staticLines {
		x := staticLines[i].GetAsSegment().A.X
		y := staticLines[i].GetAsSegment().A.Y
		gl.Vertex3f(float32(x), float32(y), 0)
		x = staticLines[i].GetAsSegment().B.X
		y = staticLines[i].GetAsSegment().B.Y
		gl.Vertex3f(float32(x), float32(y), 0)
	}
	gl.End()

	gl.Color4f(.3, .3, 1, .8)
	// draw balls
	for _, ball := range balls {
		gl.PushMatrix()
		pos := ball.Body.Position()
		rot := ball.Body.Angle() * chipmunk.DegreeConst
		gl.Translatef(float32(pos.X), float32(pos.Y), 0.0)
		gl.Rotatef(float32(rot), 0, 0, 1)
		drawCircle(float64(ballRadius), 60)
		gl.PopMatrix()
	}
}
开发者ID:TheZeroSlave,项目名称:chipmunk,代码行数:33,代码来源:bouncing_balls.go

示例6: reshape

/* new window size or exposure */
func reshape(width int32, height int32) {
	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, 600.0)
	gl.MatrixMode(gl.MODELVIEW)
	gl.LoadIdentity()
	gl.Translatef(0.0, 0.0, -100)
}
开发者ID:pietdaniel,项目名称:gl_maze,代码行数:11,代码来源:main.go

示例7: update

func (t *Transform) update() {
	gl.LoadMatrixf(&(t.parent.matrix[0]))
	gl.Translatef(t.position.X, t.position.Y, 0)
	gl.Rotatef(t.rotation, 0, 0, -1)
	gl.GetFloatv(gl.MODELVIEW_MATRIX, &(t.parent.matrix[0]))

	for _, c := range t.children {
		c.update()
	}
}
开发者ID:fmd,项目名称:bronson,代码行数:10,代码来源:transform.go

示例8: setVideoOptions

func (w *Window) setVideoOptions() {
	gl.ClearColor(0.4, 0.0, 0.3, 1.0)

	projectionMode()
	setViewport(w.Width, w.Height)

	//Required for per-pixel placing.
	gl.Translatef(0.375, 0.375, 0.0)

	modelViewMode()
	setModelViewOptions()
}
开发者ID:fmd,项目名称:gogol,代码行数:12,代码来源:window.go

示例9: reshape

func reshape(window *glfw.Window, w, h int) {
	gl.ClearColor(1, 1, 1, 1)
	//fmt.Println(gl.GetString(gl.EXTENSIONS))
	gl.Viewport(0, 0, int32(w), int32(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:zzn01,项目名称:draw2d,代码行数:14,代码来源:postscriptgl.go

示例10: reshape

func reshape(w int, 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.Viewport(0, 0, int32(w), int32(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. */
}
开发者ID:XO-Lib,项目名称:GCXO,代码行数:14,代码来源:Window.go

示例11: drawScene

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

	gl.LineWidth(1)

	gl.MatrixMode(gl.MODELVIEW)
	gl.LoadIdentity()
	gl.Translatef(0, 0, 0.0)
	//gl.Rotatef(rotationX, 1, 0, 0)
	//gl.Rotatef(rotationY, 0, 1, 0)

	//rotationX += 0.5
	//rotationY += 0.5

	//gl.BindTexture(gl.TEXTURE_2D, texture)

}
开发者ID:nightowlware,项目名称:gooey,代码行数:17,代码来源:gooey.go

示例12: Update

func (t *Transform) Update() {
	var m *float32
	if t.parentTransform != nil {
		m = &(t.parentTransform.Matrix[0])
	} else {
		m = &(t.Matrix[0])
	}

	gl.LoadMatrixf(m)
	gl.Translatef(t.position.X, t.position.Y, 0)
	gl.Rotatef(t.rotation, 0, 0, -1)
	gl.GetFloatv(gl.MODELVIEW_MATRIX, &(t.Matrix[0]))
	t.NeedsUpdate = false

	for _, c := range t.childTransforms {
		c.Update()
	}
}
开发者ID:fmd,项目名称:gogol,代码行数:18,代码来源:transform.go

示例13: key_handler

// returns if we are done or not
func key_handler() bool {
	var keys []uint8 = sdl.GetKeyState()

	if keys[sdl.K_i] != 0 {
		view_z += 1
	}
	if keys[sdl.K_o] != 0 {
		view_z -= 1
	}
	if keys[sdl.K_ESCAPE] != 0 {
		return true
	}
	if keys[sdl.K_UP] != 0 {
		view_rotx += 1
	}
	if keys[sdl.K_DOWN] != 0 {
		view_rotx -= 1.0
	}
	if keys[sdl.K_LEFT] != 0 {
		view_roty += 1.0
	}
	if keys[sdl.K_RIGHT] != 0 {
		view_roty -= 1.0
	}
	if keys[sdl.K_z] != 0 {
		if (sdl.GetModState() & sdl.KMOD_RSHIFT) != 0 {
			view_rotz -= 1.0
		} else {
			view_rotz += 1.0
		}
	}
	if keys[sdl.K_w] != 0 {
		gl.Translatef(0.0, 0.0, 1)
	}
	if keys[sdl.K_s] != 0 {
		gl.Translatef(0.0, 0.0, -1)
	}
	if keys[sdl.K_a] != 0 {
		gl.Translatef(-1, 0, 0)
	}
	if keys[sdl.K_d] != 0 {
		gl.Translatef(1, 0, 0)
	}
	if keys[sdl.K_q] != 0 {
		gl.Translatef(0, 1, 0)
	}
	if keys[sdl.K_e] != 0 {
		gl.Translatef(0, -1, 0)
	}
	return false
}
开发者ID:pietdaniel,项目名称:gl_maze,代码行数:52,代码来源:main.go

示例14: Render

func Render() {
	gl.ClearColor(0, 0, 0, 1)
	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

	gl.Color4f(1, 1, 1, 1)
	gl.BindTexture(gl.TEXTURE_2D, game.Texture)

	gl.PushMatrix()
	gl.Translatef(20-float32(game.PlayerX), 15-float32(game.PlayerY), 0)
	gl.Begin(gl.TRIANGLES)
	for i := 0; i < game.Width; i++ {
		for j := 0; j < game.Height; j++ {
			renderTile(game.Tiles[(j*game.Width)+i], float32(i), float32(j))
		}
	}
	// Player
	gl.Color4f(1, 0, 0, 1)
	renderTile(4, float32(game.PlayerX), float32(game.PlayerY))
	gl.End()
	gl.PopMatrix()
}
开发者ID:Geemili,项目名称:maze-rogue,代码行数:21,代码来源:maze-rogue.go

示例15: Printf

// Printf draws the given string at the specified coordinates.
// It expects the string to be a single line. Line breaks are not
// handled as line breaks and are rendered as glyphs.
//
// In order to render multi-line text, it is up to the caller to split
// the text up into individual lines of adequate length and then call
// this method for each line seperately.
func (f *Font) Printf(x, y float32, fs string, argv ...interface{}) error {
	indices := []rune(fmt.Sprintf(fs, argv...))

	if len(indices) == 0 {
		return nil
	}

	// Runes form display list indices.
	// For this purpose, they need to be offset by -FontConfig.Low
	low := f.config.Low
	for i := range indices {
		indices[i] -= low
	}

	var vp [4]int32
	gl.GetIntegerv(gl.VIEWPORT, &vp[0])

	gl.PushAttrib(gl.TRANSFORM_BIT)
	gl.MatrixMode(gl.PROJECTION)
	gl.PushMatrix()
	gl.LoadIdentity()
	gl.Ortho(float64(vp[0]), float64(vp[2]), float64(vp[1]), float64(vp[3]), 0, 1)
	gl.PopAttrib()

	gl.PushAttrib(gl.LIST_BIT | gl.CURRENT_BIT | gl.ENABLE_BIT | gl.TRANSFORM_BIT)
	{
		gl.MatrixMode(gl.MODELVIEW)
		gl.Disable(gl.LIGHTING)
		gl.Disable(gl.DEPTH_TEST)
		gl.Enable(gl.BLEND)
		gl.Enable(gl.TEXTURE_2D)

		gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
		gl.TexEnvf(gl.TEXTURE_ENV, gl.TEXTURE_ENV_MODE, gl.MODULATE)
		gl.BindTexture(gl.TEXTURE_2D, f.texture)
		gl.ListBase(f.listbase)

		var mv [16]float32
		gl.GetFloatv(gl.MODELVIEW_MATRIX, &mv[0])

		gl.PushMatrix()
		{
			gl.LoadIdentity()

			mgw := float32(f.maxGlyphWidth)
			mgh := float32(f.maxGlyphHeight)

			switch f.config.Dir {
			case LeftToRight, TopToBottom:
				gl.Translatef(x, float32(vp[3])-y-mgh, 0)
			case RightToLeft:
				gl.Translatef(x-mgw, float32(vp[3])-y-mgh, 0)
			}

			gl.MultMatrixf(&mv[0])
			gl.CallLists(int32(len(indices)), gl.UNSIGNED_INT, unsafe.Pointer(&indices[0]))
		}
		gl.PopMatrix()
		gl.BindTexture(gl.TEXTURE_2D, 0)
	}
	gl.PopAttrib()

	gl.PushAttrib(gl.TRANSFORM_BIT)
	gl.MatrixMode(gl.PROJECTION)
	gl.PopMatrix()
	gl.PopAttrib()
	return checkGLError()
}
开发者ID:go-gl,项目名称:gltext,代码行数:75,代码来源:font.go


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