本文整理汇总了Golang中github.com/banthar/gl.PushMatrix函数的典型用法代码示例。如果您正苦于以下问题:Golang PushMatrix函数的具体用法?Golang PushMatrix怎么用?Golang PushMatrix使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PushMatrix函数的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: drawDigits
func drawDigits(x, y int, digits []int8) {
s := sdl.GetVideoSurface()
lft, rgt, btm, top := 0.0, float64(s.W), float64(s.H), 0.0
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
gl.MatrixMode(gl.PROJECTION)
gl.PushMatrix()
gl.LoadIdentity()
gl.Ortho(lft, rgt, btm, top, 0.0, 1.0)
gl.MatrixMode(gl.MODELVIEW)
gl.PushMatrix()
gl.LoadIdentity()
w := digitImages[0].Rect.Dx()
for i := 0; i < len(digits); i++ {
img := digitImages[digits[i]]
drawImage(x-w*i-i, y, img)
}
gl.MatrixMode(gl.MODELVIEW)
gl.PopMatrix()
gl.MatrixMode(gl.PROJECTION)
gl.PopMatrix()
}
示例3: Draw
func Draw() {
gl.Clear(gl.COLOR_BUFFER_BIT)
gl.PushMatrix()
defer gl.PopMatrix()
gl.Color4f(0, 1, 0, .5)
DrawCircle(vect.Vect{ScreenSize.X / 2, ScreenSize.Y / 2}, ScreenSize.Y/2.0-5.0, false)
if Settings.Paused {
gl.Color3f(1, 1, 1)
RenderFontAt("Paused", 20, 30)
}
//draw collision objects
gl.PushMatrix()
gl.Translated(ScreenSize.X/2, ScreenSize.Y/2, 0)
gl.Scaled(Settings.Scale, Settings.Scale, 1)
DrawDebugData(space)
gl.PopMatrix()
}
示例4: general_render
func general_render(s *list.List, c *camera) {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.PushMatrix()
//gl.Translatef(float32(c.X), float32(c.Y), float32(c.Z))
glu.LookAt(c.pos.X, c.pos.Y, c.pos.Z, c.front.X, c.front.Y, c.front.Z, c.top.X, c.top.Y, c.top.Z)
for e := s.Front(); e != nil; e = e.Next() {
gl.PushMatrix()
v := e.Value.(*sprite)
v.render()
gl.PopMatrix()
}
gl.PopMatrix()
}
示例5: Draw
func (self *Wolf) Draw(center Vectorf, selectedBlockFace *BlockFace) {
gl.PushMatrix()
gl.Translatef(float32(self.position[XAXIS]), float32(self.position[YAXIS]), float32(self.position[ZAXIS]))
gl.Rotated(self.Heading(), 0.0, 1.0, 0.0)
WolfModel.GLDraw()
gl.PopMatrix()
}
示例6: DrawItemSlot
func (self *Inventory) DrawItemSlot(t int64, r Rect) {
gl.PushMatrix()
gl.LoadIdentity()
gl.Color4ub(16, 16, 16, 255)
gl.Begin(gl.QUADS)
gl.Vertex2d(r.x, r.y)
gl.Vertex2d(r.x+r.sizex, r.y)
gl.Vertex2d(r.x+r.sizex, r.y+r.sizey)
gl.Vertex2d(r.x, r.y+r.sizey)
gl.End()
gl.Color4ub(6, 6, 6, 255)
gl.Begin(gl.LINES)
gl.Vertex2d(r.x, r.y)
gl.Vertex2d(r.x+r.sizex, r.y)
gl.Vertex2d(r.x, r.y)
gl.Vertex2d(r.x, r.y+r.sizey)
gl.End()
gl.Color4ub(64, 64, 64, 255)
gl.Begin(gl.LINES)
gl.Vertex2d(r.x+r.sizex, r.y)
gl.Vertex2d(r.x+r.sizex, r.y+r.sizey)
gl.Vertex2d(r.x, r.y+r.sizey)
gl.Vertex2d(r.x+r.sizex, r.y+r.sizey)
gl.End()
gl.PopMatrix()
}
示例7: Render
func (x spinner) Render(w, h, d float64) {
gl.PushMatrix()
t := time.Now().Sub(x.start).Seconds()
gl.Rotated(120*surge(t), w, h, d)
x.child.Render(w, h, d)
gl.PopMatrix()
}
示例8: Draw
func (self *Pause) Draw(t int64) {
gl.MatrixMode(gl.MODELVIEW)
gl.PushMatrix()
gl.LoadIdentity()
gl.Disable(gl.DEPTH_TEST)
gl.Disable(gl.LIGHTING)
gl.Disable(gl.LIGHT0)
gl.Disable(gl.LIGHT1)
gl.Color4ub(0, 0, 0, 240)
gl.Begin(gl.QUADS)
gl.Vertex2f(float32(viewport.lplane), float32(viewport.bplane))
gl.Vertex2f(float32(viewport.rplane), float32(viewport.bplane))
gl.Vertex2f(float32(viewport.rplane), float32(viewport.tplane))
gl.Vertex2f(float32(viewport.lplane), float32(viewport.tplane))
gl.End()
str := "paused"
h, w := pauseFont.Measure(str)
// x := (viewport.rplane - viewport.lplane - w) / 2
// y := (viewport.tplane - viewport.bplane - h) / 2
gl.Translated(-w/2, -h/2, 0)
pauseFont.Print(str)
gl.PopMatrix()
}
示例9: DrawPlayerItems
func (self *Picker) DrawPlayerItems(t int64) {
gl.PushMatrix()
gl.LoadIdentity()
for i := 0; i < 5; i++ {
item := ThePlayer.equippedItems[i]
if item != ITEM_NONE {
angle := -(float64(i) + 1.5) * math.Pi / 4
gl.LoadIdentity()
x := self.x - self.actionItemRadius*float32(math.Sin(angle))
y := self.y + self.actionItemRadius*float32(math.Cos(angle))
gl.Translatef(x, y, 0)
gl.Rotatef(360*float32(math.Sin(float64(t)/1e10+float64(i))), 1.0, 0.0, 0.0)
gl.Rotatef(360*float32(math.Cos(float64(t)/1e10+float64(i))), 0.0, 1.0, 0.0)
gl.Rotatef(360*float32(math.Sin(float64(t)/1e10+float64(i))), 0.0, 0.0, 1.0)
gl.Scalef(blockscale, blockscale, blockscale)
gVertexBuffer.Reset()
TerrainCube(gVertexBuffer, 0, 0, 0, [18]uint16{}, item, FACE_NONE)
gVertexBuffer.RenderDirect(false)
gl.LoadIdentity()
gl.Translatef(x-17*PIXEL_SCALE, y-19*PIXEL_SCALE, 20)
consoleFont.Print(fmt.Sprintf("%d", ThePlayer.inventory[item]))
}
}
gl.PopMatrix()
}
示例10: Draw
func (self *Picker) Draw(t int64) {
gl.MatrixMode(gl.MODELVIEW)
gl.PushMatrix()
gl.LoadIdentity()
gl.Disable(gl.DEPTH_TEST)
gl.Disable(gl.LIGHTING)
gl.Disable(gl.LIGHT0)
gl.Disable(gl.LIGHT1)
gl.Begin(gl.TRIANGLE_FAN)
gl.Color4ub(0, 0, 0, 128)
gl.Vertex2f(self.x, self.y)
for angle := float64(0); angle <= 2*math.Pi; angle += math.Pi / 2 / 10 {
gl.Vertex2f(self.x-float32(math.Sin(angle))*self.radius, self.y+float32(math.Cos(angle))*self.radius)
}
gl.End()
self.DrawItemHighlight(t, ThePlayer.currentAction)
self.DrawPlayerItems(t, true)
gl.PopMatrix()
}
示例11: DrawItem
func (self *Inventory) DrawItem(t int64, quantity uint16, itemid ItemId, x float64, y float64) {
gl.PushMatrix()
gl.LoadIdentity()
// angle := -90.0
const blocksize = float32(0.3)
gl.Translated(x, y, 0)
//gl.Rotated(angle, 1.0, 0.0, 0.0)
gl.Rotated(90, 1.0, 0.0, 0.0)
gl.Rotated(30*math.Sin(float64(t)/1e9+float64(itemid)/2), 0.0, 1.0, 0.0)
gl.Scalef(blocksize, blocksize, blocksize)
self.drawBuffer.Reset()
if itemid < 256 {
TerrainCube(self.drawBuffer, Vectori{}, [18]BlockId{BLOCK_DIRT, BLOCK_DIRT, BLOCK_DIRT, BLOCK_DIRT, BLOCK_AIR, BLOCK_DIRT, BLOCK_AIR, BLOCK_AIR, BLOCK_AIR, BLOCK_AIR, BLOCK_AIR, BLOCK_AIR, BLOCK_AIR, BLOCK_AIR, BLOCK_AIR, BLOCK_AIR, BLOCK_AIR}, NewBlockDefault(BlockId(itemid)), FACE_NONE)
} else {
RenderItemFlat(self.drawBuffer, Vectori{}, BlockId(itemid))
}
self.drawBuffer.RenderDirect(false)
gl.LoadIdentity()
gl.Translated(x+2*PIXEL_SCALE-48*PIXEL_SCALE*float64(blocksize), y-7*PIXEL_SCALE-48*PIXEL_SCALE*float64(blocksize), 0)
inventoryItemFont.Print(fmt.Sprintf("%d", quantity))
gl.PopMatrix()
}
示例12: drawShip
func drawShip(angle float32) {
gl.PushMatrix()
gl.Translatef(x, y, 0.0)
gl.Rotatef(angle, 0.0, 0.0, 1.0)
if thrust {
gl.Color3f(1.0, 0.0, 0.0)
gl.Begin(gl.LINE_STRIP)
gl.Vertex2f(-0.75, -0.5)
gl.Vertex2f(-1.75, 0)
gl.Vertex2f(-0.75, 0.5)
gl.End()
}
gl.Color3f(1.0, 1.0, 0.0)
gl.Begin(gl.LINE_LOOP)
gl.Vertex2f(2.0, 0.0)
gl.Vertex2f(-1.0, -1.0)
gl.Vertex2f(-0.5, 0.0)
gl.Vertex2f(-1.0, 1.0)
gl.Vertex2f(2.0, 0.0)
gl.End()
if shield {
gl.Color3f(0.1, 0.1, 1.0)
gl.Begin(gl.LINE_LOOP)
for rad := 0.0; rad < 12.0; rad += 1.0 {
gl.Vertex2f(
float32(2.3*math.Cos(2*float64(rad)/math.Pi)+0.2),
float32(2.0*math.Sin(2*float64(rad)/math.Pi)))
}
gl.End()
}
gl.PopMatrix()
}
示例13: 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()
}
示例14: RenderFontAt
func RenderFontAt(text string, x, y float64) {
gl.PushMatrix()
gl.RasterPos2d(x, y)
Font.Render(text)
gl.PopMatrix()
}
示例15: Draw
func (self *Console) Draw(t int64) {
gl.MatrixMode(gl.MODELVIEW)
gl.PushMatrix()
gl.LoadIdentity()
gl.Disable(gl.DEPTH_TEST)
gl.Disable(gl.LIGHTING)
gl.Disable(gl.LIGHT0)
gl.Disable(gl.LIGHT1)
h := float32(consoleFont.height) * PIXEL_SCALE
margin := float32(3.0) * PIXEL_SCALE
consoleHeight := 3 * h
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Color4ub(0, 0, 0, 208)
gl.Begin(gl.QUADS)
gl.Vertex2f(float32(viewport.lplane), float32(viewport.bplane)+consoleHeight+margin*2) // Bottom Left Of The Texture and Quad
gl.Vertex2f(float32(viewport.rplane), float32(viewport.bplane)+consoleHeight+margin*2) // Bottom Right Of The Texture and Quad
gl.Vertex2f(float32(viewport.rplane), float32(viewport.bplane)) // Top Right Of The Texture and Quad
gl.Vertex2f(float32(viewport.lplane), float32(viewport.bplane)) // Top Left Of The Texture and Quad
gl.End()
gl.Translatef(float32(viewport.lplane)+margin, float32(viewport.bplane)+consoleHeight+margin-h, 0)
consoleFont.Print(fmt.Sprintf("FPS: %5.2f V: %d (%d) CH: %d M: %d", self.fps, self.vertices, self.culledVertices, len(TheWorld.chunks), len(TheWorld.mobs)))
gl.LoadIdentity()
gl.Translatef(float32(viewport.lplane)+margin, float32(viewport.bplane)+consoleHeight+margin-2*h, 0)
consoleFont.Print(fmt.Sprintf("X: %5.2f Y: %4.2f Z: %5.2f H: %5.2f (%s) D: %0.1f (%d)", ThePlayer.position[XAXIS], ThePlayer.position[YAXIS], ThePlayer.position[ZAXIS], ThePlayer.heading, HeadingToCompass(ThePlayer.heading), ThePlayer.distanceTravelled, ThePlayer.distanceFromStart))
gl.LoadIdentity()
gl.Translatef(float32(viewport.lplane)+margin, float32(viewport.bplane)+consoleHeight+margin-3*h, 0)
numgc := uint32(0)
avggc := float64(0)
var last3 [3]float64
if self.mem.NumGC > 3 {
numgc = self.mem.NumGC
avggc = float64(self.mem.PauseTotalNs) / float64(self.mem.NumGC) / 1e6
index := int(numgc) - 1
if index > 255 {
index = 255
}
last3[0] = float64(self.mem.PauseNs[index]) / 1e6
last3[1] = float64(self.mem.PauseNs[index-1]) / 1e6
last3[2] = float64(self.mem.PauseNs[index-2]) / 1e6
}
consoleFont.Print(fmt.Sprintf("Mem: %.1f/%.1f GC: %.1fms [%d: %.1f, %.1f, %.1f] ChGen: %.1fms | Sc: %.1f TOD: %.1f", float64(self.mem.Alloc)/(1024*1024), float64(self.mem.Sys)/(1024*1024), avggc, numgc, last3[0], last3[1], last3[2], float64(self.chunkGenerationTime)/1e6, viewport.scale, timeOfDay))
gl.PopMatrix()
}