本文整理汇总了Golang中github.com/go-gl/gl.Rotatef函数的典型用法代码示例。如果您正苦于以下问题:Golang Rotatef函数的具体用法?Golang Rotatef怎么用?Golang Rotatef使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Rotatef函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: drawScene
func drawScene() {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.LoadIdentity()
gl.Translatef(-1.5, 0, -6)
gl.Rotatef(trisAngle, 0, 1, 0)
gl.Begin(gl.TRIANGLES)
gl.Color3f(1, 0, 0)
gl.Vertex3f(0, 1, 0)
gl.Color3f(0, 1, 0)
gl.Vertex3f(-1, -1, 0)
gl.Color3f(0, 0, 1)
gl.Vertex3f(1, -1, 0)
gl.End()
gl.LoadIdentity()
gl.Translatef(1.5, 0, -6)
gl.Rotatef(quadAngle, 1, 0, 0)
gl.Color3f(0.5, 0.5, 1.0)
gl.Begin(gl.QUADS)
gl.Vertex3f(-1, 1, 0)
gl.Vertex3f(1, 1, 0)
gl.Vertex3f(1, -1, 0)
gl.Vertex3f(-1, -1, 0)
gl.End()
trisAngle += 0.2
quadAngle -= 0.15
glfw.SwapBuffers()
}
示例2: draw
func draw() { // 从这里开始进行所有的绘制
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT) // 清除屏幕和深度缓存
gl.LoadIdentity() // 重置当前的模型观察矩阵
gl.Translatef(-1.5, 0.0, -6.0) // 左移 1.5 单位,并移入屏幕 6.0
gl.Rotatef(rtri, 0.0, 1.0, 0.0) // 绕Y轴旋转三角形
gl.Begin(gl.TRIANGLES) // 绘制三角形
gl.Color3f(1.0, 0.0, 0.0) // 设置当前色为红色
gl.Vertex3f(0.0, 1.0, 0.0) // 上顶点
gl.Color3f(0.0, 1.0, 0.0) // 设置当前色为绿色
gl.Vertex3f(-1.0, -1.0, 0.0) // 左下
gl.Color3f(0.0, 0.0, 1.0) // 设置当前色为蓝色
gl.Vertex3f(1.0, -1.0, 0.0) // 右下
gl.End() // 三角形绘制结束
gl.LoadIdentity() // 重置当前的模型观察矩阵
gl.Translatef(1.5, 0.0, -6.0) // 右移1.5单位,并移入屏幕 6.0
gl.Rotatef(rquad, 1.0, 0.0, 0.0) // 绕X轴旋转四边形
gl.Color3f(0.5, 0.5, 1.0) // 一次性将当前色设置为蓝色
gl.Begin(gl.QUADS) // 绘制正方形
gl.Vertex3f(-1.0, 1.0, 0.0) // 左上
gl.Vertex3f(1.0, 1.0, 0.0) // 右上
gl.Vertex3f(1.0, -1.0, 0.0) // 左下
gl.Vertex3f(-1.0, -1.0, 0.0) // 右下
gl.End()
rtri += 0.2 // 增加三角形的旋转变量
rquad -= 0.15 // 减少四边形的旋转变量
}
示例3: Sphere
// Render a sphere with the correct orientation (poles along y-axis)
// Also makes a correction to avoid lighting flicker.
// TODO: Replace with geodesic
func Sphere(radius float32, granularity int) {
glh.With(glh.Matrix{gl.MODELVIEW}, func() {
// Needed to avoid a strange lighting effect
gl.Rotatef(90, 0, 1, 0)
// Rotate so that poles are on the y-axis
gl.Rotatef(90, 1, 0, 0)
glu.Sphere(quadric, radius, granularity, granularity)
})
}
示例4: main
func main() {
var err error
if err = glfw.Init(); err != nil {
log.Fatalf("%v\n", err)
return
}
defer glfw.Terminate()
// Open window with FSAA samples (if possible).
glfw.OpenWindowHint(glfw.FsaaSamples, 4)
if err = glfw.OpenWindow(400, 400, 0, 0, 0, 0, 0, 0, glfw.Windowed); err != nil {
log.Fatalf("%v\n", err)
return
}
defer glfw.CloseWindow()
glfw.SetWindowTitle("Aliasing Detector")
glfw.SetSwapInterval(1)
if samples := glfw.WindowParam(glfw.FsaaSamples); samples != 0 {
fmt.Printf("Context reports FSAA is supported with %d samples\n", samples)
} else {
fmt.Printf("Context reports FSAA is unsupported\n")
}
gl.MatrixMode(gl.PROJECTION)
glu.Perspective(0, 1, 0, 1)
for glfw.WindowParam(glfw.Opened) == 1 {
time := float32(glfw.Time())
gl.Clear(gl.COLOR_BUFFER_BIT)
gl.LoadIdentity()
gl.Translatef(0.5, 0, 0)
gl.Rotatef(time, 0, 0, 1)
gl.Enable(GL_MULTISAMPLE_ARB)
gl.Color3f(1, 1, 1)
gl.Rectf(-0.25, -0.25, 0.25, 0.25)
gl.LoadIdentity()
gl.Translatef(-0.5, 0, 0)
gl.Rotatef(time, 0, 0, 1)
gl.Disable(GL_MULTISAMPLE_ARB)
gl.Color3f(1, 1, 1)
gl.Rectf(-0.25, -0.25, 0.25, 0.25)
glfw.SwapBuffers()
}
}
示例5: drawScene
func drawScene() {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.LoadIdentity() // 重置当前矩阵
texture.Bind(gl.TEXTURE_2D)
var x_m, y_m, z_m, u_m, v_m float32
xtrans := -xpos
ztrans := -zpos
ytrans := -walkbias - 0.25
sceneroty := 360.0 - yrot
var numtriangles int
gl.Rotatef(lookupdown, 1.0, 0, 0)
gl.Rotatef(sceneroty, 0, 1.0, 0)
gl.Translatef(xtrans, ytrans, ztrans)
numtriangles = sector1.numtriangles
// Process Each Triangle
for loop_m := 0; loop_m < numtriangles; loop_m++ {
gl.Begin(gl.TRIANGLES)
gl.Normal3f(0.0, 0.0, 1.0)
x_m = sector1.triangles[loop_m].vertex[0].x
y_m = sector1.triangles[loop_m].vertex[0].y
z_m = sector1.triangles[loop_m].vertex[0].z
u_m = sector1.triangles[loop_m].vertex[0].u
v_m = sector1.triangles[loop_m].vertex[0].v
gl.TexCoord2f(u_m, v_m)
gl.Vertex3f(x_m, y_m, z_m)
x_m = sector1.triangles[loop_m].vertex[1].x
y_m = sector1.triangles[loop_m].vertex[1].y
z_m = sector1.triangles[loop_m].vertex[1].z
u_m = sector1.triangles[loop_m].vertex[1].u
v_m = sector1.triangles[loop_m].vertex[1].v
gl.TexCoord2f(u_m, v_m)
gl.Vertex3f(x_m, y_m, z_m)
x_m = sector1.triangles[loop_m].vertex[2].x
y_m = sector1.triangles[loop_m].vertex[2].y
z_m = sector1.triangles[loop_m].vertex[2].z
u_m = sector1.triangles[loop_m].vertex[2].u
v_m = sector1.triangles[loop_m].vertex[2].v
gl.TexCoord2f(u_m, v_m)
gl.Vertex3f(x_m, y_m, z_m)
gl.End()
}
}
示例6: 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()
}
}
示例7: 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()
}
示例8: drawScene
func drawScene() {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
texture.Bind(gl.TEXTURE_2D)
for loop = 0; loop < num; loop++ {
gl.LoadIdentity() // 绘制每颗星星之前,重置模型观察矩阵
gl.Translatef(0.0, 0.0, zoom) // 深入屏幕里面
gl.Rotatef(tilt, 1.0, 0.0, 0.0) // 倾斜视角
gl.Rotatef(ztilt, 0.0, 0.0, 1.0) // 倾斜视角
gl.Rotatef(star[loop].angle, 0.0, 1.0, 0.0) // 旋转至当前所画星星的角度
gl.Translatef(star[loop].dist, 0.0, 0.0) // 沿X轴正向移动
gl.Rotatef(-star[loop].angle, 0.0, 1.0, 0.0) // 取消当前星星的角度
gl.Rotatef(-ztilt, 0.0, 0.0, 1.0) // 取消屏幕倾斜
gl.Rotatef(-tilt, 1.0, 0.0, 0.0) // 取消屏幕倾斜
if twinkle { // 启用闪烁效果
// 使用byte型数值指定一个颜色
gl.Color4ub(star[(num-loop)-1].r, star[(num-loop)-1].g, star[(num-loop)-1].b, 255)
gl.Begin(gl.QUADS) // 开始绘制纹理映射过的四边形
gl.TexCoord2f(0.0, 0.0)
gl.Vertex3f(-1.0, -1.0, 0.0)
gl.TexCoord2f(1.0, 0.0)
gl.Vertex3f(1.0, -1.0, 0.0)
gl.TexCoord2f(1.0, 1.0)
gl.Vertex3f(1.0, 1.0, 0.0)
gl.TexCoord2f(0.0, 1.0)
gl.Vertex3f(-1.0, 1.0, 0.0)
gl.End() // 四边形绘制结束
}
gl.Rotatef(spin, 0.0, 0.0, 1.0) // 绕z轴旋转星星
// 使用byte型数值指定一个颜色
gl.Color4ub(star[loop].r, star[loop].g, star[loop].b, 255)
gl.Begin(gl.QUADS) // 开始绘制纹理映射过的四边形
gl.TexCoord2f(0.0, 0.0)
gl.Vertex3f(-1.0, -1.0, 0.0)
gl.TexCoord2f(1.0, 0.0)
gl.Vertex3f(1.0, -1.0, 0.0)
gl.TexCoord2f(1.0, 1.0)
gl.Vertex3f(1.0, 1.0, 0.0)
gl.TexCoord2f(0.0, 1.0)
gl.Vertex3f(-1.0, 1.0, 0.0)
gl.End() // 四边形绘制结束
spin += 0.01 // 星星的公转
star[loop].angle += float32(loop) / num // 改变星星的自转角度
star[loop].dist -= 0.01 // 改变星星离中心的距离
if star[loop].dist < 0.0 { // 星星到达中心了么
star[loop].dist += 5 // 往外移5个单位
//fmt.Println(loop, star[loop].dist)
star[loop].r = uint8(rand.Int() % 256) // 赋一个新红色分量
star[loop].g = uint8(rand.Int() % 256) // 赋一个新绿色分量
star[loop].b = uint8(rand.Int() % 256) // 赋一个新蓝色分量
}
}
}
示例9: drawBlock
func drawBlock(loc Loc, b *Block) {
// Save current modelview matrix on to the stack
gl.PushMatrix()
// Move block
gl.Translatef(loc.X, loc.Y, loc.Z)
// Rotate block
gl.Rotatef(b.Pitch, 1, 0, 0)
gl.Rotatef(b.Yaw, 0, 1, 0)
gl.Rotatef(b.Roll, 0, 0, 1)
// Start specifying the vertices of quads.
gl.Begin(gl.QUADS)
for _, quad := range b.Quads {
gl.Color3fv(quad.Color)
for _, vertex := range quad.Vertices {
gl.Vertex3fv(b.Vertices[vertex])
}
}
gl.End()
// Restore old modelview matrix
gl.PopMatrix()
}
示例10: 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
}
}
示例11: drawScene
func drawScene() {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT) /// 清除屏幕及深度缓存
gl.LoadIdentity() /// 重置模型观察矩阵
gl.Translatef(-1.5, 0, -6) /// 左移 1.5 单位,并移入屏幕 6.0
gl.Rotatef(trisAngle, 0, 1, 0) ///以y为轴 参数:角度,X,Y,Z
gl.Begin(gl.TRIANGLES) /// 绘制三角形
gl.Color3f(1, 0, 0) /// 设置当前色为红色
gl.Vertex3f(0, 1, 0) ///上顶点
gl.Color3f(0, 1, 0) /// 设置当前色为绿色
gl.Vertex3f(-1, -1, 0) /// 左下
gl.Color3f(0, 0, 1) ///设置当前色为蓝色
gl.Vertex3f(1, -1, 0) ///右下
gl.End() ///三角形绘制结束,三角形将被填充。
//但是因为每个顶点有不同的颜色,因此看起来颜色从每个角喷出,并刚好在三角形的中心汇合,三种颜色相互混合。这就是平滑着色。
/// 要让对象绕自身的轴旋转,必须让对象的中心坐标总是(0.0f,0,0f,0,0f),因此这里的四边形是满屏跑的
gl.LoadIdentity() ///将当前点移到了屏幕中心,X坐标轴从左至右,Y坐标轴从下至上,Z坐标轴从里至外。
///OpenGL屏幕中心的坐标值是X和Y轴上的0.0f点。中心左面的坐标值是负值,右面是正值。移向屏幕顶端是正值,移向屏幕底端是负值。移入屏幕深处是负值,移出屏幕则是正值。
gl.Rotatef(quadAngle, 1, 0, 0) /// 以x为轴
gl.Translatef(1.5, 0, -6) ///以当前点为起始点移动?(是的)-6为距离
//gl.Translatef(3, 0, -6); ///右移3单位,看不见?(因为loadIdentity()置中了)
gl.Color3f(0.5, 0.5, 1.0) ///一次性将当前色设置为蓝色
/// @note 顺时针绘制的正方形意味着我们所看见的是四边形的背面
gl.Begin(gl.QUADS) ///绘制正方形
gl.Vertex3f(-1, 1, 0) /// 左上
gl.Vertex3f(1, 1, 0) /// 右上
gl.Vertex3f(1, -1, 0) /// 右下
gl.Vertex3f(-1, -1, 0) /// 左下
gl.End() ///正方形绘制结束
trisAngle += 0.2
quadAngle -= 0.15
glfw.SwapBuffers() ///必须交换显示区才能展现
}
示例12: redraw
func redraw() {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
var viewport [4]int32
gl.GetIntegerv(gl.VIEWPORT, viewport[:4])
aspect := float64(viewport[2]) / float64(viewport[3])
glu.Perspective(60, aspect, 1, 100)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Translatef(POV.X, POV.Y, POV.Z)
gl.Rotatef(POV.Pitch, 1, 0, 0)
gl.Rotatef(POV.Yaw, 0, 1, 0)
gl.Rotatef(POV.Roll, 0, 0, 1)
for x, row := range World {
for z, block := range row {
drawBlock(translateCoordinates(x, 0, z), block)
if x == CursorX && z == CursorZ {
drawCursor()
}
}
}
}
示例13: main
func main() {
err := initGL()
if err != nil {
log.Printf("InitGL: %v", err)
return
}
defer glfw.Terminate()
mb := createBuffer()
defer mb.Release()
// Perform the rendering.
var angle float32
for glfw.WindowParam(glfw.Opened) > 0 {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.LoadIdentity()
gl.Translatef(0, 0, -6)
gl.Rotatef(angle, 1, 1, 1)
// Render a solid cube at half the scale.
gl.Scalef(0.2, 0.2, 0.2)
gl.Enable(gl.COLOR_MATERIAL)
gl.Enable(gl.POLYGON_OFFSET_FILL)
gl.PolygonMode(gl.FRONT_AND_BACK, gl.FILL)
mb.Render(gl.QUADS)
// Render wireframe cubes, with incremental size.
gl.Disable(gl.COLOR_MATERIAL)
gl.Disable(gl.POLYGON_OFFSET_FILL)
gl.PolygonMode(gl.FRONT_AND_BACK, gl.LINE)
for i := 0; i < 50; i++ {
scale := 0.004*float32(i) + 1.0
gl.Scalef(scale, scale, scale)
mb.Render(gl.QUADS)
}
angle += 0.5
glfw.SwapBuffers()
}
}
示例14: drawBall
func drawBall(angle float32, ball_x float32, ball_y float32) {
gl.PushMatrix()
gl.Color3f(1, 1, 1)
gl.Translatef(ball_x, ball_y, 0.0)
gl.Begin(gl.LINE_LOOP)
for rad := 0.0; rad < 1.0; rad += 0.01 {
gl.Vertex2f(
float32(2.0*math.Cos(2.0*math.Pi*rad)),
float32(2.0*math.Sin(2.0*math.Pi*rad)+0.2))
}
gl.End()
gl.Rotatef(angle, 0.0, 0.0, 1.0)
gl.Begin(gl.LINE_STRIP)
gl.Vertex2f(0, 0)
gl.Vertex2f(2, 0)
gl.End()
gl.PopMatrix()
}
示例15: drawBorderAtXY
func drawBorderAtXY(x, y float32, reverse int) {
if x <= 80 || y <= 80 {
return
}
gl.PushMatrix()
gl.Translatef(x, y, 0)
if reverse == 1 {
gl.Rotatef(60, 0, 0, 1)
}
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
gl.TexEnvf(gl.TEXTURE_ENV, gl.TEXTURE_ENV_MODE, gl.REPLACE)
borderTex.Bind(gl.TEXTURE_2D)
gl.Begin(gl.QUADS)
gl.TexCoord2f(0, 0)
gl.Vertex2i(-38, -38)
gl.TexCoord2f(0, 1)
gl.Vertex2i(-38, 38)
gl.TexCoord2f(1, 1)
gl.Vertex2i(38, 38)
gl.TexCoord2f(1, 0)
gl.Vertex2i(38, -38)
gl.End()
gl.PopMatrix()
}