本文整理汇总了Golang中github.com/chsc/gogl/gl21.Viewport函数的典型用法代码示例。如果您正苦于以下问题:Golang Viewport函数的具体用法?Golang Viewport怎么用?Golang Viewport使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Viewport函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
}
开发者ID:travis1230,项目名称:RosettaCodeData,代码行数:8,代码来源:opengl.go
示例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)
}
开发者ID:shenyp09,项目名称:mx3,代码行数:7,代码来源:input.go
示例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()
}
}
}
开发者ID:gordonklaus,项目名称:flux,代码行数:33,代码来源:window.go
示例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)
}
开发者ID:dskinner,项目名称:cell,代码行数:8,代码来源:main.go
示例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))
}
开发者ID:velovix,项目名称:paunch,代码行数:11,代码来源:window.go
示例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)
}
}
开发者ID:runningwild,项目名称:jota,代码行数:53,代码来源:editor_graphics.go
示例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
}
开发者ID:jaredly,项目名称:rocks,代码行数:15,代码来源:draw.go
示例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
}
开发者ID:drasich,项目名称:ridley,代码行数:15,代码来源:scene.go
示例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)
}
开发者ID:jacereda,项目名称:webmplay,代码行数:16,代码来源:webmplay.go
示例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))
}
开发者ID:runningwild,项目名称:arkanoid,代码行数:46,代码来源:level-blueprint.go
示例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()
}
开发者ID:runningwild,项目名称:jota,代码行数:45,代码来源:game_graphics.go
示例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()
}
开发者ID:kelly-ry4n,项目名称:glGalaxy,代码行数:19,代码来源:movement.go
示例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)
}
开发者ID:jayschwa,项目名称:groke,代码行数:20,代码来源:bspview.go
示例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]))
}
开发者ID:ajhager,项目名称:rog,代码行数:20,代码来源:backend.go
示例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
}
开发者ID:knickers,项目名称:GOpenGL,代码行数:21,代码来源:GOpenGL.go
示例16: initScene
func initScene() (err error) {
gl.Enable(gl.TEXTURE_2D)
gl.Enable(gl.DEPTH_TEST)
gl.Enable(gl.LIGHTING)
gl.ClearColor(0.5, 0.5, 0.5, 0.0)
gl.ClearDepth(1)
gl.DepthFunc(gl.LEQUAL)
gl.Lightfv(gl.LIGHT0, gl.AMBIENT, &ambient[0])
gl.Lightfv(gl.LIGHT0, gl.DIFFUSE, &diffuse[0])
gl.Lightfv(gl.LIGHT0, gl.POSITION, &lightpos[0])
gl.Enable(gl.LIGHT0)
gl.Viewport(0, 0, Width, Height)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Frustum(-1, 1, -1, 1, 1.0, 10.0)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
texture, err = createTextureFromBytes(gopher_png[:])
return
}
开发者ID:sserafimescu,项目名称:gogl,代码行数:24,代码来源:gopher.go
示例17: initScene
func initScene() {
gl.Enable(gl.DEPTH_TEST)
gl.Enable(gl.LIGHTING)
gl.ClearColor(0.1, 0.1, 0.6, 1.0)
gl.ClearDepth(1)
gl.DepthFunc(gl.LEQUAL)
gl.Lightfv(gl.LIGHT0, gl.AMBIENT, &ambient[0])
gl.Lightfv(gl.LIGHT0, gl.DIFFUSE, &diffuse[0])
gl.Lightfv(gl.LIGHT0, gl.POSITION, &lightPos[0])
gl.Enable(gl.LIGHT0)
gl.Viewport(0, 0, Width, Height)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Frustum(-1, 1, -1, 1, 1.0, 1000.0)
gl.Rotatef(20, 1, 0, 0)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.PushMatrix()
return
}
开发者ID:ReneSac,项目名称:ParticleBench,代码行数:24,代码来源:Go.go
示例18: registerCallbacks
func (w *Window) registerCallbacks() {
w.w.OnFocus(func(focused bool) {
if focused {
go doMain(func() {
for i, w2 := range windows {
if w2 == w {
windows = append(append([]*Window{w}, windows[:i]...), windows[i+1:]...)
break
}
}
})
}
})
w.w.OnClose(w.Close)
w.w.OnResize(func(width, height int) {
w.Do(func() {
s := Pt(float64(width), float64(height))
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(0, gl.Double(s.X), 0, gl.Double(s.Y), -1, 1)
Resize(w.Self, s)
if w.centralView != nil {
Resize(w.centralView, s)
}
})
})
w.w.OnFramebufferResize(func(width, height int) {
w.Do(func() {
gl.Viewport(0, 0, gl.Sizei(width), gl.Sizei(height))
})
})
k := KeyEvent{}
w.w.OnKey(func(key, scancode, action, mods int) {
w.Do(func() {
k.Key = key
k.action = action
k.Repeat = action == glfw.Repeat
k.Shift = mods&glfw.ModShift != 0
k.Ctrl = mods&glfw.ModControl != 0
k.Alt = mods&glfw.ModAlt != 0
k.Super = mods&glfw.ModSuper != 0
k.Command = commandKey(k)
if key >= KeyEscape || action == glfw.Release {
k.Text = ""
if w.keyFocus != nil {
if k.action != glfw.Release {
w.keyFocus.KeyPress(k)
} else {
w.keyFocus.KeyRelease(k)
}
}
}
})
})
w.w.OnChar(func(char rune) {
w.Do(func() {
if char < KeyEscape {
k.Text = string(char)
if w.keyFocus != nil {
if k.action != glfw.Release {
w.keyFocus.KeyPress(k)
} else {
w.keyFocus.KeyRelease(k)
}
}
}
})
})
m := MouseEvent{}
w.w.OnMouseMove(func(x, y float64) {
m.Pos = Pt(x, y)
m.Move, m.Press, m.Release, m.Drag = true, false, false, false
w.mouse(m)
})
w.w.OnMouseButton(func(button, action, mods int) {
m.Button = button
m.Move, m.Press, m.Release, m.Drag = false, action == glfw.Press, action == glfw.Release, false
w.mouse(m)
})
w.w.OnScroll(func(dx, dy float64) {
w.Do(func() {
s := ScrollEvent{m.Pos, Pt(dx, -dy)}
s.Pos = w.mapToWindow(s.Pos)
v, _ := viewAtFunc(w.Self, s.Pos, func(v View) View {
v, _ = v.(ScrollerView)
return v
}).(ScrollerView)
if v != nil {
s.Pos = Map(s.Pos, w.Self, v)
v.Scroll(s)
}
})
})
}
开发者ID:gordonklaus,项目名称:flux,代码行数:96,代码来源:window.go
示例19: framebufferResized
func (w *Window) framebufferResized(width, height int) {
w.bufWidth, w.bufHeight = gl.Sizei(width), gl.Sizei(height)
gl.Viewport(0, 0, w.bufWidth, w.bufHeight)
}
开发者ID:gordonklaus,项目名称:gui,代码行数:4,代码来源:window.go
示例20: renderLocalArchitect
func (g *Game) renderLocalArchitect(region g2.Region, local *LocalData) {
local.architect.camera.doArchitectFocusRegion(g, local.sys)
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 := local.architect.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)
zoom := local.architect.camera.current.dims.X / float64(region.Dims.Dx)
level := g.Levels[GidInvadersStart]
level.ManaSource.Draw(local, zoom, float64(level.Room.Dx), float64(level.Room.Dy))
gl.Begin(gl.LINES)
gl.Color4d(1, 1, 1, 1)
for _, poly := range g.Levels[GidInvadersStart].Room.Walls {
for i := range poly {
seg := poly.Seg(i)
gl.Vertex2d(gl.Double(seg.P.X), gl.Double(seg.P.Y))
gl.Vertex2d(gl.Double(seg.Q.X), gl.Double(seg.Q.Y))
}
}
gl.End()
gl.Color4ub(0, 255, 0, 255)
for side, pos := range g.Levels[GidInvadersStart].Room.Starts {
base.GetDictionary("luxisr").RenderString(fmt.Sprintf("S%d", side), pos.X, pos.Y, 0, 100, gui.Center)
}
gl.Color4d(1, 1, 1, 1)
for _, ent := range g.temp.AllEnts {
ent.Draw(g, -1) // TODO: Side isn't defined for architect yet
}
gl.Disable(gl.TEXTURE_2D)
g.renderLosMask(local)
if local.architect.abs.activeAbility != nil {
local.architect.abs.activeAbility.Draw("", g, -1) // TODO: side not defined for architect
}
}
开发者ID:runningwild,项目名称:magnus,代码行数:63,代码来源:local.go
注:本文中的github.com/chsc/gogl/gl21.Viewport函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论