require 'opengl' require 'glut' require 'mathn' require 'bizzieLibrary' require 'bizzieDraw' $width = 600 $height = 600 def transformPoint(screenX, screenY) x = (screenX - ($width / 2.0)) / ($width / 2.0) y = -1 * (screenY - ($height / 2.0)) / ($height / 2.0) return Point2d.new(x, y) end def init GL.Enable(GL::LINE_SMOOTH); GL.Enable(GL::BLEND); GL.BlendFunc(GL::SRC_ALPHA, GL::ONE_MINUS_SRC_ALPHA); GL.Hint(GL::LINE_SMOOTH_HINT, GL::DONT_CARE); GL.LineWidth(0.1); GL.ClearColor(0.0, 0.0, 0.0, 0.0); end display = Proc.new { GL.Clear(GL::COLOR_BUFFER_BIT); GL.Flush(); } reshape = Proc.new {|w, h| GL.Viewport(0, 0, w, h); GL.MatrixMode(GL::PROJECTION); GL.LoadIdentity(); if (w <= h) GLU.Ortho2D(-1.0, 1.0, -1.0*h/w, 1.0*h/w); else GLU.Ortho2D(-1.0*w/h, 1.0*w/h, -1.0, 1.0); end GL.MatrixMode(GL::MODELVIEW); GL.LoadIdentity(); } mouseClick = Proc.new {|button, state, x, y| } mouseMove = Proc.new {|x , y| } keyboard = Proc.new {|key, x, y| case (key) #when 'r'[0], 'R'[0] when 27 #/* Escape Key */ exit(0); end } GLUT.Init GLUT.InitDisplayMode(GLUT::SINGLE | GLUT::RGB) GLUT.InitWindowSize($width, $height) GLUT.CreateWindow($0) init GLUT.ReshapeFunc(reshape) GLUT.KeyboardFunc(keyboard) GLUT.MouseFunc(mouseClick) GLUT.MotionFunc(mouseMove) GLUT.DisplayFunc(display) GLUT.MainLoop