
/*
 A very very simple script, drawing a red line, one side of which
 is draggable with the mouse.
*/
Use(FindFile("addons/glututils"));
DllLoad(FindFile("addons/libopengl.so"));

10 # GlutKeyHandler("q",_x,_y) <-- Check(False,"Leaving");
10 # GlutKeyHandler("Q",_x,_y) <-- Check(False,"Leaving");
20 # GlutKeyHandler(_s,_x,_y) <--  Echo({s});


tox:=8;
toy:=60.2;
GlutMouseDrag(_x,_y) <--
[
  tox:=x;
  toy:=y;
  glutPostRedisplay();
];

GlutReshape():=genericReshape(frustumFlat());

GlutRender():=
[
  glClearColor(64,64,64,0);
  glClear(FromBase(16,fffff));
  glColor4d(255.0,0,0,0);

  glPushMatrix();

  glBegin(Eval(Atom("GL_LINES")));
  glVertex3d(3, 100.5, 0);
  glVertex3d(tox, toy, 0);
  glEnd();

  glTranslated(GlutViewWidth()>>1,GlutViewHeight()>>1,0);
 
  glRotated(angle,0,0,1);
  DrawParal({10,10,0},{10,0,0},{0,10,0});

  glPopMatrix();
];

angle:=N(GlutGetElapsedTime()/10);
GlutIdle():=
[
  angle:=N(GlutGetElapsedTime()/10);
/*  Echo({"idle",angle}); */
  glutPostRedisplay();
];

 GlutEnableAnimation();  

GlutMainLoop("title",100,100);

