本文整理汇总了Golang中github.com/chsc/gogl/gl21.MatrixMode函数的典型用法代码示例。如果您正苦于以下问题:Golang MatrixMode函数的具体用法?Golang MatrixMode怎么用?Golang MatrixMode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MatrixMode函数的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: 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
示例3: Draw
func (g *Gui) Draw() {
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(gl.Double(g.region.X), gl.Double(g.region.X+g.region.Dx), gl.Double(g.region.Y+g.region.Dy), gl.Double(g.region.Y), 1000, -1000)
gl.ClearColor(0, 0, 0, 1)
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
g.root.Draw(g.region, &styleStack{})
}
开发者ID:runningwild,项目名称:jota,代码行数:10,代码来源:gui.go
示例4: set2dView
func (o *OpenGl) set2dView() {
gl.Disable(gl.TEXTURE_2D)
gl.Disable(gl.DEPTH_TEST)
gl.Disable(gl.LIGHTING)
gl.Disable(gl.LIGHT0)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(0, gl.Double(o.width), 0, gl.Double(o.height), -1, 1)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
}
开发者ID:knickers,项目名称:GOpenGL,代码行数:11,代码来源:GOpenGL.go
示例5: 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
示例6: set3dView
func (o *OpenGl) set3dView() {
gl.Enable(gl.TEXTURE_2D)
gl.Enable(gl.DEPTH_TEST)
gl.Enable(gl.LIGHTING)
gl.Enable(gl.LIGHT0)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
//gl.Perspective(cam.Zoom(), o.mW / o.mH, cam.Near(), cam.Far())
gl.MatrixMode(gl.MODELVIEW)
//e := o.Camera.EYE()
//a := o.Camera.AT()
//u := o.Camera.UP()
//gl.LookAt(e.X, e.Y, e.Z, a.X, a.Y, a.Z, u.X, u.Y, u.Z)
}
开发者ID:knickers,项目名称:GOpenGL,代码行数:14,代码来源:GOpenGL.go
示例7: Draw
func (g *Gui) Draw() {
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
region := g.root.Render_region
gl.Ortho(gl.Double(region.X), gl.Double(region.X+region.Dx), gl.Double(region.Y), gl.Double(region.Y+region.Dy), 1000, -1000)
gl.ClearColor(0, 0, 0, 1)
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
g.root.Draw(region)
if g.FocusWidget() != nil {
g.FocusWidget().DrawFocused(region)
}
}
开发者ID:dgthunder,项目名称:glop,代码行数:14,代码来源:gui.go
示例8: 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
示例9: drawScene
func drawScene() {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Rotated(-90, 1, 0, 0)
//gl.Rotated(90, 0, 0, 1)
gl.Rotated(gl.Double(-viewAngles[2]), 1, 0, 0)
gl.Rotated(gl.Double(-viewAngles[0]), 0, 1, 0)
gl.Rotated(gl.Double(-viewAngles[1]), 0, 0, 1)
gl.Translated(gl.Double(viewOrg[0]), gl.Double(viewOrg[1]), gl.Double(viewOrg[2]))
var r, g, b gl.Ubyte
for i, face := range model.Faces {
r = gl.Ubyte(i) + 100
g = gl.Ubyte(i>>1) + 100
b = gl.Ubyte(i>>2) + 100
if model.Triangle {
gl.Begin(gl.TRIANGLES)
} else {
gl.Begin(gl.LINES)
}
gl.Color4ub(r, g, b, 0xff)
for _, v := range face.Verts {
gl.Vertex3d(gl.Double(v.Pos[0]), gl.Double(v.Pos[1]), gl.Double(v.Pos[2]))
}
gl.End()
}
}
开发者ID:jayschwa,项目名称:groke,代码行数:33,代码来源:bspview.go
示例10: 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
示例11: drawScene
func drawScene() {
fps()
gl.Clear(gl.COLOR_BUFFER_BIT)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
if input.Zoom > 0 {
gl.Ortho(0, gl.Double(float64(*flagSize)/input.Zoom), gl.Double(float64(*flagSize)/input.Zoom), 0, -1, 1.0)
}
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Translatef(gl.Float(input.TransX*1), gl.Float(input.TransY*1), 0)
drawGrid()
drawCells()
}
开发者ID:dskinner,项目名称:cell,代码行数:16,代码来源:main.go
示例12: run
func (w *Window) run(init func(w *Window)) {
runtime.LockOSThread()
glfw.MakeContextCurrent(w.w)
defer glfw.MakeContextCurrent(nil)
init(w)
// glfw should fire initial resize events to avoid this duplication (https://github.com/glfw/glfw/issues/62)
w.resized(w.w.Size())
w.framebufferResized(w.w.FramebufferSize())
gl.Enable(gl.SCISSOR_TEST)
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.Scissor(0, 0, w.bufWidth, w.bufHeight)
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
w.base().paint()
w.w.SwapBuffers()
}
}
}
开发者ID:gordonklaus,项目名称:gui,代码行数:32,代码来源:window.go
示例13: UpdateViewpos
// Set the GL modelview matrix to match view position and orientation.
func UpdateViewpos() {
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Translatef(gl.Float(Viewpos[0]), gl.Float(Viewpos[1]), gl.Float(Viewpos[2]))
gl.Rotatef(gl.Float(Rot[0]*2), 1, 0, 0)
gl.Rotatef(gl.Float(Rot[1]*2), 0, 1, 0)
gl.Rotatef(gl.Float(Rot[2]*2), 0, 0, 1)
}
开发者ID:shenyp09,项目名称:mx3,代码行数:9,代码来源:input.go
示例14: 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
示例15: getPlayers
func getPlayers(console *base.Console) []gin.DeviceId {
var ct controllerTracker
gin.In().RegisterEventListener(&ct)
defer gin.In().UnregisterEventListener(&ct)
ticker := time.Tick(time.Millisecond * 17)
start := time.Time{}
readyDuration := time.Second * 2
for start.IsZero() || time.Now().Sub(start) < readyDuration {
<-ticker
sys.Think()
if ct.Ready() && start.IsZero() {
start = time.Now()
}
if !ct.Ready() {
start = time.Time{}
}
render.Queue(func() {
defer console.Draw(0, 0, wdx, wdy)
gl.Clear(gl.COLOR_BUFFER_BIT)
gl.Disable(gl.DEPTH_TEST)
gui.SetFontColor(1, 1, 1, 1)
gl.Disable(gl.TEXTURE_2D)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(gl.Double(0), gl.Double(wdx), gl.Double(wdy), gl.Double(0), 1000, -1000)
gl.ClearColor(0, 0, 0, 1)
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
base.GetDictionary("crackin").RenderString(fmt.Sprintf("Num players: %d", len(ct.ids)), float64(wdx)/2, 300, 0, 100, gui.Center)
base.GetDictionary("crackin").RenderString(fmt.Sprintf("Num ready: %d", ct.NumReady()), float64(wdx)/2, 400, 0, 100, gui.Center)
if !start.IsZero() {
base.GetDictionary("crackin").RenderString(fmt.Sprintf("Starting in %2.2f", (readyDuration-time.Now().Sub(start)).Seconds()), float64(wdx)/2, 500, 0, 100, gui.Center)
}
})
render.Queue(func() {
sys.SwapBuffers()
})
render.Purge()
}
var devices []gin.DeviceId
for id := range ct.ids {
devices = append(devices, id)
}
return devices
}
开发者ID:runningwild,项目名称:jbot,代码行数:46,代码来源:main.go
示例16: mainLoop
func mainLoop(client sgf.ClientEngine, controllers []gin.DeviceId, console *base.Console) {
client.MakeRequest(game.Join{Rebels: make([]*game.RebelPlayer, 2)})
ticker := time.Tick(time.Millisecond * 17)
render.Queue(func() {
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
})
for {
<-ticker
if gin.In().GetKey(gin.AnyEscape).FramePressCount() != 0 {
return
}
sys.Think()
render.Queue(func() {
gl.Clear(gl.COLOR_BUFFER_BIT)
gl.Disable(gl.DEPTH_TEST)
gui.SetFontColor(1, 1, 1, 1)
gl.Disable(gl.TEXTURE_2D)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(gl.Double(0), gl.Double(wdx), gl.Double(wdy), gl.Double(0), 1000, -1000)
gl.ClearColor(0, 0, 0, 1)
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
base.GetDictionary("crackin").RenderString("Waiting on some nubs", float64(wdx)/2, 300, 0, 100, gui.Center)
})
client.RLock()
g := client.Game().(*game.Game)
mode := g.Mode
client.RUnlock()
if mode == game.ModeWaiting {
} else if mode == game.ModeProgram {
programLoop(client, controllers, console)
} else if mode == game.ModeRun {
}
render.Queue(func() {
sys.SwapBuffers()
})
render.Purge()
}
}
开发者ID:runningwild,项目名称:jbot,代码行数:45,代码来源:main.go
示例17: 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
示例18: Enable2d
func Enable2d(x1, y1, w, h gl.Double) {
// Save a copy of the proj matrix so we can restore it
// when we want to do more 3d rendering
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
// Set up orthographic projection
gl.Ortho(x1, x1+w, y1, y1+h, 0.0, 1)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
// Make sure depth testing and lighting are disabled for 2d redering
// until we are fninished rendering in 2d
gl.PushAttrib(gl.DEPTH_BUFFER_BIT | gl.LIGHTING_BIT)
gl.Disable(gl.DEPTH_TEST)
gl.Disable(gl.LIGHTING)
}
开发者ID:kelly-ry4n,项目名称:glGalaxy,代码行数:18,代码来源:texloader.go
示例19: resized
func (w *Window) resized(width, height int) {
wid, hei := float64(width), float64(height)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(0, gl.Double(wid), 0, gl.Double(hei), -1, 1)
w.Self.Resize(wid, hei)
if w.centralView != nil {
w.centralView.Resize(wid, hei)
}
}
开发者ID:gordonklaus,项目名称:gui,代码行数:10,代码来源:window.go
示例20: 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
注:本文中的github.com/chsc/gogl/gl21.MatrixMode函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论