• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang gl.Viewport函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/banthar/gl.Viewport函数的典型用法代码示例。如果您正苦于以下问题:Golang Viewport函数的具体用法?Golang Viewport怎么用?Golang Viewport使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Viewport函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
}
开发者ID:esnowkropla,项目名称:dep,代码行数:7,代码来源:render.go


示例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)
}
开发者ID:charlieb,项目名称:gostrange,代码行数:30,代码来源:main.go


示例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)
}
开发者ID:swantescholz,项目名称:coding,代码行数:7,代码来源:window.go


示例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

}
开发者ID:uriel,项目名称:amberfell,代码行数:28,代码来源:viewport.go


示例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)
}
开发者ID:bombless,项目名称:Fergulator,代码行数:33,代码来源:video.go


示例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)
}
开发者ID:glenn-brown,项目名称:vu,代码行数:27,代码来源:window.go


示例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()
}
开发者ID:navneet1v,项目名称:opengl-go-tutorials,代码行数:35,代码来源:lesson08.go


示例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

}
开发者ID:codygman,项目名称:amberfell,代码行数:28,代码来源:viewport.go


示例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()
}
开发者ID:andrebq,项目名称:tinygl,代码行数:9,代码来源:triangle.go


示例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)
}
开发者ID:tmc,项目名称:glut,代码行数:9,代码来源:fontdemo.go


示例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()
}
开发者ID:sycoso,项目名称:glfw,代码行数:10,代码来源:main.go


示例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)
}
开发者ID:nkostelnik,项目名称:gl,代码行数:13,代码来源:glfwgears.go


示例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()

}
开发者ID:nkostelnik,项目名称:gl,代码行数:53,代码来源:draw.go


示例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)
}
开发者ID:samnardoni,项目名称:ca,代码行数:13,代码来源:ca.go


示例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)
}
开发者ID:swantescholz,项目名称:coding,代码行数:14,代码来源:window.go


示例16: reshape

func reshape(w, 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, w, 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:tmc,项目名称:glut,代码行数:14,代码来源:simple.go


示例17: reshape

func (this *Window) reshape(w, h int) {
	gl.Viewport(0, 0, w, h)
	gl.MatrixMode(gl.PROJECTION)
	gl.LoadIdentity()
	ratio := float64(w) / float64(h)
	znear, zfar, fovx := 0.01, 65536.0, 80.0
	/*var top, bottom, left, right float64
	right = znear * math.Tan(DegToRad(.5*fovx))
	left = -right
	top = right/ratio
	bottom = -top
	gl.Frustum(left,right,bottom,top,znear, zfar)//*/
	this.projectionMatrix = mat4.Projection(DegToRad(fovx), ratio, znear, zfar)
	gl.LoadMatrixd(this.projectionMatrix.Ptr())
	gl.MatrixMode(gl.MODELVIEW)
}
开发者ID:swantescholz,项目名称:go,代码行数:16,代码来源:window.go


示例18: initGl

func initGl() {

	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, -6.0)

	gl.EnableClientState(gl.VERTEX_ARRAY)
	gl.EnableClientState(gl.TEXTURE_COORD_ARRAY)
	gl.VertexPointer(3, 0, &vertices[0][0])
	gl.TexCoordPointer(2, 0, &texCoords[0][0])
}
开发者ID:shogg,项目名称:gltoy,代码行数:18,代码来源:gltoy.go


示例19: InitUI

func InitUI() *UI {
	ui := &UI{
		running: false,
	}

	if sdl.Init(sdl.INIT_EVERYTHING) != 0 {
		panic(sdl.GetError())
	}

	if ttf.Init() != 0 {
		panic(sdl.GetError())
	}

	ui.screen = sdl.SetVideoMode(300, 300, 32, sdl.OPENGL)

	if ui.screen == nil {
		panic("sdl error")
	}

	if gl.Init() != 0 {
		panic("gl error")
	}

	gl.MatrixMode(gl.PROJECTION)

	gl.Viewport(0, 0, int(ui.screen.W), int(ui.screen.H))
	gl.LoadIdentity()
	gl.Ortho(0, float64(ui.screen.W), float64(ui.screen.H), 0, -1.0, 1.0)

	gl.ClearColor(1, 1, 1, 0)
	gl.Clear(gl.COLOR_BUFFER_BIT)

	// TTF
	sdl.EnableUNICODE(1)
	ui.font = ttf.OpenFont("FontinSans.otf", 20)
	ui.font.SetStyle(ttf.STYLE_UNDERLINE)
	if ui.font == nil {
		panic(sdl.GetError())
	}

	ui.running = true

	return ui
}
开发者ID:erikmuttersbach,项目名称:PotentialFieldGL,代码行数:44,代码来源:ui.go


示例20: onResize

func onResize(w, h int) {
	if h == 0 {
		h = 1
	}

	gl.Viewport(0, 0, w, h)

	scale := math.Min(float64(w)/640.0, float64(h)/480.0)
	hw := float64(w) * (0.5 / scale)
	hh := float64(h) * (0.5 / scale)

	gl.MatrixMode(gl.PROJECTION)
	gl.LoadIdentity()
	gl.Ortho(-hw, hw, -hh, hh, -1.0, 1.0)
	gl.Translated(0.5, 0.5, 0.0)

	Width = w
	Height = h
}
开发者ID:ftrvxmtrx,项目名称:gochipmunk,代码行数:19,代码来源:main.go



注:本文中的github.com/banthar/gl.Viewport函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang sdl.GL_SwapBuffers函数代码示例发布时间:2022-05-24
下一篇:
Golang gl.Vertex3f函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap