4 "gluck.ckx" => (:gluck:);
7 //MUST be called before any other gluck function
10 gluck.InitBasicWindow("danger! teapot!"); //generate a simple window
12 gluck.InitCallbacks(1, 1, 1); //register callbacks for the window
13 //arguments monitor ( mouse, motion, keyboard );
16 //using actual values ( from the glut.h headers ) for these because
17 //we haven't set up the constant (huge) namespace..
18 5889 => uint dummy; //PROJECTION_MATRIX
21 gl.Ortho(-1.0, 1.0, -1.0 , 1.0, -4.0 , 4.0 );
23 5888 => dummy; //GL MODELVIEW_MATRIX
26 gl.ClearColor ( 0.0 , 0.0, 0.3, 0.0 );
46 noise n => biquad b => dac;
59 function void thedrawloop() {
61 16640 => dummy; //GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT
66 gl.Translatef ( curx, cury, 0.0);
67 // gl.Scalef ( 1.1 + math.sin ( tm * 0.2 ), 1.1 + math.sin ( tm * 0.2 ), 1.1 + math.sin ( tm * 0.2 ) );
68 gl.Scalef ( 0.1 + avol , 0.1 + avol , 0.1 + avol );
69 gl.Rotatef ( tm * 45.0, 1.0, 0.0 , 0.0 );
70 gl.Rotatef (tm * 60.0, 0.0, 1.0 , 0.0 );
73 gl.Color4f( 0.0, 0.0, 0.0, 0.95 );
74 gluck.SolidTeapot ( 0.5 );
75 gl.Color4f( frac , 0.5 + 0.5 * curx , 0.05 + 0.5 * cury, 0.5 );
76 gluck.WireTeapot ( 0.5 + bg );
80 gl.Color4f( frac , 0.5 + 0.5 * curx , 0.05 + 0.5 * cury, 0.5 );
81 gluck.WireTeapot( 0.5 );
89 function void theeventloop() {
90 while ( gluck.HasEvents() ) {
91 gluck.GetNextEvent() => int id;
93 if ( gluck.GetEventType(id) == 0 ) {
94 if ( gluck.GetEventX(id) == lastx & gluck.GetEventY(id) == lasty ) {
98 gluck.GetEventX(id) => lastx;
99 gluck.GetEventY(id) => lasty;
102 if ( gluck.GetEventType(id) == 1 ) {
103 2.0 * ( (float) gluck.GetEventX(id) / (float) gluck.GetViewDims(0) ) - 1.0 => curx;
104 -2.0 * ( (float) gluck.GetEventY(id) / (float) gluck.GetViewDims(1) ) + 1.0 => cury;
105 (float) gluck.GetEventX(id) => fc;
106 (float) gluck.GetEventY(id) => ampM;
107 gl.ClearColor(0.0, 0.5 + -0.5 * curx, 0.5 + -0.5 * cury, 0.0);
109 if ( gluck.GetEventType(id) == 3 ) {
110 gluck.GetEventKey(id) => uint k;
111 100.0 + (float) ( k - 65 ) * 50.0 => b.pfreq;
118 function void theaudiocontrol( ) {
119 fc + ampM * frac => a.sfreq;
120 // 0.4 + 0.3 * math.sin ( tm * 0.2 ) => a.gain;
121 if ( avol > 1.5 ) 1.5 => avol;
122 0.1 + avol => a.gain;
123 avol + ( 0.033 * -0.1 ) => avol;
124 if ( avol < 0.0 ) { 0.0 => avol; }
125 bg + ( 0.033 * -0.4 ) => bg ; //drain bg
126 if ( bg < 0.0 ) { 0.0 => bg; }
130 function void thegraphicscall( ) {
132 gluck.MainLoopEvent(); //...
134 if ( gluck.NeedDraw() ) { thedrawloop(); }
135 if ( gluck.NeedEvent() ) { theeventloop(); }
137 gluck.PostRedisplay();
143 std.abs ( 2.0 * ( -0.5 + tm - math.floor(tm)) ) => frac;