Subversion Repositories Kolibri OS

Rev

Rev 5418 | Rev 6126 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5418 Rev 6120
Line 1... Line 1...
1
use32
1
use32
2
	org 0x0
2
	org 0x0
3
	db 'MENUET01'
3
	db 'MENUET01'
4
	dd 0x1
-
 
5
	dd start
-
 
6
	dd i_end
-
 
7
	dd mem,stacktop
-
 
8
	dd 0,cur_dir_path
4
	dd 1,start,i_end,mem,stacktop,0,cur_dir_path
Line 9... Line 5...
9
 
5
 
10
include '../../../../../proc32.inc'
6
include '../../../../../proc32.inc'
-
 
7
include '../../../../../macros.inc'
11
include '../../../../../macros.inc'
8
include '../../../../../KOSfuncs.inc'
12
include '../../../../../develop/libraries/box_lib/load_lib.mac'
9
include '../../../../../develop/libraries/box_lib/load_lib.mac'
13
include '../../../../../dll.inc'
10
include '../../../../../dll.inc'
-
 
11
include '../opengl_const.inc'
Line 14... Line 12...
14
include '../opengl_const.inc'
12
include 'fps.inc'
Line 15... Line 13...
15
 
13
 
16
@use_library
14
@use_library
Line 25... Line 23...
25
	load_library name_tgl, cur_dir_path, library_path, system_path, \
23
	load_library name_tgl, cur_dir_path, library_path, system_path, \
26
		err_message_found_lib, head_f_l, import_lib_tinygl, err_message_import, head_f_i
24
		err_message_found_lib, head_f_l, import_lib_tinygl, err_message_import, head_f_i
27
	cmp eax,-1
25
	cmp eax,-1
28
	jz button.exit
26
	jz button.exit
Line 29... Line 27...
29
 
27
 
Line 30... Line 28...
30
	mcall 40,0x27
28
	mcall SF_SET_EVENTS_MASK,0x27
31
 
29
 
Line 32... Line 30...
32
	stdcall [kosglMakeCurrent], 10,10,400,350,ctx1
30
	stdcall [kosglMakeCurrent], 0,15,400,380,ctx1
33
	stdcall reshape, 400,350
31
	stdcall reshape, 400,380
34
 
32
 
35
; *** init ***
33
; *** init ***
Line 42... Line 40...
42
	; make the gears
40
	; make the gears
43
	stdcall [glGenLists],1
41
	stdcall [glGenLists],1
44
	mov [gear1],eax
42
	mov [gear1],eax
45
	stdcall [glNewList], eax, GL_COMPILE
43
	stdcall [glNewList], eax, GL_COMPILE
46
	stdcall [glMaterialfv], GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red
44
	stdcall [glMaterialfv], GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red
47
;;;stdcall [glColor4fv], red
-
 
48
	stdcall gear, 1.0, 4.0, 1.0, 20, 0.7
45
	stdcall gear, 1.0, 4.0, 1.0, 20, 0.7
49
	call [glEndList]
46
	call [glEndList]
Line 50... Line 47...
50
 
47
 
51
	stdcall [glGenLists],1
48
	stdcall [glGenLists],1
52
	mov [gear2],eax
49
	mov [gear2],eax
53
	stdcall [glNewList], eax, GL_COMPILE
50
	stdcall [glNewList], eax, GL_COMPILE
54
	stdcall [glMaterialfv], GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green
-
 
55
;;;stdcall [glColor4fv], green
51
	stdcall [glMaterialfv], GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green
56
	stdcall gear, 0.5, 2.0, 2.0, 10, 0.7
52
	stdcall gear, 0.5, 2.0, 2.0, 10, 0.7
Line 57... Line 53...
57
	call [glEndList]
53
	call [glEndList]
58
 
54
 
59
	stdcall [glGenLists],1
55
	stdcall [glGenLists],1
60
	mov [gear3],eax
56
	mov [gear3],eax
61
	stdcall [glNewList], eax, GL_COMPILE
-
 
62
	stdcall [glMaterialfv], GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue
57
	stdcall [glNewList], eax, GL_COMPILE
63
;;;stdcall [glColor4fv], blue
58
	stdcall [glMaterialfv], GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue
Line 64... Line 59...
64
	stdcall gear, 1.3, 2.0, 0.5, 10, 0.7
59
	stdcall gear, 1.3, 2.0, 0.5, 10, 0.7
65
	call [glEndList]
60
	call [glEndList]
Line 66... Line -...
66
 
-
 
67
	stdcall [glEnable], GL_NORMALIZE
-
 
68
; *** end init ***
61
 
69
 
62
	stdcall [glEnable], GL_NORMALIZE
70
	call draw_3d
63
; *** end init ***
Line 71... Line 64...
71
 
64
 
72
align 4
65
align 4
73
red_win:
66
red_win:
-
 
67
	call draw_window
-
 
68
 
-
 
69
align 16
-
 
70
still:
-
 
71
	call draw_3d
-
 
72
 
-
 
73
	stdcall Fps, 330,4
-
 
74
	mov dword[esp-4],eax
-
 
75
	fild dword[esp-4]
-
 
76
	fmul dword[a2]
74
	call draw_window
77
	fadd dword[a1]
75
 
78
	fadd dword[angle]
76
align 4
79
	fstp dword[angle]
77
still:
80
 
78
	mcall 10
81
	mcall SF_CHECK_EVENT
79
	cmp al,1
82
	cmp al,1
80
	jz red_win
83
	jz red_win
Line -... Line 84...
-
 
84
	cmp al,2
-
 
85
	jz key
-
 
86
	cmp al,3
-
 
87
	jz button
81
	cmp al,2
88
	jmp still
82
	jz key
89
 
83
	cmp al,3
90
align 4
84
	jz button
91
a1 dd 0.01
85
	jmp still
92
a2 dd 0.3
Line 119... Line 126...
119
p6 dq 60.0
126
p6 dq 60.0
Line 120... Line 127...
120
 
127
 
121
align 4
128
align 4
122
draw_window:
129
draw_window:
123
	pushad
130
	pushad
Line 124... Line -...
124
	mcall 12,1
-
 
125
 
131
	mcall SF_REDRAW,SSF_BEGIN_DRAW
126
	mov edx,0x33ffffff ;0x73ffffff
132
 
Line 127... Line 133...
127
	mcall 0,(50 shl 16)+430,(30 shl 16)+400,,,caption
133
	mcall SF_CREATE_WINDOW,(50 shl 16)+410,(30 shl 16)+425,0x33ffffff,,title1
-
 
134
	stdcall [kosglSwapBuffers]
-
 
135
 
-
 
136
	;Title
-
 
137
	mcall SF_DRAW_TEXT,(300 shl 16)+4,0x808080,fps,   fps.end-fps
-
 
138
	mcall SF_DRAW_TEXT,(8 shl 16)+4,0x808080,title3,title3.end-title3
128
	stdcall [kosglSwapBuffers]
139
	;mcall SF_DRAW_TEXT,(180 shl 16)+4,0x808080,title2,title2.end-title2
129
 
140
 
Line 130... Line 141...
130
	mcall 12,2
141
	mcall SF_REDRAW,SSF_END_DRAW
131
	popad
142
	popad
132
	ret
143
	ret
Line 133... Line 144...
133
 
144
 
134
align 4
145
align 4
Line 135... Line 146...
135
key:
146
key:
136
	mcall 2
147
	mcall SF_GET_KEY
137
 
148
 
138
	cmp ah,27 ;Esc
149
	cmp ah,27 ;Esc
139
	je button.exit
150
	je button.exit
140
 
151
 
141
	cmp ah,61 ;+
-
 
142
	jne @f
152
	cmp ah,61 ;+
143
		fld dword[scale]
153
	jne @f
144
		fdiv dword[delt_sc]
154
		fld dword[scale]
145
		fstp dword[scale]
155
		fdiv dword[delt_sc]
146
		call draw_3d
156
		fstp dword[scale]
147
		stdcall [kosglSwapBuffers]
157
		call draw_3d
148
	@@:
158
	@@:
149
	cmp ah,45 ;-
-
 
150
	jne @f
159
	cmp ah,45 ;-
151
		fld dword[scale]
160
	jne @f
152
		fmul dword[delt_sc]
161
		fld dword[scale]
153
		fstp dword[scale]
162
		fmul dword[delt_sc]
154
		call draw_3d
163
		fstp dword[scale]
155
		stdcall [kosglSwapBuffers]
164
		call draw_3d
156
	@@:
165
	@@:
157
	cmp ah,178 ;Up
-
 
158
	jne @f
166
	cmp ah,178 ;Up
159
		fld dword[view_rotx]
167
	jne @f
160
		fadd dword[delt_size]
168
		fld dword[view_rotx]
161
		fstp dword[view_rotx]
169
		fadd dword[delt_size]
162
		call draw_3d
170
		fstp dword[view_rotx]
163
		stdcall [kosglSwapBuffers]
171
		call draw_3d
164
	@@:
172
	@@:
165
	cmp ah,177 ;Down
-
 
166
	jne @f
173
	cmp ah,177 ;Down
167
		fld dword[view_rotx]
174
	jne @f
168
		fsub dword[delt_size]
175
		fld dword[view_rotx]
169
		fstp dword[view_rotx]
176
		fsub dword[delt_size]
170
		call draw_3d
177
		fstp dword[view_rotx]
171
		stdcall [kosglSwapBuffers]
178
		call draw_3d
172
	@@:
179
	@@:
173
	cmp ah,176 ;Left
-
 
174
	jne @f
180
	cmp ah,176 ;Left
175
		fld dword[view_roty]
181
	jne @f
176
		fadd dword[delt_size]
182
		fld dword[view_roty]
177
		fstp dword[view_roty]
183
		fadd dword[delt_size]
178
		call draw_3d
184
		fstp dword[view_roty]
179
		stdcall [kosglSwapBuffers]
185
		call draw_3d
180
	@@:
186
	@@:
181
	cmp ah,179 ;Right
-
 
182
	jne @f
187
	cmp ah,179 ;Right
Line 183... Line 188...
183
		fld dword[view_roty]
188
	jne @f
Line 184... Line 189...
184
		fsub dword[delt_size]
189
		fld dword[view_roty]
185
		fstp dword[view_roty]
190
		fsub dword[delt_size]
186
		call draw_3d
191
		fstp dword[view_roty]
187
		stdcall [kosglSwapBuffers]
192
		call draw_3d
188
	@@:
193
	@@:
189
 
194
 
190
	jmp still
195
	jmp still
Line 191... Line 196...
191
 
196
 
192
align 4
197
align 4
-
 
198
button:
-
 
199
	mcall SF_GET_BUTTON
-
 
200
	cmp ah,1
-
 
201
	jne still
-
 
202
.exit:
-
 
203
	mcall SF_TERMINATE_PROCESS
-
 
204
 
-
 
205
 
193
button:
206
align 4
194
	mcall 17
207
title1: db 'TinyGL in KolibriOS'
195
	cmp ah,1
208
.end: db 0
Line 196... Line 209...
196
	jne still
209
title2: db 'F full screen'
197
.exit:
210
.end: db 0
198
	mcall -1
211
title3: db 'ESC - exit'
Line 199... Line 212...
199
 
212
.end: db 0
200
 
213
fps:    db 'FPS:'
201
align 4
214
.end: db 0
202
caption db 'Gears, [Esc] - exit, [<-],[->],[Up],[Down] - rotate',0
215
 
203
align 4
216
align 4
Line 204... Line 217...
204
ctx1 db 28 dup (0) ;TinyGLContext or KOSGLContext
217
ctx1 db 28 dup (0) ;TinyGLContext or KOSGLContext
Line 258... Line 271...
258
	stdcall [glCallList],[gear3]
271
	stdcall [glCallList],[gear3]
259
	stdcall [glPopMatrix]
272
	stdcall [glPopMatrix]
Line 260... Line 273...
260
 
273
 
Line 261... Line 274...
261
	stdcall [glPopMatrix]
274
	stdcall [glPopMatrix]
Line 262... Line 275...
262
 
275
 
263
;;;   tkSwapBuffers();
276
	stdcall [kosglSwapBuffers]
264
 
277
 
265
;   count++;
278
;   count++;
Line 266... Line 279...
266
;   if (count==limit) {
279
;   if (count==limit) {
267
;       exit(0);
280
;       exit(0);
268
ret
281
	ret
269
 
-
 
270
align 4
282
 
271
an_9 dd 9.0
283
align 4
272
an_25 dd 25.0
284
an_9 dd 9.0
Line 273... Line 285...
273
qObj dd 0 ;???
285
an_25 dd 25.0
Line 800... Line 812...
800
		fld1
812
		fld1
801
		fld1
813
		fld1
802
		faddp
814
		faddp
Line 803... Line 815...
803
 
815
 
804
		fldpi
816
		fldpi
805
		fmul st0,st1
817
		fmulp
806
		fimul dword[i]
818
		fimul dword[i]
807
		fidiv dword[teeth]
819
		fidiv dword[teeth]
Line 808... Line 820...
808
		fst dword[angle] ;angle = i * 2.0*M_PI / teeth
820
		fst dword[angle] ;angle = i * 2.0*M_PI / teeth
Line 840... Line 852...
840
		inc dword[i]
852
		inc dword[i]
841
		jmp @b
853
		jmp @b
842
	@@:
854
	@@:
843
	call [glEnd]
855
	call [glEnd]
Line 844... Line -...
844
 
-
 
845
	;ffree st0 ;2.0
-
 
846
	;fincstp
-
 
847
 
856
 
848
	ret	 
857
	ret