Annotation of OpenXM/src/cfep/Samples/simple-gl-1.rr, Revision 1.1.1.1
1.1 takayama 1: /*
2: 使い方:
3: ファイル全体を実行したあと test4(); を呼び出す.
4: test(); を呼び出す.
5: */
6: def test4() {
7: glib_init_send("0;[glib3_std_scene0]");
8: glib_init_send("0;[glib_flush]");
9: glib_send("0; [glib3_bounding_box, 1.2]");
10: glib_send("0; [glColor4f, 1.0, 0.0, 0.0, 1.0]");
11: glib_send("0;[glBegin, (int) 4]"); /* GL_TRIANGLES */
12: glib_send("0;[glVertex3f,0s,0,0]");
13: glib_send("0;[glVertex3f,0,1,0]");
14: glib_send("0;[glVertex3f,1,0,0.2]");
15: glib_send("0;[glEnd]");
16: glib_send("0;[glib_flush]");
17: }
18: def test() {
19: /* gid; commands */
20: glib_init_send("0;[glColor4f,1.0,0.8,1.0,1.0]");
21: glib_send("0;[glColor4f, 1.0, 0.0, 0.0, 0.0, 1.0]");
22: glib_send("0;[glRectf,-0.3, -0.3, 0.3, 0.3]");
23: glib_send("0;[glib_flush]");
24: glib_init_send("1; [glColor4f, 1.0,0.0,0.0,0.3]");
25: glib_init_send("1; [glRectf, -0.1,-0.1,0.1,0.1]");
26: glib_init_send("1; [glib_flush]");
27: glib_send("1; [glib_line,0.0,0.0,0.5,0.5,(int)255]");
28: glib_send("1; [glib_flush]");
29: }
30: /* test1(); */
31: def test1() {
32: for (I= 0; I<1.0; I += 0.05) {
33: myline(0,0,0.6,I, [random()%256,random()%256,random()%256]);
34: } /* bug なぜか線の色が黒になる. color が全部0. 2006.02.22*/
35: glib_send("1;[glib_flush]");
36: }
37: def myline(X,Y,X2,Y2,C) {
38: X = rtostr(deval(X)); Y = rtostr(deval(Y));
39: X2 = rtostr(deval(X2)); Y2=rtostr(deval(Y2));
40: CC = C[0]*(256*256)+C[1]*256+C[0];
41: CC=rtostr(CC); print(C,0); print(CC);
42: glib_send("1; [glib_line,"+X+","+Y+","+X2+","+Y2+","+CC+"]");
43: }
44: def t_encode1(X) {
45: return [
46: ior(0xf8,iand(0x3,ishift(X,6))),
47: ior(0xf0,iand(0x7,ishift(X,3))),
48: ior(0xf0,iand(0x7,X))];
49: }
50: def t_encode_str(S) {
51: Ans = [ ];
52: Codes = strtoascii(S);
53: N = length(Codes);
54: for (I=0; I<N; I++) {
55: T = t_encode1(Codes[I]);
56: Ans = cons(T[0],Ans);
57: Ans = cons(T[1],Ans);
58: Ans = cons(T[2],Ans);
59: }
60: return reverse(Ans);
61: }
62: def t_encode(S) {
63: return asciitostr(t_encode_str(S));
64: }
65: def glib_send(S) {
66: S=S+"\n";
67: N=length(strtoascii(S))+1;
68: C=t_encode("{1<"+rtostr(N)+" "+S+" >}");
69: ctrl("hex",1);
70: output(); ctrl("hex",0);
71: print(C); output(); /* channel 1 にコマンドを送る */
72: }
73: def glib_init_send(S) {
74: S=S+"\n";
75: N=length(strtoascii(S))+1;
76: C=t_encode("{2<"+rtostr(N)+" "+S+" >}");
77: ctrl("hex",1);
78: output(); ctrl("hex",0);
79: print(C); output(); /* channel 2 にコマンドを送る. OpenGL 初期化 */
80: }
81:
82:
83:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>