func display() { gl.Clear(gl.COLOR_BUFFER_BIT) bitmap_output(40, 35, "This is written in a GLUT bitmap font.", glut.BITMAP_TIMES_ROMAN_24) bitmap_output(30, 210, "More bitmap text is a fixed 9 by 15 font.", glut.BITMAP_9_BY_15) bitmap_output(70, 240, " Helvetica is yet another bitmap font.", glut.BITMAP_HELVETICA_18) gl.MatrixMode(gl.PROJECTION) gl.PushMatrix() gl.LoadIdentity() glu.Perspective(40.0, 1.0, 0.1, 20.0) gl.MatrixMode(gl.MODELVIEW) gl.PushMatrix() glu.LookAt(0.0, 0.0, 4.0, /* eye is at (0,0,30) */ 0.0, 0.0, 0.0, /* center is at (0,0,0) */ 0.0, 1.0, 0.0) /* up is in postivie Y direction */ gl.PushMatrix() gl.Translatef(0, 0, -4) gl.Rotatef(50, 0, 1, 0) stroke_output(-2.5, 1.1, " This is written in a", glut.STROKE_ROMAN) stroke_output(-2.5, 0, " GLUT stroke font.", glut.STROKE_ROMAN) stroke_output(-2.5, -1.1, "using 3D perspective.", glut.STROKE_ROMAN) gl.PopMatrix() gl.MatrixMode(gl.MODELVIEW) gl.PopMatrix() gl.MatrixMode(gl.PROJECTION) gl.PopMatrix() gl.MatrixMode(gl.MODELVIEW) gl.Flush() }
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 initWindow() { glut.IgnoreKeyRepeat(1) glut.DisplayFunc(display) glut.VisibilityFunc(visible) glut.KeyboardFunc(key) glut.KeyboardUpFunc(keyup) glut.SpecialFunc(special) glut.SpecialUpFunc(specialup) glut.JoystickFunc(joystick, 100) gl.MatrixMode(gl.PROJECTION) gl.LoadIdentity() gl.Ortho(0, 40, 0, 40, 0, 40) gl.MatrixMode(gl.MODELVIEW) gl.PointSize(3.0) currentWindow = glut.GetWindow() }