本文整理汇总了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()
}
示例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)
}
示例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)
}
示例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)
}