本文整理汇总了Golang中github.com/banthar/gl.Viewport函数的典型用法代码示例。如果您正苦于以下问题:Golang Viewport函数的具体用法?Golang Viewport怎么用?Golang Viewport使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Viewport函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: size_window
func size_window(x, y int, fov, aspect, min_cull, max_cull float64) {
gl.Viewport(0, 0, x, y)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
glu.Perspective(fov, aspect, min_cull, max_cull)
gl.Enable(gl.DEPTH_TEST)
}
示例2: initScreen
func initScreen() {
sdl.Init(sdl.INIT_VIDEO)
const (
resx int = 640
resy int = 480
)
var (
screen = sdl.SetVideoMode(resx, resy, 16, sdl.OPENGL)
)
if screen == nil {
sdl.Quit()
panic("Couldn't set GL video mode: " + sdl.GetError() + "\n")
}
if gl.Init() != 0 {
panic("gl error")
}
gl.MatrixMode(gl.PROJECTION)
//gl.MatrixMode(gl.MODELVIEW)
gl.Viewport(0, 0, int(screen.W), int(screen.H))
gl.LoadIdentity()
gl.Ortho(0, float64(screen.W), float64(screen.H), 0, -1.0, 1.0)
//gl.DepthRange(-1, 1)
gl.ClearColor(0, 0, 0, 0)
gl.Clear(gl.COLOR_BUFFER_BIT)
}
示例3: SetProjection2D
func (this *Window) SetProjection2D() {
gl.MatrixMode(gl.PROJECTION)
gl.Viewport(0, 0, int(this.Width()), int(this.Height()))
gl.LoadIdentity()
gl.Ortho(0, float64(this.Width()), 0, float64(this.Height()), -1.0, 1.0)
gl.MatrixMode(gl.MODELVIEW)
}
示例4: Reshape
/* new window size or exposure */
func (self *Viewport) Reshape(width int, height int) {
self.selectionDirty = false
self.screenWidth = width
self.screenHeight = height
gl.Viewport(0, 0, width, height)
viewWidth := float64(self.screenWidth) / float64(SCREEN_SCALE)
viewHeight := float64(self.screenHeight) / float64(SCREEN_SCALE)
self.lplane = -viewWidth / 2
self.rplane = viewWidth / 2
self.bplane = -viewHeight / 4
self.tplane = 3 * viewHeight / 4
println("self.lplane:", self.lplane, "self.rplane", self.rplane)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(self.lplane, self.rplane, self.bplane, self.tplane, -60, 60)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
picker.x = float32(viewport.rplane) - picker.radius + blockscale*0.5
picker.y = float32(viewport.bplane) + picker.radius - blockscale*0.5
}
示例5: Reshape
func (v *Video) Reshape(width int, height int) {
x_offset := 0
y_offset := 0
r := ((float64)(height)) / ((float64)(width))
if r > 0.9375 { // Height taller than ratio
h := (int)(math.Floor((float64)(0.9375 * (float64)(width))))
y_offset = (height - h) / 2
height = h
} else if r < 0.9375 { // Width wider
var scrW, scrH float64
if ppu.OverscanEnabled {
scrW = 240.0
scrH = 224.0
} else {
scrW = 256.0
scrH = 240.0
}
w := (int)(math.Floor((float64)((scrH / scrW) * (float64)(height))))
x_offset = (width - w) / 2
width = w
}
gl.Viewport(x_offset, y_offset, width, height)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(-1, 1, -1, 1, -1, 1)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Disable(gl.DEPTH_TEST)
}
示例6: reshape
// Handle the window being resized.
func reshape(width int, height int) {
// Render into the entire window.
gl.Viewport(0, 0, width, height)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
// Configure the Frustrum so the front face of the rendering
// volume fills the screen.
w := float64(width)
h := float64(height)
depth := (w + h) / 2
near := depth / 2.0
right := w / 4.0
top := h / 4.0
far := 4 * depth
gl.Frustum(-right, right, -top, top, near, far)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
// Center the rendering volume in the viewport. Its origin
// is at the far lower left corner.
gl.Translated(-w/2, -h/2, -2*depth)
}
示例7: 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, int(width), int(height))
// change to the projection matrix and set our viewing volume.
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
// aspect ratio
aspect := gl.GLdouble(gl.GLfloat(width) / gl.GLfloat(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()
}
示例8: Reshape
/* new window size or exposure */
func (self *Viewport) Reshape(width int, height int) {
self.selectionDirty = false
self.screenWidth = width
self.screenHeight = height
gl.Viewport(0, 0, width, height)
viewWidth := float64(self.screenWidth) / float64(SCREEN_SCALE)
viewHeight := float64(self.screenHeight) / float64(SCREEN_SCALE)
self.lplane = -viewWidth / 2
self.rplane = viewWidth / 2
self.bplane = -viewHeight / 4
self.tplane = 3 * viewHeight / 4
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(self.lplane, self.rplane, self.bplane, self.tplane, -60, 60)
// self.Perspective(90, 1, 0.01,1000);
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
picker.x = float32(viewport.rplane) - picker.radius + BLOCK_SCALE*0.5
picker.y = float32(viewport.bplane) + picker.radius - BLOCK_SCALE*0.5
}
示例9: InitGLWindow
// Initialize the OpenGL configuration with the information from the current window.
func InitGLWindow(w, h int) {
gl.Viewport(0, 0, w, h)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
glu.Perspective(45.0, float64(w)/float64(h), 0.1, 100.0)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
}
示例10: reshape
func reshape(w, h int) {
gl.Viewport(0, 0, w, h)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(0, float64(w), 0, float64(h), -1, 1)
gl.Scalef(1, -1, 1)
gl.Translatef(0, float32(-h), 0)
gl.MatrixMode(gl.MODELVIEW)
}
示例11: onResize
func onResize(w, h int) {
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Viewport(0, 0, w, h)
gl.Ortho(0, float64(w), float64(h), 0, -1.0, 1.0)
gl.ClearColor(1, 1, 1, 0)
gl.Clear(gl.COLOR_BUFFER_BIT)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
}
示例12: 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)
}
示例13: 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")
}
pen := Pen{}
gl.MatrixMode(gl.PROJECTION)
gl.Viewport(0, 0, int(screen.W), int(screen.H))
gl.LoadIdentity()
gl.Ortho(0, float64(screen.W), float64(screen.H), 0, -1.0, 1.0)
gl.ClearColor(1, 1, 1, 0)
gl.Clear(gl.COLOR_BUFFER_BIT)
var running = true
for running {
for e := sdl.PollEvent(); e != nil; e = sdl.PollEvent() {
switch ev := e.(type) {
case *sdl.QuitEvent:
running = false
case *sdl.KeyboardEvent:
if ev.Keysym.Sym == sdl.K_ESCAPE {
running = false
}
case *sdl.MouseMotionEvent:
if ev.State != 0 {
pen.lineTo(Point{int(ev.X), int(ev.Y)})
} else {
pen.moveTo(Point{int(ev.X), int(ev.Y)})
}
}
}
sdl.GL_SwapBuffers()
sdl.Delay(25)
}
sdl.Quit()
}
示例14: onResize
func onResize(w, h int) {
if h == 0 {
h = 1
}
gl.Viewport(0, 0, w, h)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(-1, 1, -1, 1, -1, 1)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Disable(gl.DEPTH_TEST)
}
示例15: reshape
func (this *Window) reshape(w, h int) {
gl.Viewport(0, 0, w, h)
ratio := Double(w) / Double(h)
var znear, zfar, fovx Double = 0.01, 65536.0, 80.0
this.projectionMatrix = mat4.Projection(fovx.ToRad(), ratio, znear, zfar)
if globals.UseShader {
program.SetProjectionMatrix(this.projectionMatrix)
program.SetFarClipplane(zfar)
}
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.LoadMatrixd(this.projectionMatrix.Ptr())
gl.MatrixMode(gl.MODELVIEW)
}