本文整理汇总了Golang中github.com/go-gl/gl.PopMatrix函数的典型用法代码示例。如果您正苦于以下问题:Golang PopMatrix函数的具体用法?Golang PopMatrix怎么用?Golang PopMatrix使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PopMatrix函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: 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()
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.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:himanshushekhar,项目名称:glut,代码行数:29,代码来源:fontdemo.go
示例2: draw
// OpenGL draw function & timing
func draw() {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.PushMatrix()
gl.Rotated(view_rotx, 1.0, 0.0, 0.0)
gl.Rotated(view_roty, 0.0, 1.0, 0.0)
gl.Rotated(view_rotz, 0.0, 0.0, 1.0)
gl.PushMatrix()
gl.Translated(-3.0, -2.0, 0.0)
gl.Rotated(angle, 0.0, 0.0, 1.0)
gl.CallList(gear1)
gl.PopMatrix()
gl.PushMatrix()
gl.Translated(3.1, -2.0, 0.0)
gl.Rotated(-2.0*angle-9.0, 0.0, 0.0, 1.0)
gl.CallList(gear2)
gl.PopMatrix()
gl.PushMatrix()
gl.Translated(-3.1, 4.2, 0.0)
gl.Rotated(-2.0*angle-25.0, 0.0, 0.0, 1.0)
gl.CallList(gear3)
gl.PopMatrix()
gl.PopMatrix()
}
开发者ID:nzlov,项目名称:examples,代码行数:29,代码来源:gears.go
示例3: popGlStates
func (r *RenderTarget) popGlStates() {
gl.MatrixMode(gl.PROJECTION)
gl.PopMatrix()
gl.MatrixMode(gl.MODELVIEW)
gl.PopMatrix()
gl.MatrixMode(gl.TEXTURE)
gl.PopMatrix()
gl.PopClientAttrib()
gl.PopAttrib()
}
开发者ID:netpoetica,项目名称:gosfml,代码行数:10,代码来源:rendertarget.go
示例4: renderSwitchBlocks
func renderSwitchBlocks(s *Switch) {
// TODO constant
v := SwitchSize / 2
x, y := float32(s.X+v), float32(s.Y+v)
gl.LoadIdentity()
gl.Translatef(x, y, 0)
if s.rotate != 0 {
gl.Rotatef(float32(s.rotate), 0, 0, 1)
}
bsf := float32(BlockSize - s.Z)
padding := float32(BlockPadding)
var b *Block
// Render block top left
b = g.level.blocks[s.line][s.col]
if !b.Rendered {
gl.PushMatrix()
gl.Translatef(-bsf-padding, -bsf-padding, 0)
renderBlock(b, bsf)
gl.PopMatrix()
b.Rendered = true
}
// Render block top right
b = g.level.blocks[s.line][s.col+1]
if !b.Rendered {
gl.PushMatrix()
gl.Translatef(padding, -bsf-padding, 0)
renderBlock(b, bsf)
gl.PopMatrix()
b.Rendered = true
}
// Render block bottom right
b = g.level.blocks[s.line+1][s.col+1]
if !b.Rendered {
gl.PushMatrix()
gl.Translatef(padding, padding, 0)
renderBlock(b, bsf)
gl.PopMatrix()
b.Rendered = true
}
// render block bottom left
b = g.level.blocks[s.line+1][s.col]
if !b.Rendered {
gl.PushMatrix()
gl.Translatef(-bsf-padding, padding, 0)
renderBlock(b, bsf)
gl.PopMatrix()
b.Rendered = true
}
}
开发者ID:remogatto,项目名称:mozaik,代码行数:53,代码来源:main_init.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:niksaak,项目名称:chipmunk,代码行数:33,代码来源:bouncing_balls.go
示例6: Draw
func (m *Map) Draw() {
gl.PushMatrix()
gl.PushAttrib(gl.CURRENT_BIT | gl.ENABLE_BIT | gl.LIGHTING_BIT | gl.POLYGON_BIT | gl.LINE_BIT)
gl.EnableClientState(gl.VERTEX_ARRAY)
gl.VertexPointer(3, gl.FLOAT, 0, m.vertices)
gl.EnableClientState(gl.NORMAL_ARRAY)
gl.NormalPointer(gl.FLOAT, 0, m.normals)
// gl.EnableClientState(gl.TEXTURE_COORD_ARRAY)
// gl.TexCoordPointer(2, gl.FLOAT, 0, m.texcoords)
gl.EnableClientState(gl.COLOR_ARRAY)
gl.ColorPointer(3, gl.FLOAT, 0, m.colors)
// draw solids
gl.Enable(gl.COLOR_MATERIAL)
// gl.DrawArrays(gl.TRIANGLE_STRIP, 0, len(m.vertices)/3)
gl.PolygonMode(gl.FRONT_AND_BACK, gl.LINE)
gl.LineWidth(1.0)
gl.Color4f(1, 1, 1, 1)
gl.DrawArrays(gl.TRIANGLE_STRIP, 0, len(m.vertices)/3)
gl.PopAttrib()
gl.PopMatrix()
}
开发者ID:sixthgear,项目名称:landscapes,代码行数:30,代码来源:map.go
示例7: main
func main() {
if !glfw.Init() {
log.Fatal("glfw failed to initialize")
}
defer glfw.Terminate()
window, err := glfw.CreateWindow(640, 480, "Deformable", nil, nil)
if err != nil {
log.Fatal(err.Error())
}
window.MakeContextCurrent()
glfw.SwapInterval(1)
window.SetMouseButtonCallback(handleMouseButton)
window.SetKeyCallback(handleKeyDown)
window.SetInputMode(glfw.Cursor, glfw.CursorHidden)
gl.Init()
initGL()
i := 16
m = GenerateMap(1600/i, 1200/i, i)
for running && !window.ShouldClose() {
x, y := window.GetCursorPosition()
if drawing != 0 {
m.Add(int(x)+int(camera[0]), int(y)+int(camera[1]), drawing, brushSizes[currentBrushSize])
}
gl.Clear(gl.COLOR_BUFFER_BIT)
gl.LoadIdentity()
gl.PushMatrix()
gl.PushAttrib(gl.CURRENT_BIT | gl.ENABLE_BIT | gl.LIGHTING_BIT | gl.POLYGON_BIT | gl.LINE_BIT)
gl.Translatef(-camera[0], -camera[1], 0)
m.Draw()
gl.PopAttrib()
gl.PopMatrix()
gl.PushAttrib(gl.COLOR_BUFFER_BIT)
gl.LineWidth(2)
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.ONE_MINUS_DST_COLOR, gl.ZERO)
// gl.Enable(gl.LINE_SMOOTH)
// gl.Hint(gl.LINE_SMOOTH_HINT, gl.NICEST)
gl.Translatef(float32(x), float32(y), 0)
gl.EnableClientState(gl.VERTEX_ARRAY)
gl.VertexPointer(2, gl.DOUBLE, 0, cursorVerts)
gl.DrawArrays(gl.LINE_LOOP, 0, 24)
gl.PopAttrib()
window.SwapBuffers()
glfw.PollEvents()
}
}
开发者ID:sixthgear,项目名称:deformable,代码行数:60,代码来源:main.go
示例8: runGameLoop
func runGameLoop(window *glfw.Window) {
for !window.ShouldClose() {
// update objects
updateObjects()
// hit detection
hitDetection()
// ---------------------------------------------------------------
// draw calls
gl.Clear(gl.COLOR_BUFFER_BIT)
drawCurrentScore()
drawHighScore()
if isGameWon() {
drawWinningScreen()
} else if isGameLost() {
drawGameOverScreen()
}
// draw everything 9 times in a 3x3 grid stitched together for seamless clipping
for x := -1.0; x < 2.0; x++ {
for y := -1.0; y < 2.0; y++ {
gl.MatrixMode(gl.MODELVIEW)
gl.PushMatrix()
gl.Translated(gameWidth*x, gameHeight*y, 0)
drawObjects()
gl.PopMatrix()
}
}
gl.Flush()
window.SwapBuffers()
glfw.PollEvents()
// switch resolution
if altEnter {
window.Destroy()
fullscreen = !fullscreen
var err error
window, err = initWindow()
if err != nil {
panic(err)
}
altEnter = false
gl.LineWidth(1)
if fullscreen {
gl.LineWidth(2)
}
}
}
}
开发者ID:JamesClonk,项目名称:asteroids,代码行数:58,代码来源:main.go
示例9: PlaceObject
func PlaceObject(compiledPrim gl.List, scale [3]double, translation [3]double, rotation [4]double) {
// objects are placed and transformed when necessary
gl.PushMatrix()
gl.Scaled(scale)
gl.Translated(translation)
gl.Rotated(rotation)
gl.CallList(compiledPrim)
gl.PopMatrix()
}
开发者ID:7thprime,项目名称:sol,代码行数:9,代码来源:utils.go
示例10: stroke_output
func stroke_output(x, y float32, str string, font glut.StrokeFont) {
gl.PushMatrix()
gl.Translatef(x, y, 0)
gl.Scalef(0.005, 0.005, 0.005)
for _, ch := range str {
font.Character(ch)
}
gl.PopMatrix()
}
开发者ID:himanshushekhar,项目名称:glut,代码行数:9,代码来源:fontdemo.go
示例11: drawPaddle
func drawPaddle(x float32, y float32) {
gl.PushMatrix()
gl.Translatef(float32(x), float32(y), 0)
gl.Color3f(1.0, 1.0, 1.0)
gl.Begin(gl.LINE_STRIP)
gl.Vertex2f(0, -5)
gl.Vertex2f(0, 5)
gl.End()
gl.PopMatrix()
}
开发者ID:rick-monster,项目名称:gopong,代码行数:10,代码来源:view.go
示例12: draw
func draw() {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.PushMatrix()
gl.Rotated(view_rotx, 1.0, 0.0, 0.0)
gl.Rotated(view_roty, 0.0, 1.0, 0.0)
gl.Rotated(view_rotz, 0.0, 0.0, 1.0)
gl.PushMatrix()
gl.Translated(-3.0, -2.0, 0.0)
gl.Rotated(angle, 0.0, 0.0, 1.0)
gl.CallList(gear1)
gl.PopMatrix()
gl.PushMatrix()
gl.Translated(3.1, -2.0, 0.0)
gl.Rotated(-2.0*angle-9.0, 0.0, 0.0, 1.0)
gl.CallList(gear2)
gl.PopMatrix()
gl.PushMatrix()
gl.Translated(-3.1, 4.2, 0.0)
gl.Rotated(-2.0*angle-25.0, 0.0, 0.0, 1.0)
gl.CallList(gear3)
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:jayschwa,项目名称:examples,代码行数:43,代码来源:main.go
示例13: DrawEntity
func DrawEntity(en Entity) {
x := en.Xpos
y := en.Ypos
r := en.Rot
s := en.Size
col := en.Colour
switch col {
case "grey":
gl.Color3d(0.5, 0.5, 0.5)
case "red":
gl.Color3d(1, 0, 0)
case "green":
gl.Color3d(0, 1, 0)
case "blue":
gl.Color3d(0, 0, 1)
case "lblue":
gl.Color3d(0.3, 0.3, 1)
case "orange":
gl.Color3d(1, 0.5, 0)
case "yellow":
gl.Color3d(1, 1, 0)
case "purple":
gl.Color3d(1, 0, 1)
case "white":
gl.Color3d(1, 1, 1)
default:
gl.Color3d(1, 1, 1)
}
gl.PushMatrix()
gl.Translated(x, y, 0)
gl.Scaled(s, s, s)
//gl.Rotated(r*180/math.Pi, 0, 0, 1)
gl.Rotated(r, 0, 0, 1)
enx := [3]float64{-0.7, 0.7, 0}
eny := [3]float64{1, 1, -1}
//in OpenGL 3.2, the vertices below would be stored on the GPU
//so all you would need to do is say DrawShape(A) or something
gl.Begin(gl.TRIANGLES)
gl.Vertex3d(enx[0], eny[0], 0)
gl.Vertex3d(enx[1], eny[1], 0)
gl.Vertex3d(enx[2], eny[2], 0)
gl.End()
gl.PopMatrix()
}
开发者ID:neurocase,项目名称:pathfinding,代码行数:53,代码来源:drawen.go
示例14: drawPool
func drawPool(cards [5]DeckCard, x float32) {
gl.PushMatrix()
gl.Translatef(x, 590-CardHeight, 0)
for i, card := range cards {
if i > 0 {
gl.Translatef(0, -(CardHeight + 5), 0)
}
card.Draw()
}
gl.PopMatrix()
}
开发者ID:Bunkerbewohner,项目名称:cardgame,代码行数:13,代码来源:playfield.go
示例15: DebugLines
// Draws a cross on the screen with known lengths, useful for understanding
// screen dimensions
func DebugLines() {
gl.MatrixMode(gl.PROJECTION)
gl.PushMatrix()
//gl.LoadIdentity()
//gl.Ortho(-2.1, 6.1, -4, 8, 1, -1)
gl.MatrixMode(gl.MODELVIEW)
gl.PushMatrix()
gl.LoadIdentity()
gl.LoadIdentity()
gl.LineWidth(5)
gl.Color4f(1, 1, 0, 1)
gl.Begin(gl.LINES)
gl.Vertex2d(0, -1.6)
gl.Vertex2d(0, 0.8)
gl.Vertex2d(-0.8, 0)
gl.Vertex2d(0.8, 0)
gl.End()
gl.PopMatrix()
gl.MatrixMode(gl.PROJECTION)
gl.PopMatrix()
gl.MatrixMode(gl.MODELVIEW)
}
开发者ID:jasonrpowers,项目名称:glh,代码行数:26,代码来源:util.go
示例16: DrawSizeableTri
func DrawSizeableTri(Tr SizeableTri) {
ax := Tr.Ax
bx := Tr.Bx
cx := Tr.Cx
ay := Tr.Ay
by := Tr.By
cy := Tr.Cy
col := Tr.Colour
switch col {
case "grey":
gl.Color3d(0.5, 0.5, 0.5)
case "red":
gl.Color3d(1, 0, 0)
case "green":
gl.Color3d(0, 1, 0)
case "blue":
gl.Color3d(0, 0, 1)
case "lblue":
gl.Color3d(0.3, 0.3, 1)
case "orange":
gl.Color3d(1, 0.5, 0)
case "yellow":
gl.Color3d(1, 1, 0)
case "purple":
gl.Color3d(1, 0, 1)
default:
gl.Color3d(1, 1, 1)
}
gl.PushMatrix()
// gl.Translated(x, y, 0)
// gl.Scaled(s, s, s)
// gl.Rotated(r, 0, 0, 1)
gl.Begin(gl.TRIANGLES)
gl.Vertex3d(ax, ay, 0)
gl.Vertex3d(bx, by, 0)
gl.Vertex3d(cx, cy, 0)
gl.End()
gl.PopMatrix()
}
开发者ID:neurocase,项目名称:physicstest,代码行数:48,代码来源:drawen.go
示例17: Render
func (m HexMap) Render() {
for x := 0; x < 11; x++ {
maxy := 8
if x%2 == 1 {
maxy = 9
}
for y := 0; y < maxy; y++ {
if m[x][y].State != StateNormal {
continue
}
gl.PushMatrix()
posX, posY := m.GetTopLeft(x, y).WithOffset()
gl.Translatef(float32(posX), float32(posY), 0)
m[x][y].Render(1, false)
gl.PopMatrix()
}
}
}
开发者ID:TheOnly92,项目名称:gexic,代码行数:18,代码来源:hex.go
示例18: Draw
func (p *Playfield) Draw() {
drawPool(p.playerCards, 10)
drawPool(p.opponentCards, 790-CardWidth)
// draw the slots
gl.PushMatrix()
gl.Translatef(CardWidth+60, 580-CardHeight, 0)
for i, slot := range p.slots {
if i > 0 {
gl.Translatef(CardWidth+2, 0, 0)
if i%4 == 0 {
gl.Translatef(-((CardWidth + 2) * 4), -(CardHeight + 2), 0)
}
}
slot.card.Draw()
}
gl.PopMatrix()
}
开发者ID:Bunkerbewohner,项目名称:cardgame,代码行数:18,代码来源:playfield.go
示例19: drawBall
func drawBall(angle float32, ball_x float32, ball_y float32) {
gl.PushMatrix()
gl.Color3f(1, 1, 1)
gl.Translatef(ball_x, ball_y, 0.0)
gl.Begin(gl.LINE_LOOP)
for rad := 0.0; rad < 1.0; rad += 0.01 {
gl.Vertex2f(
float32(2.0*math.Cos(2.0*math.Pi*rad)),
float32(2.0*math.Sin(2.0*math.Pi*rad)+0.2))
}
gl.End()
gl.Rotatef(angle, 0.0, 0.0, 1.0)
gl.Begin(gl.LINE_STRIP)
gl.Vertex2f(0, 0)
gl.Vertex2f(2, 0)
gl.End()
gl.PopMatrix()
}
开发者ID:rick-monster,项目名称:gopong,代码行数:20,代码来源:view.go
示例20: drawBlock
func drawBlock(loc Loc, b *Block) {
// Save current modelview matrix on to the stack
gl.PushMatrix()
// Move block
gl.Translatef(loc.X, loc.Y, loc.Z)
// Rotate block
gl.Rotatef(b.Pitch, 1, 0, 0)
gl.Rotatef(b.Yaw, 0, 1, 0)
gl.Rotatef(b.Roll, 0, 0, 1)
// Start specifying the vertices of quads.
gl.Begin(gl.QUADS)
for _, quad := range b.Quads {
gl.Color3fv(quad.Color)
for _, vertex := range quad.Vertices {
gl.Vertex3fv(b.Vertices[vertex])
}
}
gl.End()
// Restore old modelview matrix
gl.PopMatrix()
}
开发者ID:srm88,项目名称:blocks,代码行数:21,代码来源:main.go
注:本文中的github.com/go-gl/gl.PopMatrix函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论