1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
|
-
|
|
|
!
|
#define global PFD_TYPE_RGBA 0
#define global PFD_MAIN_PLANE 0
#define global GL_MODELVIEW $1700
#define global GL_NORMALIZE $0BA1
#define global GL_AUTO_NORMA $0D80
#define global GL_SMOOTH $1D01
#define global GL_DEPTH_TEST $0B71
#define global GL_PROJECTION $1701
#define global GL_POLYGON_OFFSET_FILL $8037
#define global GL_COLOR_BUFFER_BIT $4000
#define global GL_DEPTH_BUFFER_BIT $0100
#define global GL_LINES $0001
#define global GL_LINE_LOOP $0002
#define global GL_POLYGON $0009
#uselib "opengl32.dll" #func global glClearColor "glClearColor" int,int,int,int
#func global glClear "glClear" int
#func global glColor3d "glColor3d" double,double,double
#func global glBegin "glBegin" int
#func global glVertex2d "glVertex2d" double,double
#func global glVertex3d "glVertex3d" double,double,double
#func global glNormal3d "glNormal3d" double,double,double
#func global glEnd "glEnd"
#func global glFlush "glFlush"
#func global glRotated "glRotated" double,double,double,double
#func global glLightfv "glLightfv" int,int,int
#func global glLightModelfv "glLightModelfv" int,int,int
#func global glMaterialfv "glMaterialfv" int,int,int
#func global glEnable "glEnable" int
#cfunc global wglCreateContext "wglCreateContext" int
#func global wglDeleteContext "wglDeleteContext" int
#func global wglMakeCurrent "wglMakeCurrent" int,int
#func global glMatrixMode "glMatrixMode" int
#func global glLoadIdentity "glLoadIdentity"
#func global glViewport "glViewport" int,int,int,int
#cfunc global glGenLists "glGenLists" int
#func global glNewList "glNewList" int,int
#func global glEndList "glEndList"
#func global glShadeModel "glShadeModel" int
#func global glPushMatrix "glPushMatrix"
#func global glCallList "glCallList" int
#func global glPopMatrix "glPopMatrix"
#func global glDisable "glDisable" int
#func global glLineWidth "glLineWidth" int
#func global glTranslated "glTranslated" double,double,double
#func global glPolygonOffset "glPolygonOffset" int,int
#uselib "glu32.dll" #func global gluLookAt "gluLookAt" double,double,double,double,double,double,double,double,double
#func global gluPerspective "gluPerspective" double,double,double,double
#uselib "gdi32.dll" #func global SwapBuffers "SwapBuffers" int
#cfunc global ChoosePixelFormat"ChoosePixelFormat" int,int
#func global SetPixelFormat "SetPixelFormat" int,int,int
#uselib "user32.dll" #cfunc global GetDC "GetDC" int
#func global ReleaseDC "ReleaseDC" int,int
#module
#defcfunc d2f double d_ d=d_
f=0
asdf=lpeek(d, 4)
f = asdf & 0x80000000
if d ! 0 {
f |= (((asdf >> 20) & 0x7FF) -896) << 23
f |= (asdf << 3) & 0x7FFFFF
f |= (lpeek(d, 0) >> 29) & 7
}
return f
#deffunc GLinit
dim pfd ,24
pfd(0)=96
pfd(1)=37 , PFD_TYPE_RGBA
pfd(3)=24
pfd(4)=0,0,0,0,0,0
pfd(10)=0,0,0, 0,0,0,0
pfd(17)=32,0,0
pfd(20)=PFD_MAIN_PLANE,0,0,0,0
WinDC=GetDC(hwnd)
pixelFormat = ChoosePixelFormat( WinDC,varptr(pfd) )
SetPixelFormat WinDC,pixelFormat,varptr(pfd)
hRC = wglCreateContext( WinDC )
wglMakeCurrent WinDC, hRC
glMatrixMode GL_MODELVIEW
glLoadIdentity
glEnable GL_NORMALIZE
glEnable GL_AUTO_NORMAL
glShadeModel GL_SMOOTH
glEnable GL_DEPTH_TEST return
#deffunc GLview
w=ginfo_winx
h=ginfo_winy
glMatrixMode GL_PROJECTION
glLoadIdentity
gluPerspective 60, 1.0*w/h, 0.3, 200
glViewport 0, 0, w , h
glMatrixMode GL_MODELVIEW
return
#deffunc GLdraw
glFlush
SwapBuffers WinDC
return
#deffunc Cube double x,double y,double z,int mode
glBegin mode
glNormal3d 1,0,0
glVertex3d x, -y, -z
glVertex3d x, y, -z
glVertex3d x, y, z
glVertex3d x, -y, z
glEnd
glBegin mode
glNormal3d -1,0,0
glVertex3d -x, -y, -z
glVertex3d -x, y, -z
glVertex3d -x, y, z
glVertex3d -x, -y, z
glEnd
glBegin mode
glNormal3d 0,1,0
glVertex3d -x, y, -z
glVertex3d x, y, -z
glVertex3d x, y, z
glVertex3d -x, y, z
glEnd
glBegin mode
glNormal3d 0,-1,0
glVertex3d -x, -y, -z
glVertex3d x, -y, -z
glVertex3d x, -y, z
glVertex3d -x, -y, z
glEnd
glBegin mode
glNormal3d 0,0,1
glVertex3d -x, -y, z
glVertex3d x, -y, z
glVertex3d x, y, z
glVertex3d -x, y, z
glEnd
glBegin mode
glNormal3d 0,0,-1
glVertex3d -x, -y, -z
glVertex3d x, -y, -z
glVertex3d x, y, -z
glVertex3d -x, y, -z
glEnd
return
#deffunc ReleaseOpenGL onexit
wglMakeCurrent WinDC,0
wglDeleteContext hRC
ReleaseDC hwnd,WinDC
return
#global
GLinit
glClearColor d2f(0.118), d2f(0.255), d2f(0.353),d2f(0)
r=M_PI/4
glEnable GL_POLYGON_OFFSET_FILL
glPolygonOffset d2f(1.1),d2f(1.1)
while 1
glPopMatrix glPushMatrix
GLview
glClear GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT
gluLookAt sin(r)*30,10,cos(r)*30, 0,0,0, 0,1,0
glLineWidth d2f(2.0)
glBegin GL_LINES
glColor3d 1.0, 0.0, 0.0 glVertex3d 0, 0, 0 glVertex3d 30, 0, 0
glEnd
glBegin GL_LINES
glColor3d 0.0, 1.0, 0.0 glVertex3d 0, 0, 0 glVertex3d 0, 30, 0
glEnd
glBegin GL_LINES
glColor3d 0.0, 0.0, 1.0 glVertex3d 0, 0, 0 glVertex3d 0, 0, 30
glEnd
glPushMatrix
glTranslated 3,1,3
glColor3d 0.0,0.0,0.0 Cube 1,1,1,GL_POLYGON
glColor3d 1.0, 0.0, 0.0 glLineWidth d2f(1.0) Cube 1,1,1,GL_LINE_LOOP
glPopMatrix
GLdraw r+=0.03 wait 3
wend
|