本文整理汇总了Golang中github.com/go-gl/gl.PopMatrix函数的典型用法代码示例。如果您正苦于以下问题:Golang PopMatrix函数的具体用法?Golang PopMatrix怎么用?Golang PopMatrix使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PopMatrix函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()
}
示例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()
}
示例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()
}
示例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
}
}
示例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()
}
}
示例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()
}
示例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()
}
}
示例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)
}
}
}
}
示例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()
}
示例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()
}
示例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()
}
示例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
}
}
}
示例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()
}
示例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()
}
示例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)
}