Annotation of OpenXM/src/cfep/tests/cfep-opengl.rr, Revision 1.2
1.1 takayama 1: extern GL_COLOR_BUFFER_BIT$
2: extern GL_DEPTH_BUFFER_BIT$
3: extern GL_LINES $
4: extern GL_LINE_STIPPLE $
5: extern GL_LINE_STIPPLE_PATTERN$
6: extern GL_LINE_STIPPLE_REPEAT $
7: extern GL_LINE_WIDTH $
8: extern GL_LINE $
9: extern GL_POINTS $
10: extern GL_POINT_SIZE $
11: extern GL_POLYGON $
12: extern GL_TRIANGLES $
13:
14: GL_COLOR_BUFFER_BIT= 0x00004000$
15: GL_DEPTH_BUFFER_BIT= 0x00000100$
16: GL_LINES = 0x0001$
17: GL_LINE_STIPPLE = 0x0B24$
18: GL_LINE_STIPPLE_PATTERN= 0x0B25$
19: GL_LINE_STIPPLE_REPEAT = 0x0B26$
20: GL_LINE_WIDTH = 0x0B21$
21: GL_LINE = 0x1B01$
22: GL_POINTS = 0x0000$
23: GL_POINT_SIZE = 0x0B11$
24: GL_POLYGON = 0x0009 $
25: GL_TRIANGLES=3$
26:
27:
28:
29: module opengl;
30: localf initStatic$
31:
32: localf setCanvas$
33: localf init$
34: localf redraw$
35: localf metaRemoveAll$
36: localf metaShowListOfOpenGLCommands$
37:
38: localf glBegin$
39: localf glClear$
40: localf glClearColor$
41: localf glColor4f$
42: localf glEnable$
43: localf glEnd$
44: localf glFlush$
45: localf glLineStipple$
46: localf glLineWidth $
47: localf glNormal3f $
48: localf glRectf$
49: localf glVertex3f$
50: localf glVertex2f$
51:
52: localf glib3DefaultScene$
53:
54: localf test2$
55:
56: static Canvas$
57: static Channel$
58: def initStatic() {
59: ctrl("double_output",1);
60: Canvas="0;";
61: Channel=0;
62: }
63: initStatic()$
64:
65: def setCanvas(N) {
66: if ((N>=0) && (type(N) <= 1)) Canvas=rtostr(N)+";";
67: }
68: def init() {
69: Channel = 0;
70: }
71: def redraw() {
72: opengl.glFlush();
73: Channel=1;
74: }
75: def metaShowListOfOpenGLCommands() {
76: cfep.glib_send2(Channel,Canvas+"meta_showListOfOglComm");
77: }
78: def metaRemoveAll() {
79: cfep.glib_send2(Channel,Canvas+"meta_removeAllInit");
80: cfep.glib_send2(Channel,Canvas+"meta_removeAll");
81: }
82:
1.2 ! takayama 83: /* import("cfep-opengl.rr");
1.1 takayama 84: opengl.glib3DefaultScene("mesa demo/ray");
85: opengl.glib3DefaultScene("cfep demo/icosahedron");
86:
87: opengl.metaRemoveAll();
88: opengl.init();
89: opengl.glib3DefaultScene(0);
90: opengl.redraw();
91: opengl.glColor4f(0.0,0.0,1.0,0.3);
92: opengl.glBegin(GL_POLYGON); Y=0.1;
93: opengl.glVertex3f(-1.0, Y, 0.5);
94: opengl.glVertex3f(-1.0, Y, -0.5);
95: opengl.glVertex3f(1.0, Y, -0.5);
96: opengl.glVertex3f(1.0, Y, 0.5);
97: opengl.glEnd();
98:
99: opengl.glColor4f(1.0,0.0,0.0,0.5);
100: opengl.glBegin(GL_POLYGON);
101: opengl.glVertex3f(0.0, 0.5, 0.0);
102: opengl.glVertex3f(0.0, 0.5, -0.4);
103: opengl.glVertex3f(0.5, -0.2, -0.4);
104: opengl.glVertex3f(0.5, -0.2, 0.0);
105: opengl.glEnd();
106: opengl.glFlush() ;
107: opengl.metaShowListOfOpenGLCommands();
108:
109: */
110: def glib3DefaultScene(Type) {
111: if (type(Type) == 7) {
112: if (Type=="mesa demo/ray") {
113: init();
114: cfep.glib_send2(Channel,Canvas+"[glib3_ray_init]");
115: redraw();
116: cfep.glib_send2(Channel,Canvas+"[glib3_ray]");
117: glFlush();
118: return;
119: }else if (Type =="cfep demo/icosahedron") {
120: init();
121: cfep.glib_send2(Channel,Canvas+"[glib3_std_scene0]");
122: redraw();
123: cfep.glib_send2(Channel,Canvas+"[glib3_icosahedron]");
124: glFlush();
125: return;
126: }else{ Type = 0; }
127: }
128: if (Type == 0) {
129: cfep.glib_send2(Channel,Canvas+"[glib3_std_scene0]");
130: return;
131: }
132: cfep.glib_send2(Channel,Canvas+"[glib3_std_scene0]");
133: }
134:
135: def glBegin(M) {
136: cfep.glib_send2(Channel,Canvas+"[glBegin,(int)"+rtostr(eval(M))+"]");
137: }
138:
139: def glClear(M) {
140: cfep.glib_send2(Channel,Canvas+"[glClear,(int)"+rtostr(eval(M))+"]");
141: }
142: def glClearColor(R,G,B,A) {
143: cfep.glib_send2(Channel,Canvas+"[glClearColor,"+
144: rtostr(deval(R))+","+
145: rtostr(deval(G))+","+
146: rtostr(deval(B))+","+
147: rtostr(deval(A))+"]");
148: }
149: def glColor4f(R,G,B,A) {
150: cfep.glib_send2(Channel,Canvas+"[glColor4f,"+
151: rtostr(deval(R))+","+
152: rtostr(deval(G))+","+
153: rtostr(deval(B))+","+
154: rtostr(deval(A))+"]");
155: } /*
156: opengl.metaRemoveAll();
157: opengl.init();
158: opengl.glClearColor(1.0,1.0,1.0,1.0);
159: opengl.glClear(GL_COLOR_BUFFER_BIT);
160: opengl.redraw();
161: opengl.glColor4f(1.0,0.0,0.0,0.3);
162: opengl.glRectf(-0.2,-0.2,0.2,0.2);
163: opengl.glFlush() ;
164: opengl.metaShowListOfOpenGLCommands();
165: */
166: def glEnable(M) {
167: cfep.glib_send2(Channel,Canvas+"[glEnable,(int)"+rtostr(eval(M))+"]");
168: }
169:
170: def glEnd() {
171: cfep.glib_send2(Channel,Canvas+"[glEnd]");
172: }
173:
174: def glFlush() {
175: cfep.glib_send2(Channel,Canvas+"[glFlush]");
176: }
177:
178: def glLineStipple(R,P) {
179: cfep.glib_send2(Channel,Canvas+"[glLineStipple,(int)"+
180: rtostr(eval(R))+",(int)"+
181: rtostr(eval(P))+"]");
182: }
183:
184: def glLineWidth(W) {
185: cfep.glib_send2(Channel,Canvas+"[glLineWidth,"+
186: rtostr(deval(W))+"]");
187: } /*
188: opengl.metaRemoveAll();
189: opengl.init();
190: opengl.redraw();
191: opengl.glColor4f(1.0,0.0,1.0,0.3);
192: opengl.glLineWidth(1.0);
193: opengl.glEnable(GL_LINE_STIPPLE);
194: opengl.glLineStipple(1,0xaaaa);
195: opengl.glBegin(GL_LINES);
196: opengl.glVertex2f(0.0, 0.0);
197: opengl.glVertex2f(1.0, 0.0);
198: opengl.glVertex2f(0.0, 1.0);
199: opengl.glVertex2f(-0.2, 0.5);
200: opengl.glEnd();
201: opengl.glFlush() ;
202: opengl.metaShowListOfOpenGLCommands();
203: */
204: def glNormal3f(X,Y,Z) { /* left bottom, right top */
205: cfep.glib_send2(Channel,Canvas+"[glNormal3f,"+
206: rtostr(deval(X))+","+
207: rtostr(deval(Y))+","+
208: rtostr(deval(Z))+"]");
209: }
210:
211:
212: def glRectf(Xlb,Ylb,Xrt,Yrt) { /* left bottom, right top */
213: cfep.glib_send2(Channel,Canvas+"[glRectf,"+
214: rtostr(deval(Xlb))+","+
215: rtostr(deval(Ylb))+","+
216: rtostr(deval(Xrt))+","+
217: rtostr(deval(Yrt))+"]");
218: }
219:
220: def glVertex3f(X,Y,Z) {
221: cfep.glib_send2(Channel,Canvas+"[glVertex3f,"+
222: rtostr(deval(X))+","+
223: rtostr(deval(Y))+","+
224: rtostr(deval(Z))+"]");
225: }
226: def glVertex2f(X,Y) {
227: cfep.glib_send2(Channel,Canvas+"[glVertex2f,"+
228: rtostr(deval(X))+","+
229: rtostr(deval(Y))+"]");
230: }
231:
232: def test2() {
233: cfep.glib_init_send("0;[glib3_ray_init]");
234: cfep.glib_init_send("0;[glib_flush]");
235: cfep.glib_send("0;[glib3_ray]");
236: cfep.glib_send("0;[glib_flush]");
237: }
238:
239: endmodule;
240: /* opengl.test2(); */
241: /* 最終的には asir-contrib へ移動 */
242: /* $OpenXM$ */
243: end$
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>