func reshape(w, h int) { gl.Viewport(0, 0, gl.GLsizei(w), gl.GLsizei(h)) gl.MatrixMode(gl.PROJECTION) gl.LoadIdentity() gl.Ortho(0, gl.GLdouble(w), 0, gl.GLdouble(h), -1, 1) gl.Scalef(1, -1, 1) gl.Translatef(0, gl.GLfloat(-h), 0) gl.MatrixMode(gl.MODELVIEW) }
func stroke_output(x, y gl.GLfloat, str string, font glut.StrokeFont) { gl.PushMatrix() gl.Translatef(x, y, 0) gl.Scalef(0.005, 0.005, 0.005) for _, ch := range str { font.Character(ch) } gl.PopMatrix() }
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) }
func reshape(w, h int) { /* Because Gil specified "screen coordinates" (presumably with an upper-left origin), this short bit of code sets up the coordinate system to correspond to actual window coodrinates. This code wouldn't be required if you chose a (more typical in 3D) abstract coordinate system. */ gl.Viewport(0, 0, w, h) /* Establish viewing area to cover entire window. */ gl.MatrixMode(gl.PROJECTION) /* Start modifying the projection matrix. */ gl.LoadIdentity() /* Reset project matrix. */ gl.Ortho(0, float64(w), 0, float64(h), -1, 1) /* Map abstract coords directly to window coords. */ gl.Scalef(1, -1, 1) /* Invert Y axis so increasing Y goes down. */ gl.Translatef(0, float32(-h), 0) /* Shift origin up to upper-left corner. */ }
func reshape(w, h int) { /* Because Gil specified "screen coordinates" (presumably with an upper-left origin), this short bit of code sets up the coordinate system to correspond to actual window coodrinates. This code wouldn't be required if you chose a (more typical in 3D) abstract coordinate system. */ gl.ClearColor(1, 1, 1, 1) //fmt.Println(gl.GetString(gl.EXTENSIONS)) gl.Viewport(0, 0, w, h) /* Establish viewing area to cover entire window. */ gl.MatrixMode(gl.PROJECTION) /* Start modifying the projection matrix. */ gl.LoadIdentity() /* Reset project matrix. */ gl.Ortho(0, float64(w), 0, float64(h), -1, 1) /* Map abstract coords directly to window coords. */ gl.Scalef(1, -1, 1) /* Invert Y axis so increasing Y goes down. */ gl.Translatef(0, float32(-h), 0) /* Shift origin up to upper-left corner. */ gl.Enable(gl.BLEND) gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA) gl.Disable(gl.DEPTH_TEST) width, height = w, h }
func (f *Font) DrawText3D(pos Vector3, color [3]byte, scale float, txt string) (endw int, endh int) { gl.LoadIdentity() // gl.Translatef(gl.GLfloat(pos.X), gl.GLfloat(pos.Y), gl.GLfloat(-4.99)); gl.Translatef(gl.GLfloat(pos.X), gl.GLfloat(pos.Y), gl.GLfloat(-4.99)) gl.Scalef(gl.GLfloat(1.0/64.0*scale), gl.GLfloat(1.0/64.0*scale), gl.GLfloat(1.0)) gl.Disable(gl.DEPTH_TEST) texture, initial, intermediarya, intermediary, w, h := f.setupTextRendering(color, txt) wi := gl.GLfloat(w) he := gl.GLfloat(h) locX := gl.GLfloat(0) - wi*0.5 locY := gl.GLfloat(0) - he*0.5 /* Draw a quad at location */ gl.Begin(gl.QUADS) /* Recall that the origin is in the lower-left corner That is why the TexCoords specify different corners than the Vertex coors seem to. */ gl.Color4f(1.0, 1.0, 0.0, 1.0) gl.TexCoord2f(0.0, 1.0) gl.Vertex3f(locX, locY, 0.0) gl.TexCoord2f(1.0, 1.0) gl.Vertex3f(locX+wi, locY, 0.0) gl.TexCoord2f(1.0, 0.0) gl.Vertex3f(locX+wi, locY+he, 0.0) gl.TexCoord2f(0.0, 0.0) gl.Vertex3f(locX, locY+he, 0.0) gl.End() endw, endh = f.teardownTextRendering(texture, initial, intermediarya, intermediary) gl.Enable(gl.DEPTH_TEST) return }