本文整理汇总了Golang中github.com/go-gl/gl.Ortho函数的典型用法代码示例。如果您正苦于以下问题:Golang Ortho函数的具体用法?Golang Ortho怎么用?Golang Ortho使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Ortho函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Enter
func (wc WindowCoords) Enter() {
w, h := GetViewportWH()
Matrix{gl.PROJECTION}.Enter()
if !wc.NoReset {
gl.LoadIdentity()
}
if wc.Invert {
gl.Ortho(0, float64(w), float64(h), 0, -1, 1)
} else {
gl.Ortho(0, float64(w), 0, float64(h), -1, 1)
}
Matrix{gl.MODELVIEW}.Enter()
gl.LoadIdentity()
}
示例2: 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)
}
示例3: Reshape
func Reshape(w, h int) {
gl.Viewport(0, 0, w, h)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(0, 100, 0, 100, -1, 1)
gl.MatrixMode(gl.MODELVIEW)
}
示例4: initWindow
func initWindow() {
// Function called to do the re-rendering
glut.DisplayFunc(display)
// Called when the visibility of the program changes
glut.VisibilityFunc(visible)
// Called when a regular ascii character is pressed
glut.KeyboardFunc(keyboardIn)
// Called when any non-ascii character is pressed
glut.SpecialFunc(specialIn)
// Called when the size of the window changes
glut.ReshapeFunc(reshape)
// affect our projection matrix
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity() // Load an identity matrix -> projection
// Specify the bounds of the of our scene
gl.Ortho(0, 40, 0, 40, 0, 40)
// Now affect our modelview matrix
gl.MatrixMode(gl.MODELVIEW)
// Make points be rendererd larger
gl.PointSize(3.0)
currentWindow = glut.GetWindow()
}
示例5: InitDisplay
func InitDisplay() {
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(0, 100, 0, 100, -1, 1)
gl.MatrixMode(gl.MODELVIEW)
gl.PointSize(3.0)
}
示例6: 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)
}
示例7: initGL
func initGL() {
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Viewport(0, 0, 800, 600)
gl.Ortho(0, 800, 600, 0, -1.0, 1.0)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.ClearColor(0.1, 0.05, 0.0, 1.0)
}
示例8: main
func main() {
_ = fmt.Sprint()
if !glfw.Init() {
panic("Can't init glfw!")
}
defer glfw.Terminate()
// antialiasing
//glfw.WindowHint(glfw.Samples, 4)
window, err = glfw.CreateWindow(WindowWidth, WindowHeight, "Mozaik", nil, nil)
if err != nil {
panic(err)
}
defer window.Destroy()
// Ensure thread context
window.MakeContextCurrent()
//glfw.SwapInterval(1)
window.SetKeyCallback(keyCb)
window.SetMouseButtonCallback(mouseCb)
gl.Init()
gl.ClearColor(0.9, 0.85, 0.46, 0.0)
// useless in 2D
gl.Disable(gl.DEPTH_TEST)
// antialiasing
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
gl.Enable(gl.LINE_SMOOTH)
for i := int32(32); i < 72; i++ {
font := loadFonts(i)
defer font.Release()
fonts = append(fonts, font)
}
// Compute window radius
windowRadius = math.Sqrt(math.Pow(WindowHeight, 2) + math.Pow(WindowWidth, 2))
// Use window coordinates
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(0, WindowWidth, WindowHeight, 0, 0, 1)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
g = NewGame()
g.Start()
go eventLoop(g)
go renderLoop(g)
Main()
g.Stop()
}
示例9: onResize
// TODO Dynamically fetch size and render accordingly.
func onResize(w, h int) {
gl.Viewport(0, 0, w, h)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(0, float64(w), float64(h), 0, -1, 1)
gl.ClearColor(0.255, 0.255, 0.255, 0)
gl.Clear(gl.COLOR_BUFFER_BIT)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
// log.Printf("resized: %dx%d\n", w, h)
}
示例10: onResize
// onResize sets up a simple 2d ortho context based on the window size
func onResize(window *glfw.Window, w, h int) {
w, h = window.GetSize() // query window to get screen pixels
width, height := window.GetFramebufferSize()
gl.Viewport(0, 0, width, height)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(0, float64(w), 0, float64(h), -1, 1)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.ClearColor(1, 1, 1, 1)
}
示例11: reshape
func reshape(w, h int) {
// Write to both buffers, prevent flickering
gl.DrawBuffer(gl.FRONT_AND_BACK)
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.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
}
示例12: setupGL
func setupGL(w, h int) {
gl.Viewport(0, 0, w, h)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(0, float64(w), float64(h), 0, 0, 1)
gl.ShadeModel(gl.SMOOTH)
gl.ClearColor(1, 1, 1, 0)
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
gl.Disable(gl.DEPTH_TEST)
gl.Hint(gl.LINE_SMOOTH_HINT|gl.LINE_SMOOTH_HINT, gl.NICEST)
}
示例13: onResize
func onResize(w, h int) {
// Write to both buffers, prevent flickering
gl.DrawBuffer(gl.FRONT_AND_BACK)
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()
}
示例14: Reshape
func Reshape(width, height int) {
gl.Viewport(0, 0, width, height)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(-1, 1, -1, 1, -1, 1)
//gl.Ortho(-2.1, 6.1, -2.25*2, 2.1*2, -1, 1) // Y debug
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.ClearColor(0, 0, 0, 1)
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
}
示例15: reshapeWindow
func reshapeWindow(window *glfw.Window, width, height int) {
ratio := float64(width) / float64(height)
gameWidth = ratio * fieldSize
gameHeight = fieldSize
gl.Viewport(0, 0, width, height)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(0, gameWidth, 0, gameHeight, -1.0, 1.0)
gl.MatrixMode(gl.MODELVIEW)
if wireframe {
gl.PolygonMode(gl.FRONT_AND_BACK, gl.LINE)
}
}