本文整理匯總了Golang中github.com/chsc/gogl/gl21.LoadIdentity函數的典型用法代碼示例。如果您正苦於以下問題:Golang LoadIdentity函數的具體用法?Golang LoadIdentity怎麽用?Golang LoadIdentity使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了LoadIdentity函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: 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()
}
}
}
示例2: 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{})
}
示例3: 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()
}
示例4: 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)
}
}
示例5: 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()
}
}
示例6: 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)
}
示例7: 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()
}
示例8: 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()
}
}
}
示例9: 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)
}
示例10: 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
}
示例11: 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))
}
示例12: 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)
}
示例13: 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()
}
}
示例14: 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)
}
示例15: 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)
}
}