本文整理汇总了Golang中github.com/go-gl/gl.Translated函数的典型用法代码示例。如果您正苦于以下问题:Golang Translated函数的具体用法?Golang Translated怎么用?Golang Translated使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Translated函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: 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
示例2: Render
func (p *Planetoid) Render(dp float64) {
glh.With(glh.Matrix{gl.MODELVIEW}, func() {
gl.Rotated(p.rising_node, 0, 1, 0)
gl.Rotated(p.inclination, 0, 0, 1)
gl.Rotated(p.phase0+p.phase, 0, 1, 0)
p.phase += dp*10 + (1 - p.apogee)
glh.With(glh.Matrix{gl.MODELVIEW}, func() {
// TODO: Compute position correctly
gl.Translated(p.apogee, 0, 0)
Sphere(p.radius, 3)
})
// TODO: Avoid depth thrashing when trails overlap
// Trail
glh.With(glh.Matrix{gl.MODELVIEW}, func() {
gl.Rotated(90, 1, 0, 0)
gl.Scaled(p.apogee, p.apogee, 1)
gl.LineWidth(2)
glh.With(glh.Disable(gl.LIGHTING), func() {
p.circle.Render(gl.LINE_STRIP)
})
})
})
}
开发者ID:pwaller,项目名称:debris,代码行数:28,代码来源:main.go
示例3: 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
示例4: 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
示例5: reshape
// new window size
func reshape(window *glfw.Window, width, height int) {
gl.Viewport(0, 0, width, height)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Frustum(-1.0, 1.0, -1.0, 1.0, 1, 20)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Translated(0.0, 0.0, -20.0)
}
开发者ID:nzlov,项目名称:gogl,代码行数:11,代码来源:06.go
示例6: 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
示例7: 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
示例8: reshape
// new window size
func reshape(window *glfw.Window, width, height int) {
h := float64(height) / float64(width)
znear := 5.0
zfar := 30.0
xmax := znear * 0.5
gl.Viewport(0, 0, width, height)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Frustum(-xmax, xmax, -xmax*h, xmax*h, znear, zfar)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Translated(0.0, 0.0, -20.0)
}
开发者ID:nzlov,项目名称:gogl,代码行数:16,代码来源:04.go
示例9: TestWindowCoordsA
// Draw a test pattern
func TestWindowCoordsA(t *testing.T) {
gltest.OnTheMainThread(func() {
gltest.SetWindowSize(40, 5)
w, h := GetViewportWH()
With(WindowCoords{}, func() {
// So that we draw in the middle of the pixel
gl.Translated(0.5, 0.5, 0)
gl.Color4f(1, 1, 1, 1)
With(Primitive{gl.POINTS}, func() {
for i := 0; i < w+1; i += 2 {
gl.Vertex2i(i, h/2)
}
})
})
}, func() {
CaptureToPng("TestWindowCoordsA.png")
})
}
开发者ID:pwaller,项目名称:glh,代码行数:21,代码来源:glh_test.go
示例10: renderDashboard
func renderDashboard() {
gl.LoadIdentity()
setColor(Blue)
fonts[32].Printf(float32(XMin), float32(WindowHeight-DashboardHeight),
"Level %d", g.currentLevel)
gl.Translatef(float32(XMin)+300, float32(WindowHeight-DashboardHeight), 0)
line := 0
for _, c := range g.level.winSignature {
if c == '\n' {
line++
gl.LoadIdentity()
gl.Translatef(float32(XMin)+300, float32(WindowHeight-DashboardHeight+SignatureBlockSize*line+BlockPadding), 0)
continue
}
if c != '-' {
renderBlockSignature(atoc(string(c)))
}
gl.Translated(SignatureBlockSize+BlockPadding, 0, 0)
}
}
开发者ID:remogatto,项目名称:mozaik,代码行数:20,代码来源:main_init.go
示例11: RenderShadowVolume
func (p *Planetoid) RenderShadowVolume() {
glh.With(glh.Matrix{gl.MODELVIEW}, func() {
// gl.Rotated(90, 0, 1, 0)
gl.Rotated(p.rising_node, 0, 1, 0)
gl.Rotated(p.inclination, 0, 0, 1)
gl.Rotated(p.phase0+p.phase, 0, 1, 0)
// TODO: Compute position correctly
gl.Translated(p.apogee, 0, 0)
gl.Rotated(p.phase0+p.phase, 0, -1, 0)
gl.Rotated(p.inclination, 0, 0, -1)
gl.Rotated(p.rising_node, 0, -1, 0)
// gl.Rotated(p.phase0+p.phase, 0, -1, 0)
gl.Rotated(90, 0, -1, 0)
glu.Cylinder(quadric, p.radius, p.radius, 2, 10, 1)
})
}
开发者ID:pwaller,项目名称:debris,代码行数:23,代码来源:main.go
示例12: Draw
func (block *Block) Draw(start, N int64, detailed bool) {
if block.tex == nil {
block.RequestTexture()
}
switch detailed {
case true:
block.detail_needed = true
if block.vertex_data == nil {
// Hey, we need vertices but don't have them! Let's fix that..
block.RequestVertices()
}
default:
block.detail_needed = false
}
width := uint64(len(block.display_active_pages)) * *PAGE_SIZE
if width == 0 {
width = 1
}
vc := glh.NewMeshBuffer(glh.RenderArrays,
glh.NewPositionAttr(2, gl.FLOAT, gl.STATIC_DRAW),
glh.NewPositionAttr(4, gl.UNSIGNED_INT, gl.STATIC_DRAW),
)
colors := make([]int32, 0)
positions := make([]float32, 0)
// var vc glh.ColorVertices
if *pageboundaries {
// boundary_color := color.RGBA{64, 64, 64, 255}
// If we try and draw too many of these, X will hang
if width / *PAGE_SIZE < 10000 {
for p := uint64(0); p <= width; p += *PAGE_SIZE {
x := float32(p) / float32(width)
x = (x - 0.5) * 4
colors = append(colors, 64, 64, 64, 255)
positions = append(positions, x, float32(N))
// vc.Add(glh.ColorVertex{boundary_color, glh.Vertex{x, 0}})
// vc.Add(glh.ColorVertex{boundary_color, glh.Vertex{x, float32(N)}})
}
}
}
var border_color [4]float64
gl.LineWidth(1)
glh.With(&Timer{Name: "DrawPartial"}, func() {
var x1, y1, x2, y2 float64
glh.With(glh.Matrix{gl.MODELVIEW}, func() {
// TODO: A little less co-ordinate insanity?
gl.Translated(0, -2, 0)
gl.Scaled(1, 4/float64(*nback), 1)
gl.Translated(0, -float64(start), 0)
x1, y1 = glh.ProjToWindow(-2, 0)
x2, y2 = glh.ProjToWindow(-2+WIDTH, float64(N))
})
border_color = [4]float64{1, 1, 1, 1}
glh.With(glh.Matrix{gl.MODELVIEW}, func() {
gl.Translated(0, -2, 0)
gl.Scaled(1, 4/float64(*nback), 1)
gl.Translated(0, -float64(start), 0)
// Page boundaries
// TODO: Use different blending scheme on textured quads so that the
// lines show through
glh.With(glh.Attrib{gl.ENABLE_BIT}, func() {
gl.Disable(gl.LINE_SMOOTH)
// vc.Draw(gl.LINES)
vc.Render(gl.LINES)
})
})
if block.tex != nil && (!detailed || block.vertex_data == nil) {
border_color = [4]float64{0, 0, 1, 1}
glh.With(glh.WindowCoords{Invert: true}, func() {
gl.Color4f(1, 1, 1, 1)
// Render textured block quad
glh.With(block.tex, func() {
glh.DrawQuadd(x1, y1, x2-x1, y2-y1)
})
glh.With(glh.Primitive{gl.LINES}, func() {
glh.Squared(x1, y1, x2-x1, y2-y1)
})
})
if block.vertex_data != nil && !block.detail_needed {
// TODO: figure out when we can unload
// Hey, we can unload you, because you are not needed
block.vertex_data = nil
}
}
//.........这里部分代码省略.........
开发者ID:pwaller,项目名称:mema,代码行数:101,代码来源:block.go
示例13: BuildTexture
func (block *Block) BuildTexture() {
block.tex = glh.NewTexture(1024, 256)
block.tex.Init()
// TODO: use runtime.SetFinalizer() to clean up/delete the texture?
glh.With(block.tex, func() {
//gl.TexParameteri(gl.TEXTURE_2D, gl.GENERATE_MIPMAP, gl.TRUE)
//gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR)
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST_MIPMAP_NEAREST)
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST)
// TODO: Only try and activate anisotropic filtering if it is available
gl.TexParameterf(gl.TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, MaxAnisotropy)
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAX_LEVEL, 1)
})
for i := 0; i < 2; i++ {
glh.With(&glh.Framebuffer{Texture: block.tex, Level: i}, func() {
glh.With(glh.Attrib{gl.COLOR_BUFFER_BIT}, func() {
gl.ClearColor(1, 0, 0, 0)
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
})
viewport_proj := glh.Compound(glh.Attrib{gl.VIEWPORT_BIT},
glh.Matrix{gl.PROJECTION})
glh.With(viewport_proj, func() {
gl.Viewport(0, 0, block.tex.W/(1<<uint(i)), block.tex.H/(1<<uint(i)))
gl.LoadIdentity()
//gl.Ortho(0, float64(tex.w), 0, float64(tex.h), -1, 1)
gl.Ortho(-2, -2+WIDTH, 2, -2, -1, 1)
glh.With(glh.Matrix{gl.MODELVIEW}, func() {
gl.LoadIdentity()
//gl.Hint(gl.LINES, gl.NICEST)
//gl.LineWidth(4)
/*
glh.With(glh.Primitive{gl.LINES}, func() {
gl.Color4f(1, 1, 1, 1)
gl.Vertex2f(-2, 0)
gl.Vertex2f(2, 0)
})
*/
gl.PointSize(4)
glh.With(glh.Matrix{gl.MODELVIEW}, func() {
gl.Translated(0, -2, 0)
gl.Scaled(1, 4/float64(block.nrecords), 1)
block.vertex_data.Render(gl.POINTS)
})
/*
gl.Color4f(0.5, 0.5, 1, 1)
With(Primitive{gl.LINE_LOOP}, func() {
b := 0.2
Squared(-2.1+b, -2.1+b, 4.35-b*2, 4.2-b*2)
})
*/
})
})
})
}
//block.img = block.tex.AsImage()
if !block.detail_needed {
block.vertex_data = nil
runtime.GC()
}
blocks_rendered++
}
开发者ID:pwaller,项目名称:mema,代码行数:74,代码来源:block.go
示例14: main
func main() {
sdl.Init(sdl.INIT_VIDEO)
var screen = sdl.SetVideoMode(640, 480, 32, sdl.OPENGL)
if screen == nil {
panic("sdl error")
}
if gl.Init() != 0 {
panic("gl error")
}
gl.MatrixMode(gl.PROJECTION)
gl.Viewport(0, 0, int(screen.W), int(screen.H))
gl.LoadIdentity()
gl.Ortho(-5, 5, -2.5, 2.5, -1.0, 1.0)
gl.ClearColor(0, 0, 0, 0)
gl.Clear(gl.COLOR_BUFFER_BIT)
gl.PolygonMode(gl.FRONT_AND_BACK, gl.LINE)
tess := glu.NewTess()
tess.SetBeginCallback(tessBeginHandler)
tess.SetVertexCallback(tessVertexHandler)
tess.SetEndCallback(tessEndHandler)
tess.SetErrorCallback(tessErrorHandler)
tess.SetEdgeFlagCallback(tessEdgeFlagHandler)
tess.SetCombineCallback(tessCombineHandler)
tess.Normal(0, 0, 1)
var running = true
for running {
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Translated(-2.5, 0, 0)
tess.BeginPolygon(nil)
tess.BeginContour()
for v := range OuterContour {
tess.Vertex(OuterContour[v], &OuterContour[v])
}
tess.EndContour()
tess.BeginContour()
for v := range InnerContour {
tess.Vertex(InnerContour[v], &InnerContour[v])
}
tess.EndContour()
tess.EndPolygon()
gl.Translated(5, 0, 0)
tess.BeginPolygon(nil)
tess.BeginContour()
for v := range StarContour {
tess.Vertex(StarContour[v], &StarContour[v])
}
tess.EndContour()
tess.EndPolygon()
sdl.GL_SwapBuffers()
sdl.Delay(25)
}
tess.Delete()
sdl.Quit()
}
开发者ID:0xfaded,项目名称:glu,代码行数:81,代码来源:tess.go
示例15: main
//.........这里部分代码省略.........
glh.With(glh.Attrib{
gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.ENABLE_BIT |
gl.POLYGON_BIT | gl.STENCIL_BUFFER_BIT,
}, func() {
gl.Disable(gl.LIGHTING)
if shadowing {
// gl.Disable(gl.DEPTH_TEST)
gl.DepthMask(false)
gl.DepthFunc(gl.LEQUAL)
gl.Enable(gl.STENCIL_TEST)
gl.ColorMask(false, false, false, false)
gl.StencilFunc(gl.ALWAYS, 1, 0xffffffff)
}
shadow_volume := func() {
const sv_length = 2
const sv_granularity = 100
const sv_radius = earth_radius * 1.001
// Shadow cone
glh.With(glh.Matrix{gl.MODELVIEW}, func() {
gl.Rotatef(90, 1, 0, 0)
gl.Rotatef(90, 0, -1, 0)
gl.Color4f(0.5, 0.5, 0.5, 1)
glu.Cylinder(quadric, sv_radius, sv_radius*1.05,
sv_length, sv_granularity, 1)
glu.Disk(quadric, 0, sv_radius, sv_granularity, 1)
glh.With(glh.Matrix{gl.MODELVIEW}, func() {
gl.Translated(0, 0, sv_length)
glu.Disk(quadric, 0, sv_radius*1.05, sv_granularity, 1)
})
})
for _, p := range planetoids {
p.RenderShadowVolume()
}
}
if cone {
gl.FrontFace(gl.CCW)
gl.StencilOp(gl.KEEP, gl.KEEP, gl.INCR)
shadow_volume()
gl.FrontFace(gl.CW)
gl.StencilOp(gl.KEEP, gl.KEEP, gl.DECR)
shadow_volume()
}
if shadowing {
gl.StencilFunc(gl.NOTEQUAL, 0, 0xffffffff)
gl.StencilOp(gl.KEEP, gl.KEEP, gl.KEEP)
gl.ColorMask(true, true, true, true)
// gl.Disable(gl.STENCIL_TEST)
gl.Disable(gl.DEPTH_TEST)
gl.FrontFace(gl.CCW)
开发者ID:pwaller,项目名称:debris,代码行数:67,代码来源:main.go
示例16: InitStatsHUD
func InitStatsHUD() {
plots := chart.ScatterChart{Title: "", Options: glchart.DarkStyle}
start := time.Now()
l := float64(start.UnixNano())
r := float64(start.Add(2 * time.Second).UnixNano())
plots.XRange.Fixed(l, r, 1e9)
plots.YRange.Fixed(0.1, 100, 10)
plots.XRange.TicSetting.Tics, plots.YRange.TicSetting.Tics = 1, 1
plots.XRange.TicSetting.Mirror, plots.YRange.TicSetting.Mirror = 2, 2
plots.XRange.TicSetting.Grid, plots.YRange.TicSetting.Grid = 2, 2
plots.YRange.ShowZero = true
//plots.XRange.Log = true
//plots.YRange.Log = true
plots.Key.Pos, plots.Key.Cols = "obc", 3
plots.XRange.TicSetting.Format = func(f float64) string {
t := time.Unix(int64(f)/1e9, int64(f)%1e9)
return fmt.Sprintf("%.3v", time.Since(t))
}
memhelper.GetMaxRSS()
var gpufree float64
gpupoll := gpuinfo.PollGPUMemory()
go func() {
for gpustatus := range gpupoll {
gpufree = float64(memhelper.ByteSize(gpustatus.Free()) * memhelper.MiB)
}
}()
statistics := &Statistics{}
statistics.Add(&plots, "GPU Free", "#FF9F00", func() float64 { return gpufree })
statistics.Add(&plots, "SpareRAM()", "#ff0000", func() float64 { return float64(SpareRAM() * 1e6) })
statistics.Add(&plots, "MaxRSS", "#FFE240", func() float64 { return float64(memhelper.GetMaxRSS()) })
statistics.Add(&plots, "Heap Idle", "#33ff33", func() float64 { return float64(memstats.HeapIdle) })
statistics.Add(&plots, "Alloc", "#FF6600", func() float64 { return float64(memstats.Alloc) })
statistics.Add(&plots, "Heap Alloc", "#006699", func() float64 { return float64(memstats.HeapAlloc) })
statistics.Add(&plots, "Sys", "#996699", func() float64 { return float64(memstats.Sys) })
statistics.Add(&plots, "System Free", "#3333ff", func() float64 { return float64(SystemFree()) })
statistics.Add(&plots, "nBlocks x 1e6", "#FFCC00", func() float64 { return float64(nblocks * 1e6) })
statistics.Add(&plots, "nDrawn x 1e6", "#9C8AA5", func() float64 { return float64(blocks_rendered * 1e6) })
go func() {
top := 0.
i := -1
for {
time.Sleep(250 * time.Millisecond)
max := statistics.Update()
if max > top {
top = max
}
i++
if i%4 != 0 {
continue
}
segment := float64(1e9)
if time.Since(start) > 10*time.Second {
segment = 5e9
}
if time.Since(start) > 1*time.Minute {
segment = 30e9
}
// Update axis limits
nr := float64(time.Now().Add(2 * time.Second).UnixNano())
plots.XRange.Fixed(l, nr, segment)
plots.YRange.Fixed(-1e9, top*1.1, 500e6)
}
}()
const pw, ph = 640, 480
scalex, scaley := 0.4, 0.5
chart_gfxcontext := glchart.New(pw, ph, "", 10, color.RGBA{})
StatsHUD = func() {
glh.With(glh.Matrix{gl.PROJECTION}, func() {
gl.LoadIdentity()
gl.Translated(1-scalex, scaley-1, 0)
gl.Scaled(scalex, scaley, 1)
gl.Ortho(0, pw, ph, 0, -1, 1)
gl.Translated(0, -50, 0)
glh.With(glh.Attrib{gl.ENABLE_BIT}, func() {
gl.Disable(gl.DEPTH_TEST)
glh.With(&Timer{Name: "Chart"}, func() {
plots.Plot(chart_gfxcontext)
})
})
})
//.........这里部分代码省略.........
开发者ID:pwaller,项目名称:mema,代码行数:101,代码来源:statshud.go
示例17: main_loop
//.........这里部分代码省略.........
px, py := glh.WindowToProj(x, y)
// Record index
rec = int64((py+2)*float64(*nback)/4. + 0.5)
rec_actual = rec + i
dpy := py - mousepy
di := int64(-dpy * float64(*nback) / 4.)
if lbutton {
i += di
}
mousepx, mousepy = px, py
mousex, mousey = x, y
//log.Printf("Mouse motion: (%3d, %3d), (%f, %f), (%d, %d) dpy=%f di=%d",
//x, y, px, py, rec, rec_actual, dpy, di)
update_text()
})
glfw.SetKeyCallback(func(key, state int) {
switch key {
case glfw.KeyEsc:
escape_hit = true
}
})
draw_mousepoint := func() {
// Draw the mouse point
glh.With(glh.Matrix{gl.MODELVIEW}, func() {
gl.Translated(0, -2, 0)
gl.Scaled(1, 4/float64(*nback), 1)
gl.Translated(0, float64(rec), 0)
gl.PointSize(10)
glh.With(glh.Primitive{gl.POINTS}, func() {
gl.Color4f(1, 1, 1, 1)
gl.Vertex3d(mousepx, 0, 0)
})
})
}
draw_text := func() {
// Draw any text
glh.With(glh.WindowCoords{}, func() {
w, h := glh.GetViewportWHD()
glh.With(glh.Attrib{gl.ENABLE_BIT}, func() {
gl.Enable(gl.TEXTURE_2D)
// text.Draw(0, 0)
for text_idx := range stacktext {
stacktext[text_idx].Draw(int(w*0.55), int(h)-35-text_idx*16)
}
for text_idx := range dwarftext {
dwarftext[text_idx].Draw(int(w*0.55), 35+text_idx*16)
}
if recordtext != nil {
recordtext.Draw(int(w*0.55), 35)
}
})
})
}
开发者ID:pwaller,项目名称:mema,代码行数:66,代码来源:main.go
示例18: TestWindowCoords
// Draw a test pattern
func TestWindowCoords(t *testing.T) {
gltest.OnTheMainThread(func() {
gltest.SetWindowSize(40, 40)
w, h := GetViewportWH()
With(WindowCoords{}, func() {
// So that we draw in the middle of the pixel
gl.Translated(0.5, 0.5, 0)
// Draw stripes
stride := 1
internal_n := 4
for b := 0; b < w/2-internal_n*stride; b += stride {
if b/stride%2 == 0 {
gl.Color4f(1, 1, 1, 1)
} else {
gl.Color4f(1, 0, 0, 1)
}
With(Primitive{gl.LINE_LOOP}, func() {
gl.Vertex2i(b, b)
gl.Vertex2i(w-b, b)
gl.Vertex2i(w-b, h-b)
gl.Vertex2i(b, h-b)
})
}
// Central white, green, blue checked pattern
gl.PointSize(2)
With(Primitive{gl.POINTS}, func() {
gl.Color4f(1, 1, 1, 1)
gl.Vertex2i(w/2-2, h/2-2)
gl.Vertex2i(w/2+2, h/2+2)
gl.Color4f(0, 1, 0, 1)
gl.Vertex2i(w/2+2, h/2-2)
gl.Vertex2i(w/2-2, h/2+2)
gl.Color4f(1, 1, 1, 1)
gl.Vertex2i(w/2, h/2)
})
// Blue horizontal line to show
With(Primitive{gl.LINE_LOOP}, func() {
gl.Color4f(0, 0, 1, 1)
gl.Vertex2i(0, h/2-4)
gl.Vertex2i(w, h/2-4)
gl.Vertex2i(w/2-4, 0)
gl.Vertex2i(w/2-4, h)
})
// Remove some pixels near the boundaries
gl.PointSize(1)
gl.Color4f(0, 0, 0, 1)
With(Primitive{gl.POINTS}, func() {
// Black dot in top left
gl.Vertex2i(0, 0)
// Off the top right (should not be visible)
gl.Vertex2i(w, 0)
// Bottom left pixel (should be visible as a black dot)
gl.Vertex2i(0, h-1)
})
})
}, func() {
CaptureToPng("TestWindowCoords.png")
})
}
开发者ID:pwaller,项目名称:glh,代码行数:68,代码来源:glh_test.go
注:本文中的github.com/go-gl/gl.Translated函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论