本文整理汇总了Golang中gl.Frustum函数的典型用法代码示例。如果您正苦于以下问题:Golang Frustum函数的具体用法?Golang Frustum怎么用?Golang Frustum使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Frustum函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: resizeWindow
// reset our viewport after a window resize
func resizeWindow(width, height int) {
// protect against a divide by zero
if height == 0 {
height = 1
}
// Setup our viewport
gl.Viewport(0, 0, width, height)
// change to the projection matrix and set our viewing volume.
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
// aspect ratio
aspect := gl.GLdouble(width / height)
// Set our perspective.
// This code is equivalent to using gluPerspective as in the original tutorial.
var fov, near, far gl.GLdouble
fov = 45.0
near = 0.1
far = 100.0
top := gl.GLdouble(math.Tan(float64(fov*math.Pi/360.0))) * near
bottom := -top
left := aspect * bottom
right := aspect * top
gl.Frustum(float64(left), float64(right), float64(bottom), float64(top), float64(near), float64(far))
// Make sure we're changing the model view and not the projection
gl.MatrixMode(gl.MODELVIEW)
// Reset the view
gl.LoadIdentity()
}
开发者ID:PragmaticCypher,项目名称:opengl-go-tutorials,代码行数:35,代码来源:lesson01.go
示例2: reshape
/* new window size or exposure */
func reshape(width int, height int) {
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, 60.0)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Translatef(0.0, 0.0, -40.0)
}
开发者ID:DeedleFake,项目名称:Go-OpenGL,代码行数:13,代码来源:gogears.go
示例3: Setup
func (self *Camera) Setup() {
d := self.Distance
Angle := self.Angle
Angle360 := Angle.Scale(1 / math.Pi * 180)
TargetPos := self.Target.Pos
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Viewport(0, 0, 800, 600)
gl.Frustum(-1, 1, -1, 1, 4, 1000)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Translatef(0, 0, -d)
gl.Rotatef(Angle360.Y, 1, 0, 0)
gl.Rotatef(Angle360.X, 0, 1, 0)
gl.Translatef(-TargetPos.X, -TargetPos.Y, -TargetPos.Z)
}
开发者ID:rolfrm,项目名称:boxworld,代码行数:19,代码来源:graphics.go
示例4: ResizeWindow
func ResizeWindow(w int32, h int32) {
// resizeWindow
gl.MatrixMode(gl.PROJECTION)
gl.Viewport(0, 0, gl.GLsizei(w), gl.GLsizei(h))
gl.LoadIdentity()
// glu.Perspective( 45.0, ratio, 0.1, 100.0)
aspect := gl.GLdouble(w) / gl.GLdouble(h)
zNear := gl.GLdouble(0.1)
zFar := gl.GLdouble(100.0)
gl.Frustum(-NearHeight*aspect,
NearHeight*aspect,
-NearHeight,
NearHeight, zNear, zFar)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
WinW = int(w)
WinH = int(h)
}
开发者ID:jcd,项目名称:go-gamelib,代码行数:24,代码来源:video.go
注:本文中的gl.Frustum函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论