本文整理汇总了Golang中github.com/go-gl/gl/v2/1/gl.Translatef函数的典型用法代码示例。如果您正苦于以下问题:Golang Translatef函数的具体用法?Golang Translatef怎么用?Golang Translatef使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Translatef函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: draw
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()
//Transform screen to keep player in middle. Added intentation to make obvious the push matrix is like a block
gl.PushMatrix()
// gl.Translatef((1280/2)-float32(player.x), 0, 0.0)
// gl.Begin(gl.LINES)
// gl.Color3f(.2, .5, .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(player.color_r, player.color_g, player.color_b, player.color_a)
//Draw Player
gl.PushMatrix()
rot := player.rot
pos_x := player.x
pos_y := player.y
gl.Translatef(pos_x, pos_y, 0.0)
gl.Rotatef(float32(rot), 0, 0, 1)
drawCircle(float64(BALL_RADIUS), 20)
gl.PopMatrix()
//Draw the grapple
gl.PushMatrix()
gl.Translatef(player.hook.x_end, player.hook.y_end, 0.0)
drawCircle(float64(5), 5)
gl.PopMatrix()
//Grapple Line
gl.LineWidth(2.5)
gl.Color3f(1.0, 0.0, 0.0)
gl.Begin(gl.LINES)
gl.Vertex3f(player.x, player.y, 0.0)
gl.Vertex3f(player.hook.x_end, player.hook.y_end, 0)
gl.End()
//Second Pop
gl.PopMatrix()
}
开发者ID:jhautefeuille,项目名称:hellochipmunk,代码行数:54,代码来源:glfwtest.go
示例2: 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()
player := game.Player
//Transform screen.
gl.PushMatrix()
gl.Translatef((1280/2)-float32((player.Body.Position().X)), 0, 0.0)
gl.Begin(gl.LINES)
gl.Color3f(.2, .5, .2)
for _, segment := range game.Level.GetChipmunkSegments() {
x := segment.GetAsSegment().A.X
y := segment.GetAsSegment().A.Y
gl.Vertex3f(float32(x), float32(y), 0)
x = segment.GetAsSegment().B.X
y = segment.GetAsSegment().B.Y
gl.Vertex3f(float32(x), float32(y), 0)
}
gl.End()
gl.Color4f(.9, .1, 1, .9)
// draw balls
for _, enemy := range game.Enemies {
gl.PushMatrix()
pos := enemy.Body.Position()
rot := enemy.Body.Angle() * game.DegreeConst
gl.Translatef(float32(pos.X), float32(pos.Y), 0.0)
gl.Rotatef(float32(rot), 0, 0, 1)
drawCircle(float64(enemy.Radius), 60)
gl.PopMatrix()
}
gl.Color4f(.3, .3, 1, .8)
//Draw Player
gl.PushMatrix()
pos := player.Body.Position()
rot := player.Body.Angle() * game.DegreeConst
gl.Translatef(float32(pos.X), float32(pos.Y), 0.0)
gl.Rotatef(float32(rot), 0, 0, 1)
drawCircle(float64(player.Radius), 60)
gl.PopMatrix()
gl.PopMatrix()
}
开发者ID:jhautefeuille,项目名称:hellochipmunk,代码行数:50,代码来源:main.go
示例3: drawSpinner
func drawSpinner(spinner int) {
gl.LoadIdentity()
gl.Translatef(30.5, 30.5, 0)
gl.Rotatef(float32(spinner), 0, 0, 1)
gl.Color3d(0, 0, 0)
gl.Rectd(-0.5, -10.5, 0.5, 10.5)
}
开发者ID:taliszhou,项目名称:Conception-go,代码行数:7,代码来源:main.go
示例4: drawSlide
func drawSlide() {
gl.Clear(gl.COLOR_BUFFER_BIT)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Translatef(0, 0, -3.0)
gl.Begin(gl.QUADS)
//top left
gl.TexCoord2f(0, 0)
gl.Vertex3f(-1, 1, 0)
//top right
gl.TexCoord2f(1, 0)
gl.Vertex3f(1, 1, 0)
//bottom right
gl.TexCoord2f(1, 1)
gl.Vertex3f(1, -1, 0)
//bottom left
gl.TexCoord2f(0, 1)
gl.Vertex3f(-1, -1, 0)
gl.End()
}
开发者ID:lordwelch,项目名称:PresentationApp,代码行数:27,代码来源:glfw.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:TheZeroSlave,项目名称:chipmunk,代码行数:33,代码来源:bouncing_balls.go
示例6: reshape
/* new window size or exposure */
func reshape(width int32, height int32) {
h := float64(height) / float64(width)
gl.Viewport(0, 0, width, height)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Frustum(-1.0, 1.0, -h, h, 5.0, 600.0)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Translatef(0.0, 0.0, -100)
}
开发者ID:pietdaniel,项目名称:gl_maze,代码行数:11,代码来源:main.go
示例7: update
func (t *Transform) update() {
gl.LoadMatrixf(&(t.parent.matrix[0]))
gl.Translatef(t.position.X, t.position.Y, 0)
gl.Rotatef(t.rotation, 0, 0, -1)
gl.GetFloatv(gl.MODELVIEW_MATRIX, &(t.parent.matrix[0]))
for _, c := range t.children {
c.update()
}
}
开发者ID:fmd,项目名称:bronson,代码行数:10,代码来源:transform.go
示例8: setVideoOptions
func (w *Window) setVideoOptions() {
gl.ClearColor(0.4, 0.0, 0.3, 1.0)
projectionMode()
setViewport(w.Width, w.Height)
//Required for per-pixel placing.
gl.Translatef(0.375, 0.375, 0.0)
modelViewMode()
setModelViewOptions()
}
开发者ID:fmd,项目名称:gogol,代码行数:12,代码来源:window.go
示例9: reshape
func reshape(window *glfw.Window, w, h int) {
gl.ClearColor(1, 1, 1, 1)
//fmt.Println(gl.GetString(gl.EXTENSIONS))
gl.Viewport(0, 0, int32(w), int32(h)) /* Establish viewing area to cover entire window. */
gl.MatrixMode(gl.PROJECTION) /* Start modifying the projection matrix. */
gl.LoadIdentity() /* Reset project matrix. */
gl.Ortho(0, float64(w), 0, float64(h), -1, 1) /* Map abstract coords directly to window coords. */
gl.Scalef(1, -1, 1) /* Invert Y axis so increasing Y goes down. */
gl.Translatef(0, float32(-h), 0) /* Shift origin up to upper-left corner. */
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
gl.Disable(gl.DEPTH_TEST)
width, height = w, h
}
开发者ID:zzn01,项目名称:draw2d,代码行数:14,代码来源:postscriptgl.go
示例10: reshape
func reshape(w int, h int) {
/* Because Gil specified "screen coordinates" (presumably with an
upper-left origin), this short bit of code sets up the coordinate
system to correspond to actual window coodrinates. This code
wouldn't be required if you chose a (more typical in 3D) abstract
coordinate system. */
gl.Viewport(0, 0, int32(w), int32(h)) /* Establish viewing area to cover entire window. */
gl.MatrixMode(gl.PROJECTION) /* Start modifying the projection matrix. */
gl.LoadIdentity() /* Reset project matrix. */
gl.Ortho(0, float64(w), 0, float64(h), -1, 1) /* Map abstract coords directly to window coords. */
gl.Scalef(1, -1, 1) /* Invert Y axis so increasing Y goes down. */
gl.Translatef(0, float32(-h), 0) /* Shift origin up to upper-left corner. */
}
开发者ID:XO-Lib,项目名称:GCXO,代码行数:14,代码来源:Window.go
示例11: drawScene
func drawScene() {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.LineWidth(1)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Translatef(0, 0, 0.0)
//gl.Rotatef(rotationX, 1, 0, 0)
//gl.Rotatef(rotationY, 0, 1, 0)
//rotationX += 0.5
//rotationY += 0.5
//gl.BindTexture(gl.TEXTURE_2D, texture)
}
开发者ID:nightowlware,项目名称:gooey,代码行数:17,代码来源:gooey.go
示例12: Update
func (t *Transform) Update() {
var m *float32
if t.parentTransform != nil {
m = &(t.parentTransform.Matrix[0])
} else {
m = &(t.Matrix[0])
}
gl.LoadMatrixf(m)
gl.Translatef(t.position.X, t.position.Y, 0)
gl.Rotatef(t.rotation, 0, 0, -1)
gl.GetFloatv(gl.MODELVIEW_MATRIX, &(t.Matrix[0]))
t.NeedsUpdate = false
for _, c := range t.childTransforms {
c.Update()
}
}
开发者ID:fmd,项目名称:gogol,代码行数:18,代码来源:transform.go
示例13: key_handler
// returns if we are done or not
func key_handler() bool {
var keys []uint8 = sdl.GetKeyState()
if keys[sdl.K_i] != 0 {
view_z += 1
}
if keys[sdl.K_o] != 0 {
view_z -= 1
}
if keys[sdl.K_ESCAPE] != 0 {
return true
}
if keys[sdl.K_UP] != 0 {
view_rotx += 1
}
if keys[sdl.K_DOWN] != 0 {
view_rotx -= 1.0
}
if keys[sdl.K_LEFT] != 0 {
view_roty += 1.0
}
if keys[sdl.K_RIGHT] != 0 {
view_roty -= 1.0
}
if keys[sdl.K_z] != 0 {
if (sdl.GetModState() & sdl.KMOD_RSHIFT) != 0 {
view_rotz -= 1.0
} else {
view_rotz += 1.0
}
}
if keys[sdl.K_w] != 0 {
gl.Translatef(0.0, 0.0, 1)
}
if keys[sdl.K_s] != 0 {
gl.Translatef(0.0, 0.0, -1)
}
if keys[sdl.K_a] != 0 {
gl.Translatef(-1, 0, 0)
}
if keys[sdl.K_d] != 0 {
gl.Translatef(1, 0, 0)
}
if keys[sdl.K_q] != 0 {
gl.Translatef(0, 1, 0)
}
if keys[sdl.K_e] != 0 {
gl.Translatef(0, -1, 0)
}
return false
}
开发者ID:pietdaniel,项目名称:gl_maze,代码行数:52,代码来源:main.go
示例14: Render
func Render() {
gl.ClearColor(0, 0, 0, 1)
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.Color4f(1, 1, 1, 1)
gl.BindTexture(gl.TEXTURE_2D, game.Texture)
gl.PushMatrix()
gl.Translatef(20-float32(game.PlayerX), 15-float32(game.PlayerY), 0)
gl.Begin(gl.TRIANGLES)
for i := 0; i < game.Width; i++ {
for j := 0; j < game.Height; j++ {
renderTile(game.Tiles[(j*game.Width)+i], float32(i), float32(j))
}
}
// Player
gl.Color4f(1, 0, 0, 1)
renderTile(4, float32(game.PlayerX), float32(game.PlayerY))
gl.End()
gl.PopMatrix()
}
开发者ID:Geemili,项目名称:maze-rogue,代码行数:21,代码来源:maze-rogue.go
示例15: Printf
// Printf draws the given string at the specified coordinates.
// It expects the string to be a single line. Line breaks are not
// handled as line breaks and are rendered as glyphs.
//
// In order to render multi-line text, it is up to the caller to split
// the text up into individual lines of adequate length and then call
// this method for each line seperately.
func (f *Font) Printf(x, y float32, fs string, argv ...interface{}) error {
indices := []rune(fmt.Sprintf(fs, argv...))
if len(indices) == 0 {
return nil
}
// Runes form display list indices.
// For this purpose, they need to be offset by -FontConfig.Low
low := f.config.Low
for i := range indices {
indices[i] -= low
}
var vp [4]int32
gl.GetIntegerv(gl.VIEWPORT, &vp[0])
gl.PushAttrib(gl.TRANSFORM_BIT)
gl.MatrixMode(gl.PROJECTION)
gl.PushMatrix()
gl.LoadIdentity()
gl.Ortho(float64(vp[0]), float64(vp[2]), float64(vp[1]), float64(vp[3]), 0, 1)
gl.PopAttrib()
gl.PushAttrib(gl.LIST_BIT | gl.CURRENT_BIT | gl.ENABLE_BIT | gl.TRANSFORM_BIT)
{
gl.MatrixMode(gl.MODELVIEW)
gl.Disable(gl.LIGHTING)
gl.Disable(gl.DEPTH_TEST)
gl.Enable(gl.BLEND)
gl.Enable(gl.TEXTURE_2D)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
gl.TexEnvf(gl.TEXTURE_ENV, gl.TEXTURE_ENV_MODE, gl.MODULATE)
gl.BindTexture(gl.TEXTURE_2D, f.texture)
gl.ListBase(f.listbase)
var mv [16]float32
gl.GetFloatv(gl.MODELVIEW_MATRIX, &mv[0])
gl.PushMatrix()
{
gl.LoadIdentity()
mgw := float32(f.maxGlyphWidth)
mgh := float32(f.maxGlyphHeight)
switch f.config.Dir {
case LeftToRight, TopToBottom:
gl.Translatef(x, float32(vp[3])-y-mgh, 0)
case RightToLeft:
gl.Translatef(x-mgw, float32(vp[3])-y-mgh, 0)
}
gl.MultMatrixf(&mv[0])
gl.CallLists(int32(len(indices)), gl.UNSIGNED_INT, unsafe.Pointer(&indices[0]))
}
gl.PopMatrix()
gl.BindTexture(gl.TEXTURE_2D, 0)
}
gl.PopAttrib()
gl.PushAttrib(gl.TRANSFORM_BIT)
gl.MatrixMode(gl.PROJECTION)
gl.PopMatrix()
gl.PopAttrib()
return checkGLError()
}
开发者ID:go-gl,项目名称:gltext,代码行数:75,代码来源:font.go
示例16: drawScreen
func (ctx *DrawContext) drawScreen(o *orrery.Orrery) {
fullscreen := false
gl.Viewport(0, 0, int32(ctx.width), int32(ctx.height))
gl.Hint(gl.PERSPECTIVE_CORRECTION_HINT, gl.NICEST)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Translatef(0, 0, 0)
t_delta := time.Duration(0)
frametime := time.Second / 24
log.Printf(`ft: %v`, frametime)
frametimes := time.Duration(0)
nsamples := 0
slowest_frame := time.Duration(0)
frames_over_deadline := 0
defer func() {
log.Printf(`average frame time: %v, #sample: %d`, frametimes/time.Duration(nsamples), nsamples)
log.Printf(`slowest frame: %v, # of frames over %v: %d`, slowest_frame, frametime, frames_over_deadline)
}()
for {
t_start := time.Now()
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
ctx.cam.Update()
ctx.drawGrid()
ctx.drawParticles(o)
ctx.drawHud(o, t_delta)
ctx.win.SwapBuffers()
glfw.PollEvents()
select {
case cmd := <-ctx.cmd:
switch cmd {
case DRAW_QUIT:
return
case DRAW_FULLSCREEN:
/*
if fullscreen {
ctx.win.SetFullscreen(0)
} else {
ctx.win.SetFullscreen(sdl.WINDOW_FULLSCREEN)
}
*/
fullscreen = !fullscreen
case DRAW_TOGGLE_WIREFRAME:
ctx.wireframe = !ctx.wireframe
case DRAW_TOGGLE_VERBOSE:
ctx.verbose = !ctx.verbose
}
default:
/* ignore */
}
t_delta = time.Since(t_start)
frametimes += t_delta
nsamples++
if t_delta > slowest_frame {
slowest_frame = t_delta
}
if t_delta > frametime {
frames_over_deadline++
}
t_sleep := frametime.Nanoseconds() - t_delta.Nanoseconds()
if t_sleep > 0 {
time.Sleep(time.Duration(t_sleep) * time.Nanosecond)
}
}
}
开发者ID:farhaven,项目名称:universe,代码行数:74,代码来源:drawing.go
示例17: drawScene
func drawScene() {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Translatef(0, 0, -3.0)
gl.Rotatef(rotationX, 1, 0, 0)
gl.Rotatef(rotationY, 0, 1, 0)
rotationX += 0.5
rotationY += 0.5
gl.BindTexture(gl.TEXTURE_2D, texture)
gl.Color4f(1, 1, 1, 1)
gl.Begin(gl.QUADS)
gl.Normal3f(0, 0, 1)
gl.TexCoord2f(0, 0)
gl.Vertex3f(-1, -1, 1)
gl.TexCoord2f(1, 0)
gl.Vertex3f(1, -1, 1)
gl.TexCoord2f(1, 1)
gl.Vertex3f(1, 1, 1)
gl.TexCoord2f(0, 1)
gl.Vertex3f(-1, 1, 1)
gl.Normal3f(0, 0, -1)
gl.TexCoord2f(1, 0)
gl.Vertex3f(-1, -1, -1)
gl.TexCoord2f(1, 1)
gl.Vertex3f(-1, 1, -1)
gl.TexCoord2f(0, 1)
gl.Vertex3f(1, 1, -1)
gl.TexCoord2f(0, 0)
gl.Vertex3f(1, -1, -1)
gl.Normal3f(0, 1, 0)
gl.TexCoord2f(0, 1)
gl.Vertex3f(-1, 1, -1)
gl.TexCoord2f(0, 0)
gl.Vertex3f(-1, 1, 1)
gl.TexCoord2f(1, 0)
gl.Vertex3f(1, 1, 1)
gl.TexCoord2f(1, 1)
gl.Vertex3f(1, 1, -1)
gl.Normal3f(0, -1, 0)
gl.TexCoord2f(1, 1)
gl.Vertex3f(-1, -1, -1)
gl.TexCoord2f(0, 1)
gl.Vertex3f(1, -1, -1)
gl.TexCoord2f(0, 0)
gl.Vertex3f(1, -1, 1)
gl.TexCoord2f(1, 0)
gl.Vertex3f(-1, -1, 1)
gl.Normal3f(1, 0, 0)
gl.TexCoord2f(1, 0)
gl.Vertex3f(1, -1, -1)
gl.TexCoord2f(1, 1)
gl.Vertex3f(1, 1, -1)
gl.TexCoord2f(0, 1)
gl.Vertex3f(1, 1, 1)
gl.TexCoord2f(0, 0)
gl.Vertex3f(1, -1, 1)
gl.Normal3f(-1, 0, 0)
gl.TexCoord2f(0, 0)
gl.Vertex3f(-1, -1, -1)
gl.TexCoord2f(1, 0)
gl.Vertex3f(-1, -1, 1)
gl.TexCoord2f(1, 1)
gl.Vertex3f(-1, 1, 1)
gl.TexCoord2f(0, 1)
gl.Vertex3f(-1, 1, -1)
gl.End()
}
开发者ID:donomii,项目名称:throfflib,代码行数:80,代码来源:throffgraphics.go
示例18: Translatef
func (c *Context) Translatef(x, y, z float32) {
gl.Translatef(x, y, z)
}
开发者ID:Lealen,项目名称:webgl,代码行数:3,代码来源:webgl_gl2.go
示例19: loadFont
// loadFont loads the given font data. This does not deal with font scaling.
// Scaling should be handled by the independent Bitmap/Truetype loaders.
// We therefore expect the supplied image and charset to already be adjusted
// to the correct font scale.
//
// The image should hold a sprite sheet, defining the graphical layout for
// every glyph. The config describes font metadata.
func loadFont(img *image.RGBA, config *FontConfig) (f *Font, err error) {
f = new(Font)
f.config = config
// Resize image to next power-of-two.
img = Pow2Image(img).(*image.RGBA)
ib := img.Bounds()
// Create the texture itself. It will contain all glyphs.
// Individual glyph-quads display a subset of this texture.
gl.GenTextures(1, &f.texture)
gl.BindTexture(gl.TEXTURE_2D, f.texture)
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR)
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR)
gl.TexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, int32(ib.Dx()), int32(ib.Dy()), 0,
gl.RGBA, gl.UNSIGNED_BYTE, gl.Ptr(img.Pix))
// Create display lists for each glyph.
f.listbase = gl.GenLists(int32(len(config.Glyphs)))
texWidth := float32(ib.Dx())
texHeight := float32(ib.Dy())
for index, glyph := range config.Glyphs {
// Update max glyph bounds.
if glyph.Width > f.maxGlyphWidth {
f.maxGlyphWidth = glyph.Width
}
if glyph.Height > f.maxGlyphHeight {
f.maxGlyphHeight = glyph.Height
}
// Quad width/height
vw := float32(glyph.Width)
vh := float32(glyph.Height)
// Texture coordinate offsets.
tx1 := float32(glyph.X) / texWidth
ty1 := float32(glyph.Y) / texHeight
tx2 := (float32(glyph.X) + vw) / texWidth
ty2 := (float32(glyph.Y) + vh) / texHeight
// Advance width (or height if we render top-to-bottom)
adv := float32(glyph.Advance)
gl.NewList(f.listbase+uint32(index), gl.COMPILE)
{
gl.Begin(gl.QUADS)
{
gl.TexCoord2f(tx1, ty2)
gl.Vertex2f(0, 0)
gl.TexCoord2f(tx2, ty2)
gl.Vertex2f(vw, 0)
gl.TexCoord2f(tx2, ty1)
gl.Vertex2f(vw, vh)
gl.TexCoord2f(tx1, ty1)
gl.Vertex2f(0, vh)
}
gl.End()
switch config.Dir {
case LeftToRight:
gl.Translatef(adv, 0, 0)
case RightToLeft:
gl.Translatef(-adv, 0, 0)
case TopToBottom:
gl.Translatef(0, -adv, 0)
}
}
gl.EndList()
}
err = checkGLError()
return
}
开发者ID:go-gl,项目名称:gltext,代码行数:83,代码来源:font.go
注:本文中的github.com/go-gl/gl/v2/1/gl.Translatef函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论