本文整理汇总了Golang中github.com/chsc/gogl/gl21.Viewport函数的典型用法代码示例。如果您正苦于以下问题:Golang Viewport函数的具体用法?Golang Viewport怎么用?Golang Viewport使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Viewport函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: resize
// resize resizes the window to the specified dimensions.
func resize(width, height int) {
gl.Viewport(0, 0, gl.Sizei(width), gl.Sizei(height))
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(-30.0, 30.0, -30.0, 30.0, -30.0, 30.0)
gl.MatrixMode(gl.MODELVIEW)
}
示例2: InitViewport
func InitViewport() {
gl.Viewport(0, 0, gl.Sizei(Width), gl.Sizei(Height))
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
x := gl.Double(float64(Height) / float64(Width))
gl.Frustum(-1./2., 1./2., -x/2, x/2, 10, 100)
}
示例3: run
func (w *Window) run() {
runtime.LockOSThread()
glfw.MakeContextCurrent(w.w)
defer glfw.MakeContextCurrent(nil)
// glfw should fire initial resize events to avoid this duplication (https://github.com/glfw/glfw/issues/62)
width, height := w.w.Size()
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(0, gl.Double(width), 0, gl.Double(height), -1, 1)
Resize(w, Pt(float64(width), float64(height)))
width, height = w.w.FramebufferSize()
gl.Viewport(0, 0, gl.Sizei(width), gl.Sizei(height))
gl.Enable(gl.BLEND)
gl.Enable(gl.POINT_SMOOTH)
gl.Enable(gl.LINE_SMOOTH)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
for !w.close {
select {
case f := <-w.do:
f()
case <-w.paint:
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
w.base().paint()
w.w.SwapBuffers()
}
}
}
示例4: initScene
func initScene() {
input.Init()
life = automata.NewLife(*flagRule, *flagSize, *flagDelay, *flagSeed)
input.Sim = life
go life.Run()
gl.ClearColor(0.0, 0.0, 0.0, 0.0)
gl.Viewport(0, 0, Width, Height)
}
示例5: windowResizeCallback
func windowResizeCallback(window *glfw.Window, width, height int) {
paunchWindow.width = width
paunchWindow.height = height
for _, eventManager := range paunchWindow.eventManagers {
eventManager.RunWindowResizeEvent(width, height)
}
gl.Viewport(0, 0, gl.Sizei(width), gl.Sizei(height))
}
示例6: RenderLocalEditor
func (g *Game) RenderLocalEditor(region g2.Region) {
g.editor.Lock()
defer g.editor.Unlock()
g.editor.region = region
g.editor.camera.regionDims = linear.Vec2{float64(region.Dims.Dx), float64(region.Dims.Dy)}
levelDims := linear.Vec2{float64(g.Level.Room.Dx), float64(g.Level.Room.Dy)}
g.editor.camera.StandardRegion(levelDims.Scale(0.5), levelDims)
g.editor.camera.approachTarget()
gl.MatrixMode(gl.PROJECTION)
gl.PushMatrix()
gl.LoadIdentity()
defer gl.PopMatrix()
gl.PushAttrib(gl.VIEWPORT_BIT)
gl.Viewport(gl.Int(region.X), gl.Int(region.Y), gl.Sizei(region.Dx), gl.Sizei(region.Dy))
defer gl.PopAttrib()
current := &g.editor.camera.current
gl.Ortho(
gl.Double(current.mid.X-current.dims.X/2),
gl.Double(current.mid.X+current.dims.X/2),
gl.Double(current.mid.Y+current.dims.Y/2),
gl.Double(current.mid.Y-current.dims.Y/2),
gl.Double(1000),
gl.Double(-1000),
)
defer func() {
gl.MatrixMode(gl.PROJECTION)
gl.PopMatrix()
gl.MatrixMode(gl.MODELVIEW)
}()
gl.MatrixMode(gl.MODELVIEW)
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
g.renderWalls()
g.renderEdges()
g.renderBases()
g.renderEntsAndAbilities()
g.renderProcesses()
g.editor.renderPathing(&g.Level.Room, g.local.pathingData)
switch g.editor.action {
case editorActionNone:
case editorActionPlaceBlock:
g.editor.renderPlaceBlock(g)
default:
base.Error().Printf("Unexpected editorAction: %v", g.editor.action)
}
}
示例7: initScene
func initScene(width, height int, init func()) (err error) {
gl.Disable(gl.DEPTH_TEST)
gl.ClearColor(0.5, 0.5, 0.5, 0.0)
gl.Viewport(0, 0, gl.Sizei(width), gl.Sizei(height))
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(0, gl.Double(width), gl.Double(height), 0, 0, 1)
gl.MatrixMode(gl.MODELVIEW)
init()
return
}
示例8: Init
func (s *Scene) Init() (err error) {
runtime.LockOSThread()
gl.Enable(gl.TEXTURE_2D)
gl.Enable(gl.DEPTH_TEST)
gl.ClearColor(0.0, 0.0, 0.0, 0.0)
gl.ClearDepth(1)
//gl.DepthFunc(gl.LEQUAL)
gl.Viewport(0, 0, Width, Height)
mm.init()
return
}
示例9: OnResize
func (a *app) OnResize(w, h int) {
oaspect := float64(a.imgW()) / float64(a.imgH())
haspect := float64(w) / float64(h)
vaspect := float64(h) / float64(w)
var scx, scy float64
if oaspect > haspect {
scx = 1
scy = haspect / oaspect
} else {
scx = vaspect * oaspect
scy = 1
}
gl.Viewport(0, 0, gl.Sizei(w), gl.Sizei(h))
gl.LoadIdentity()
gl.Scaled(gl.Double(scx), gl.Double(scy), 1)
}
示例10: SetUpCamera
func SetUpCamera(
screenWidth int32,
screenHeight int32,
lb *LevelBlueprint,
playerIndex int32) {
pb := &lb.Players[playerIndex]
// Calculate the distance between the near plane and the camera. We want
// (PaddleAreaWidth / 2) / cameraDist = tan(CameraHorzFovDegrees / 2)
t := math.Tan(math.Pi * Config.CameraHorzFovDegrees / 360)
cameraDist := pb.PaddleAreaWidth / (2 * t)
cameraPos := pb.PaddleAreaCenter.Minus(
pb.Orientation.Forward.Times(cameraDist))
// Set up the projection matrix.
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Viewport(0, 0, gl.Sizei(screenWidth), gl.Sizei(screenHeight))
gl.Frustum(
gl.Double(-pb.PaddleAreaWidth/2), gl.Double(pb.PaddleAreaWidth/2),
gl.Double(-pb.PaddleAreaHeight/2), gl.Double(pb.PaddleAreaHeight/2),
gl.Double(cameraDist), gl.Double(cameraDist+Config.ViewDepth))
// Set up the modelview matrix.
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
transformation := [16]gl.Double{
gl.Double(pb.Orientation.Right.X),
gl.Double(pb.Orientation.Up.X),
gl.Double(-pb.Orientation.Forward.X),
gl.Double(0.0),
gl.Double(pb.Orientation.Right.Y),
gl.Double(pb.Orientation.Up.Y),
gl.Double(-pb.Orientation.Forward.Y),
gl.Double(0.0),
gl.Double(pb.Orientation.Right.Z),
gl.Double(pb.Orientation.Up.Z),
gl.Double(-pb.Orientation.Forward.Z),
gl.Double(0.0),
gl.Double(0.0), gl.Double(0.0), gl.Double(0.0), gl.Double(1.0)}
gl.MultMatrixd(&transformation[0])
gl.Translated(
gl.Double(-cameraPos.X),
gl.Double(-cameraPos.Y),
gl.Double(-cameraPos.Z))
}
示例11: RenderLocalGame
func (g *Game) RenderLocalGame(region g2.Region) {
g.local.Camera.regionDims = linear.Vec2{float64(region.Dims.Dx), float64(region.Dims.Dy)}
// func (g *Game) renderLocalHelper(region g2.Region, local *LocalData, camera *cameraInfo, side int) {
g.local.Camera.FocusRegion(g, 0)
gl.MatrixMode(gl.PROJECTION)
gl.PushMatrix()
gl.LoadIdentity()
// Set the viewport so that we only render into the region that we're supposed
// to render to.
// TODO: Check if this works on all graphics cards - I've heard that the opengl
// spec doesn't actually require that viewport does any clipping.
gl.PushAttrib(gl.VIEWPORT_BIT)
gl.Viewport(gl.Int(region.X), gl.Int(region.Y), gl.Sizei(region.Dx), gl.Sizei(region.Dy))
defer gl.PopAttrib()
current := &g.local.Camera.current
gl.Ortho(
gl.Double(current.mid.X-current.dims.X/2),
gl.Double(current.mid.X+current.dims.X/2),
gl.Double(current.mid.Y+current.dims.Y/2),
gl.Double(current.mid.Y-current.dims.Y/2),
gl.Double(1000),
gl.Double(-1000),
)
defer func() {
gl.MatrixMode(gl.PROJECTION)
gl.PopMatrix()
gl.MatrixMode(gl.MODELVIEW)
}()
gl.MatrixMode(gl.MODELVIEW)
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
level := g.Level
zoom := current.dims.X / float64(region.Dims.Dx)
level.ManaSource.Draw(zoom, float64(level.Room.Dx), float64(level.Room.Dy))
g.renderWalls()
g.renderEdges()
g.renderBases()
g.renderEntsAndAbilities()
g.renderProcesses()
g.RenderLosMask()
}
示例12: PositionCamera
func PositionCamera(x, y gl.Double, width, height gl.Sizei) {
texs.Disable2d()
texs.Enable2d(x, y, 1000, 900)
gl.Viewport(0, 0, 1000, 900)
gl.LoadIdentity()
title := strconv.FormatInt(int64(x), 10) + " , " + strconv.FormatInt(int64(y), 10)
glfw.SetWindowTitle(title)
X = x
y = Y
Width = width
Height = height
//UpdateActiveSystems()
}
示例13: initScene
func initScene() {
gl.Disable(gl.TEXTURE_2D)
gl.Disable(gl.DEPTH_TEST)
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
gl.Disable(gl.ALPHA_TEST)
gl.Enable(gl.LINE_SMOOTH)
gl.Hint(gl.LINE_SMOOTH_HINT, gl.NICEST)
gl.PolygonMode(gl.FRONT_AND_BACK, gl.LINE)
gl.LineWidth(1.0)
gl.ClearColor(0.0, 0.0, 0.0, 0.0)
gl.ClearDepth(1)
//gl.DepthFunc(gl.LEQUAL)
gl.Viewport(0, 0, Width, Height)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
perspective(110.0, 1.0, 4, 8192)
}
示例14: glInit
func glInit(width, height int) {
gl.Init()
gl.Enable(gl.TEXTURE_2D)
gl.PixelStorei(gl.UNPACK_ALIGNMENT, 1)
gl.Viewport(0, 0, gl.Sizei(width), gl.Sizei(height))
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(0, gl.Double(width), gl.Double(height), 0, -1, 1)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
gl.EnableClientState(gl.VERTEX_ARRAY)
gl.EnableClientState(gl.COLOR_ARRAY)
gl.EnableClientState(gl.TEXTURE_COORD_ARRAY)
gl.VertexPointer(2, gl.FLOAT, 0, gl.Pointer(&vs[0]))
gl.ColorPointer(3, gl.UNSIGNED_BYTE, 0, gl.Pointer(&cs[0]))
gl.TexCoordPointer(2, gl.FLOAT, 0, gl.Pointer(&ts[0]))
}
示例15: initScene
func (o *OpenGl) initScene() (err error) {
gl.ClearColor(0.0, 0.0, 0.0, 0.0)
gl.ClearDepth(1)
gl.DepthFunc(gl.LEQUAL)
ambient := []gl.Float{0.5, 0.5, 0.5, 1}
diffuse := []gl.Float{1, 1, 1, 1}
position := []gl.Float{-5, 5, 10, 0}
gl.Lightfv(gl.LIGHT0, gl.AMBIENT, &ambient[0])
gl.Lightfv(gl.LIGHT0, gl.DIFFUSE, &diffuse[0])
gl.Lightfv(gl.LIGHT0, gl.POSITION, &position[0])
gl.Viewport(0, 0, gl.Sizei(o.width), gl.Sizei(o.height))
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Frustum(-1, 1, -1, 1, 1.0, 10.0)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
return nil
}