本文整理汇总了Golang中github.com/banthar/gl.Translated函数的典型用法代码示例。如果您正苦于以下问题:Golang Translated函数的具体用法?Golang Translated怎么用?Golang Translated使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Translated函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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()
}
示例2: Render
func (vbox vbox) Render(w, h, d float64) {
l := len(vbox.renderers)
dh := h / float64(l)
gl.Translated(0, h, 0)
for _, a := range vbox.renderers {
gl.Translated(0, -dh, 0)
a.Render(w, dh, d)
}
}
示例3: renderPortrait
func renderPortrait(r Renderer, w, h, d float64) {
gl.PushMatrix()
ww := h / math.Phi
if ww <= w {
gl.Translated((w-ww)/2.0, 0, 0)
r.Render(ww, h, d)
} else {
hh := w * math.Phi
gl.Translated(0, (h-hh)/2.0, 0)
r.Render(w, hh, d)
}
gl.PopMatrix()
}
示例4: renderLandscape
func renderLandscape(r Renderer, w, h, d float64) {
gl.PushMatrix()
hh := w / math.Phi
if hh <= h {
gl.Translated(0, (h-hh)/2.0, 0)
r.Render(w, hh, d)
} else {
ww := h * math.Phi
gl.Translated((w-ww)/2.0, 0, 0)
r.Render(ww, h, d)
}
gl.PopMatrix()
}
示例5: 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()
}
示例6: 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()
}
示例7: positionCamera
func positionCamera() {
gl.LoadIdentity()
x, y, z := player.Position()
gl.Translated(-x, -y+4, -z)
gl.Lightfv(gl.LIGHT1, gl.POSITION, []float32{float32(x), float32(y), float32(z) + 0.5, 1})
}
示例8: OpenWindow
// OpenWindow opens a new window with the given size.
func OpenWindow(w, h int) error {
glfw.OpenWindowHint(glfw.WindowNoResize, 1)
r, g, b := 0, 0, 0 // defaults
a := 8 // 8-bit alpha channel
d, s := 0, 0 // no depth or stencil buffers
m := glfw.Windowed
if err := glfw.OpenWindow(w, h, r, g, b, a, d, s, m); err != nil {
return err
}
if gl.Init() != 0 {
return errors.New("Failed to initialize OpenGL")
}
gl.Enable(gl.TEXTURE_2D)
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
gl.ClearColor(0.0, 0.0, 0.0, 0.0)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(0, float64(w), 0, float64(-h), -1, 1)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Translated(0, float64(-h), 0)
return nil
}
示例9: reshape
// Handle the window being resized.
func reshape(width int, height int) {
// Render into the entire window.
gl.Viewport(0, 0, width, height)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
// Configure the Frustrum so the front face of the rendering
// volume fills the screen.
w := float64(width)
h := float64(height)
depth := (w + h) / 2
near := depth / 2.0
right := w / 4.0
top := h / 4.0
far := 4 * depth
gl.Frustum(-right, right, -top, top, near, far)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
// Center the rendering volume in the viewport. Its origin
// is at the far lower left corner.
gl.Translated(-w/2, -h/2, -2*depth)
}
示例10: 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
}
}
}
示例11: 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()
glfw.SwapBuffers()
Frames++
{
t := glfw.Time()
if t-T0 >= 5 {
seconds := (t - T0)
fps := float64(Frames) / seconds
print(Frames, " frames in ", int(seconds), " seconds = ", int(fps), " FPS\n")
T0 = t
Frames = 0
}
}
}
示例12: drawCircle
func drawCircle(s CircleShape) {
center := s.Center()
radius := s.Radius()
angle := s.Body().Angle()
gl.VertexPointer(2, 0, circleVerts)
gl.PushMatrix()
gl.Translated(center.X, center.Y, 0.0)
gl.Rotated(angle*180.0/math.Pi, 0.0, 0.0, 1.0)
gl.Scaled(radius, radius, 1.0)
gl.DrawArrays(gl.LINE_STRIP, 0, len(circleVerts)/2)
gl.PopMatrix()
}
示例13: DrawItem
func (self *Inventory) DrawItem(t int64, quantity uint16, blockid uint16, r Rect) {
gl.PushMatrix()
gl.LoadIdentity()
const blocksize = float32(0.3)
i := 1
gl.Translated(r.x+r.sizex/2, r.y+r.sizey/2+4*PIXEL_SCALE, 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(blocksize, blocksize, blocksize)
gVertexBuffer.Reset()
TerrainCube(gVertexBuffer, Vectori{}, [18]uint16{}, blockid, FACE_NONE)
gVertexBuffer.RenderDirect(false)
gl.LoadIdentity()
gl.Translated(r.x+5*PIXEL_SCALE, r.y+2*PIXEL_SCALE, 0)
inventoryItemFont.Print(fmt.Sprintf("%d", quantity))
gl.PopMatrix()
}
示例14: plot_list
func plot_list(list uint) {
gl.Enable(gl.BLEND)
gl.Enable(gl.POINT_SMOOTH)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
gl.PointSize(1.0)
gl.LoadIdentity()
gl.Rotated(xrot, 1, 0, 0)
gl.Rotated(yrot, 0, 1, 0)
gl.Rotated(zrot, 0, 0, 1)
gl.Scaled(scale, scale, scale)
gl.Translated(xoff, yoff, zoff)
gl.CallList(list)
gl.Flush()
}
示例15: onResize
func onResize(w, h int) {
if h == 0 {
h = 1
}
gl.Viewport(0, 0, w, h)
scale := math.Min(float64(w)/640.0, float64(h)/480.0)
hw := float64(w) * (0.5 / scale)
hh := float64(h) * (0.5 / scale)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(-hw, hw, -hh, hh, -1.0, 1.0)
gl.Translated(0.5, 0.5, 0.0)
Width = w
Height = h
}