func initScene() (err error) { gl.Enable(gl.TEXTURE_2D) gl.Enable(gl.DEPTH_TEST) gl.Enable(gl.LIGHTING) gl.ClearColor(0.5, 0.5, 0.5, 0.0) gl.ClearDepth(1) gl.DepthFunc(gl.LEQUAL) gl.Lightfv(gl.LIGHT0, gl.AMBIENT, ambient) gl.Lightfv(gl.LIGHT0, gl.DIFFUSE, diffuse) gl.Lightfv(gl.LIGHT0, gl.POSITION, lightpos) gl.Enable(gl.LIGHT0) gl.Viewport(0, 0, Width, Height) gl.MatrixMode(gl.PROJECTION) gl.LoadIdentity() gl.Frustum(-1, 1, -1, 1, 1.0, 10.0) gl.MatrixMode(gl.MODELVIEW) gl.LoadIdentity() goph, err := os.Open("../../data/gopher.png") if err != nil { panic(err) } defer goph.Close() texture, err = createTexture(goph) return }
func copiedReshape(window *glfw.Window, w int, h int) { gl.DrawBuffer(gl.FRONT_AND_BACK) //gl.Viewport(int(w/2), int(h/2), w, h) gl.MatrixMode(gl.PROJECTION) gl.LoadIdentity() gl.Frustum(-1, 1, -1, 1, 1.5, 20) gl.MatrixMode(gl.MODELVIEW) }
// new window size func reshape(window *glfw.Window, width, height int) { gl.Viewport(0, 0, width, height) gl.MatrixMode(gl.PROJECTION) gl.LoadIdentity() gl.Frustum(-1.0, 1.0, -1.0, 1.0, 1, 20) gl.MatrixMode(gl.MODELVIEW) gl.LoadIdentity() }
func copiedInit() { gl.ClearColor(0, 0, 0, 0) gl.ShadeModel(gl.FLAT) gl.Enable(gl.CULL_FACE) gl.Viewport(320, 240, 640, 480) gl.MatrixMode(gl.PROJECTION) gl.LoadIdentity() gl.Frustum(-1, 1, -1, 1, 1.5, 20) gl.MatrixMode(gl.MODELVIEW) }
/* new window size or exposure */ func reshape(width int, height int) { h := float64(height) / float64(width) gl.Viewport(0, 0, width, height) gl.MatrixMode(gl.PROJECTION) gl.LoadIdentity() gl.Frustum(-1.0, 1.0, -h, h, 5.0, 60.0) gl.MatrixMode(gl.MODELVIEW) gl.LoadIdentity() gl.Translatef(0.0, 0.0, -40.0) }
func onResize(w, h int) { if h == 0 { h = 1 } gl.Viewport(0, 0, w, h) gl.MatrixMode(gl.PROJECTION) gl.LoadIdentity() gl.Frustum(-1.0, 1.0, -1.0, 1.0, 1, 20) gl.MatrixMode(gl.MODELVIEW) gl.LoadIdentity() }
// new window size func reshape(window *glfw.Window, width, height int) { h := float64(height) / float64(width) znear := 5.0 zfar := 30.0 xmax := znear * 0.5 gl.Viewport(0, 0, width, height) gl.MatrixMode(gl.PROJECTION) gl.LoadIdentity() gl.Frustum(-xmax, xmax, -xmax*h, xmax*h, znear, zfar) gl.MatrixMode(gl.MODELVIEW) gl.LoadIdentity() gl.Translated(0.0, 0.0, -20.0) }