Subversion Repositories Kolibri OS

Rev

Rev 5290 | Rev 6143 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5218 IgorA 1
struct GLUquadricObj
2
	DrawStyle   dd ? ; GLU_FILL, LINE, SILHOUETTE, or POINT
3
	Orientation dd ? ; GLU_INSIDE or GLU_OUTSIDE
4
	TextureFlag dd ? ; Generate texture coords?
5
	Normals     dd ? ; GLU_NONE, GLU_FLAT, or GLU_SMOOTH
6
	ErrorFunc   dd ? ; Error handler callback function
7
ends
8
 
9
offs_qobj_DrawStyle equ 0
10
offs_qobj_Orientation equ 4
11
offs_qobj_TextureFlag equ 8
12
offs_qobj_Normals equ 12
13
offs_qobj_ErrorFunc equ 16
14
 
15
;void drawTorus(float rc, int numc, float rt, int numt)
16
;{
17
;}
18
 
19
;static void normal3f(GLfloat x, GLfloat y, GLfloat z )
20
;{
21
;}
22
 
23
;void gluPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar )
24
;{
25
;}
26
 
27
;void gluLookAt(GLdouble eyex, GLdouble eyey, GLdouble eyez,
28
;	  GLdouble centerx, GLdouble centery, GLdouble centerz,
29
;	  GLdouble upx, GLdouble upy, GLdouble upz)
30
;{
31
;}
32
 
33
align 4
34
gluNewQuadric:
35
	stdcall gl_malloc, sizeof.GLUquadricObj
36
	or eax,eax
37
	jz @f
38
		mov dword[eax+offs_qobj_DrawStyle],GLU_FILL
39
		mov dword[eax+offs_qobj_Orientation],GLU_OUTSIDE
40
		mov dword[eax+offs_qobj_TextureFlag],GL_FALSE
41
		mov dword[eax+offs_qobj_Normals],GLU_SMOOTH
42
		mov dword[eax+offs_qobj_ErrorFunc],0 ;NULL
43
	@@:
44
	ret
45
 
46
align 4
47
proc gluDeleteQuadric, state:dword
48
	cmp dword[state],0
49
	je @f
50
		stdcall gl_free,[state]
51
	@@:
52
	ret
53
endp
54
 
5290 IgorA 55
;
56
; Set the drawing style to be GLU_FILL, GLU_LINE, GLU_SILHOUETTE,
57
; or GLU_POINT.
58
;
59
align 4
60
proc gluQuadricDrawStyle uses eax ebx, qobj:dword, drawStyle:dword
61
	mov eax,[qobj]
62
	or eax,eax
63
	jz .err_q
64
	mov ebx,[drawStyle]
65
	cmp ebx,GLU_FILL
66
	je @f
67
	cmp ebx,GLU_LINE
68
	je @f
69
	cmp ebx,GLU_SILHOUETTE
70
	je @f
71
	cmp ebx,GLU_POINT
72
	je @f
73
	jmp .err_q
74
	@@:
75
		mov dword[eax+offs_qobj_DrawStyle],ebx
76
		jmp @f
77
	.err_q:
6108 IgorA 78
		stdcall dbg_print,sz_gluQuadricDrawStyle,err_9
5290 IgorA 79
	@@:
80
	ret
81
endp
5218 IgorA 82
 
5290 IgorA 83
;
84
; Set the orientation to GLU_INSIDE or GLU_OUTSIDE.
85
;
86
align 4
87
proc gluQuadricOrientation uses eax ebx, qobj:dword, orientation:dword
88
	mov eax,[qobj]
89
	or eax,eax
90
	jz .err_q
91
	mov ebx,[orientation]
92
	cmp ebx,GLU_INSIDE
93
	je @f
94
	cmp ebx,GLU_OUTSIDE
95
	je @f
96
	jmp .err_q
97
	@@:
98
		mov dword[eax+offs_qobj_Orientation],ebx
99
		jmp @f
100
	.err_q:
6108 IgorA 101
		stdcall dbg_print,sz_gluQuadricOrientation,err_9
5290 IgorA 102
	@@:
103
	ret
104
endp
105
 
6108 IgorA 106
align 4
107
proc gluQuadricTexture uses eax ebx, qobj:dword, texture:dword
108
	mov eax,[qobj]
109
	or eax,eax
110
	jz .err_q
111
	mov ebx,[texture]
112
	cmp ebx,GL_TRUE
113
	je @f
114
	cmp ebx,GL_FALSE
115
	je @f
116
	@@:
117
		mov dword[eax+offs_qobj_TextureFlag],ebx
118
		jmp @f
119
	.err_q:
120
		stdcall dbg_print,sz_gluQuadricTexture,err_9
121
	@@:
122
	ret
123
endp
124
 
5218 IgorA 125
;void gluCylinder(GLUquadricObj *qobj, GLdouble baseRadius, GLdouble topRadius, GLdouble height, GLint slices, GLint stacks )
126
;{
127
;}
128
 
129
; Disk (adapted from Mesa)
130
 
131
;void gluDisk(GLUquadricObj *qobj, GLdouble innerRadius, GLdouble outerRadius, GLint slices, GLint loops )
132
;{
133
;}
134
 
135
;
136
; Sphere (adapted from Mesa)
137
;
138
 
139
;input:
140
; float radius, int slices, int stacks
141
align 4
142
proc gluSphere qobj:dword, radius:dword, slices:dword, stacks:dword
143
locals
144
	rho dd ? ;float
145
	drho dd ?
146
	theta dd ?
147
	dtheta dd ?
148
	x dd ? ;float
149
	y dd ? ;float
150
	z dd ? ;float
151
	s dd ? ;float
152
	t dd ? ;float
153
	d_s dd ? ;float
154
	d_t dd ? ;float
155
	i dd ? ;int
156
	j dd ? ;int
157
	imax dd ? ;int
158
	normals dd ? ;int
159
	nsign dd ? ;float
160
endl
161
pushad
162
 
163
	mov eax,[qobj]
164
	cmp dword[eax+offs_qobj_Normals],GLU_NONE ;if (qobj.Normals==GLU_NONE)
165
	jne .els_0
166
		mov dword[normals],GL_FALSE
167
		jmp @f
168
	.els_0:
169
		mov dword[normals],GL_TRUE
170
	@@:
171
	cmp dword[eax+offs_qobj_Orientation],GLU_INSIDE ;if (qobj.Orientation==GLU_INSIDE)
172
	jne .els_1
173
		mov dword[nsign],-1.0
174
		jmp @f
175
	.els_1:
176
		mov dword[nsign],1.0
177
	@@:
178
 
179
	fldpi
180
	fidiv dword[stacks]
181
	fstp dword[drho]
182
	fld1
183
	fldpi
184
	fscale
185
	fidiv dword[slices]
186
	fstp dword[dtheta]
187
	ffree st0
188
	fincstp
189
 
5290 IgorA 190
	cmp dword[eax+offs_qobj_DrawStyle],GLU_FILL ;if (qobj.DrawStyle==GLU_FILL)
191
	jne .if_glu_line
192
 
5218 IgorA 193
	; draw +Z end as a triangle fan
194
	stdcall glBegin,GL_TRIANGLE_FAN
195
	cmp dword[normals],GL_TRUE
196
	jne @f
197
		stdcall glNormal3f, 0.0, 0.0, 1.0
198
	@@:
199
	cmp dword[eax+offs_qobj_TextureFlag],0 ;if (qobj.TextureFlag)
200
	je @f
6108 IgorA 201
		stdcall glTexCoord2f, 0.5,0.0
5218 IgorA 202
	@@:
203
	sub esp,4
204
	fld dword[nsign]
205
	fmul dword[radius]
206
	fstp dword[esp]
207
	stdcall glVertex3f, 0.0, 0.0 ;, nsign * radius
208
	fld dword[drho]
209
	fcos
210
	fmul dword[nsign]
211
	fstp dword[z] ;z = nsign * cos(drho)
212
	mov dword[j],0
213
	mov ecx,[slices]
214
align 4
215
	.cycle_0: ;for (j=0;j<=slices;j++)
216
		cmp dword[j],ecx
217
		jg .cycle_0_end
218
		fld dword[drho]
219
		fsin
220
		je @f
221
			fild dword[j]
222
			fmul dword[dtheta]
223
			jmp .t0_end
224
		@@:
225
			fldz
226
		.t0_end:
227
		fst dword[theta] ;theta = (j==slices) ? 0.0 : j * dtheta
228
		fsin
229
		fchs
230
		fmul st0,st1
231
		fstp dword[x] ;x = -sin(theta) * sin(drho)
232
		fld dword[theta]
233
		fcos
234
		fmulp
235
		fstp dword[y] ;y = cos(theta) * sin(drho)
236
		cmp dword[normals],GL_TRUE
237
		jne @f
238
			fld dword[nsign]
239
			fld dword[z]
240
			fmul st0,st1
241
			fstp dword[esp-4]
242
			fld dword[y]
243
			fmul st0,st1
244
			fstp dword[esp-8]
245
			fld dword[x]
5290 IgorA 246
			fmulp
5218 IgorA 247
			fstp dword[esp-12]
248
			sub esp,12
249
			stdcall glNormal3f ;x*nsign, y*nsign, z*nsign
250
		@@:
251
		fld dword[radius]
252
		fld dword[z]
253
		fmul st0,st1
254
		fstp dword[esp-4]
255
		fld dword[y]
256
		fmul st0,st1
257
		fstp dword[esp-8]
258
		fld dword[x]
5290 IgorA 259
		fmulp
5218 IgorA 260
		fstp dword[esp-12]
261
		sub esp,12
262
		call glVertex3f ;x*radius, y*radius, z*radius
263
		inc dword[j]
264
		jmp .cycle_0
265
	.cycle_0_end:
5290 IgorA 266
	call glEnd
5218 IgorA 267
 
268
	fld1
269
	fidiv dword[slices]
270
	fstp dword[d_s] ;1.0 / slices
271
	fld1
272
	fidiv dword[stacks]
273
	fstp dword[d_t] ;1.0 / stacks
274
	mov dword[t],1.0 ; because loop now runs from 0
275
	mov ebx,[stacks]
276
	cmp dword[eax+offs_qobj_TextureFlag],0 ;if (qobj.TextureFlag)
277
	je .els_2
278
		mov dword[i],0
279
		mov [imax],ebx
280
		jmp @f
281
	.els_2:
282
		mov dword[i],1
283
		dec ebx
284
		mov [imax],ebx
285
	@@:
286
 
287
	; draw intermediate stacks as quad strips
288
	mov ebx,[imax]
289
align 4
290
	.cycle_1: ;for (i=imin;i
291
	cmp dword[i],ebx
292
	jge .cycle_1_end
293
	fild dword[i]
294
	fmul dword[drho]
295
	fstp dword[rho] ;rho = i * drho
296
	stdcall glBegin,GL_QUAD_STRIP
297
	mov dword[s],0.0
298
	mov dword[j],0
299
align 4
300
	.cycle_2: ;for (j=0;j<=slices;j++)
301
		cmp dword[j],ecx
302
		jg .cycle_2_end
303
		fld dword[rho]
304
		fsin
305
		je @f
306
			fild dword[j]
307
			fmul dword[dtheta]
308
			jmp .t1_end
309
		@@:
310
			fldz
311
		.t1_end:
312
		fst dword[theta] ;theta = (j==slices) ? 0.0 : j * dtheta
313
		fsin
314
		fchs
315
		fmul st0,st1
316
		fstp dword[x] ;x = -sin(theta) * sin(rho)
317
		fld dword[theta]
318
		fcos
319
		fmulp
320
		fstp dword[y] ;y = cos(theta) * sin(rho)
321
		fld dword[rho]
322
		fcos
323
		fmul dword[nsign]
324
		fstp dword[z] ;z = nsign * cos(rho)
325
		cmp dword[normals],GL_TRUE
326
		jne @f
327
			fld dword[nsign]
328
			fld dword[z]
329
			fmul st0,st1
330
			fstp dword[esp-4]
331
			fld dword[y]
332
			fmul st0,st1
333
			fstp dword[esp-8]
334
			fld dword[x]
5290 IgorA 335
			fmulp
5218 IgorA 336
			fstp dword[esp-12]
337
			sub esp,12
338
			stdcall glNormal3f ;x*nsign, y*nsign, z*nsign
339
		@@:
340
		cmp dword[eax+offs_qobj_TextureFlag],0 ;if (qobj.TextureFlag)
341
		je @f
6108 IgorA 342
			fld1
343
			fsub dword[t]
344
			fstp dword[esp-4]
345
			sub esp,4
346
			stdcall glTexCoord2f, [s] ;,1-t
5218 IgorA 347
		@@:
348
		fld dword[radius]
349
		fld dword[z]
350
		fmul st0,st1
351
		fstp dword[esp-4]
352
		fld dword[y]
353
		fmul st0,st1
354
		fstp dword[esp-8]
355
		fld dword[x]
5290 IgorA 356
		fmulp
5218 IgorA 357
		fstp dword[esp-12]
358
		sub esp,12
359
		call glVertex3f ;x*radius, y*radius, z*radius
360
		fld dword[rho]
361
		fadd dword[drho]
362
		fsin ;st0 = sin(rho+drho)
363
		fld dword[theta]
364
		fsin
365
		fchs
366
		fmul st0,st1
367
		fstp dword[x] ;x = -sin(theta) * sin(rho+drho)
368
		fld dword[theta]
369
		fcos
370
		fmulp
371
		fstp dword[y] ;y = cos(theta) * sin(rho+drho)
372
		fld dword[rho]
373
		fadd dword[drho]
374
		fcos
375
		fmul dword[nsign]
376
		fstp dword[z] ;z = nsign * cos(rho+drho)
377
		cmp dword[normals],GL_TRUE
378
		jne @f
379
			fld dword[nsign]
380
			fld dword[z]
381
			fmul st0,st1
382
			fstp dword[esp-4]
383
			fld dword[y]
384
			fmul st0,st1
385
			fstp dword[esp-8]
386
			fld dword[x]
5290 IgorA 387
			fmulp
5218 IgorA 388
			fstp dword[esp-12]
389
			sub esp,12
390
			stdcall glNormal3f ;x*nsign, y*nsign, z*nsign
391
		@@:
392
		cmp dword[eax+offs_qobj_TextureFlag],0 ;if (qobj.TextureFlag)
393
		je @f
6108 IgorA 394
			fld1
395
			fsub dword[t]
396
			fadd dword[d_t]
397
			fstp dword[esp-4]
398
			sub esp,4
399
			stdcall glTexCoord2f, [s] ;,1-(t-dt)
5218 IgorA 400
			fld dword[s]
401
			fadd dword[d_s]
402
			fstp dword[s]
403
		@@:
404
		fld dword[radius]
405
		fld dword[z]
406
		fmul st0,st1
407
		fstp dword[esp-4]
408
		fld dword[y]
409
		fmul st0,st1
410
		fstp dword[esp-8]
411
		fld dword[x]
5290 IgorA 412
		fmulp
5218 IgorA 413
		fstp dword[esp-12]
414
		sub esp,12
415
		call glVertex3f ;x*radius, y*radius, z*radius
416
		inc dword[j]
417
		jmp .cycle_2
418
		.cycle_2_end:
5290 IgorA 419
	call glEnd
5218 IgorA 420
	fld dword[t]
421
	fsub dword[d_t]
422
	fstp dword[t]
423
	inc dword[i]
424
	jmp .cycle_1
425
	.cycle_1_end:
426
 
427
	; draw -Z end as a triangle fan
428
	stdcall glBegin,GL_TRIANGLE_FAN
429
	cmp dword[normals],GL_TRUE
430
	jne @f
431
		stdcall glNormal3f, 0.0, 0.0, -1.0
432
	@@:
433
	cmp dword[eax+offs_qobj_TextureFlag],0 ;if (qobj.TextureFlag)
434
	je @f
6108 IgorA 435
		stdcall glTexCoord2f, 0.5,1.0
5218 IgorA 436
		mov dword[s],1.0
437
		mov ebx,[d_t]
438
		mov [t],ebx
439
	@@:
440
	sub esp,4
441
	fld dword[radius]
442
	fchs
443
	fmul dword[nsign]
444
	fstp dword[esp]
445
	stdcall glVertex3f, 0.0, 0.0 ;, -radius*nsign
446
	fldpi
447
	fsub dword[drho]
448
	fst dword[rho]
449
	fcos
450
	fmul dword[nsign]
451
	fstp dword[z] ;z = nsign * cos(rho)
452
	mov [j],ecx
5290 IgorA 453
align 4
5218 IgorA 454
	.cycle_3: ;for (j=slices;j>=0;j--)
455
		cmp dword[j],0
456
		jl .cycle_3_end
457
		fld dword[rho]
458
		fsin
459
		je @f
460
			fild dword[j]
461
			fmul dword[dtheta]
462
			jmp .t2_end
463
		@@:
464
			fldz
465
		.t2_end:
466
		fst dword[theta] ;theta = (j==slices) ? 0.0 : j * dtheta
467
		fsin
468
		fchs
469
		fmul st0,st1
470
		fstp dword[x] ;x = -sin(theta) * sin(rho)
471
		fld dword[theta]
472
		fcos
473
		fmulp
474
		fstp dword[y] ;y = cos(theta) * sin(rho)
475
		cmp dword[normals],GL_TRUE
476
		jne @f
477
			fld dword[nsign]
478
			fld dword[z]
479
			fmul st0,st1
480
			fstp dword[esp-4]
481
			fld dword[y]
482
			fmul st0,st1
483
			fstp dword[esp-8]
484
			fld dword[x]
485
			fmul st0,st1
486
			fstp dword[esp-12]
487
			sub esp,12
488
			ffree st0
489
			fincstp
490
			stdcall glNormal3f ;x*nsign, y*nsign, z*nsign
491
		@@:
492
		cmp dword[eax+offs_qobj_TextureFlag],0 ;if (qobj.TextureFlag)
493
		je @f
6108 IgorA 494
			fld1
495
			fsub dword[t]
496
			fstp dword[esp-4]
497
			sub esp,4
498
			stdcall glTexCoord2f, [s] ;,1-t
5218 IgorA 499
			fld dword[s]
500
			fsub dword[d_s]
501
			fstp dword[s]
502
		@@:
503
		fld dword[radius]
504
		fld dword[z]
505
		fmul st0,st1
506
		fstp dword[esp-4]
507
		fld dword[y]
508
		fmul st0,st1
509
		fstp dword[esp-8]
510
		fld dword[x]
5290 IgorA 511
		fmulp
5218 IgorA 512
		fstp dword[esp-12]
513
		sub esp,12
514
		call glVertex3f ;x*radius, y*radius, z*radius
515
		dec dword[j]
516
		jmp .cycle_3
517
	.cycle_3_end:
5290 IgorA 518
	call glEnd
519
	jmp .end_f
520
 
521
	.if_glu_line:
522
	cmp dword[eax+offs_qobj_DrawStyle],GLU_LINE ;if (qobj.DrawStyle==GLU_LINE)
523
	je @f
524
	cmp dword[eax+offs_qobj_DrawStyle],GLU_SILHOUETTE ;if (qobj.DrawStyle==GLU_SILHOUETTE)
525
	je @f
526
	jmp .if_glu_point
527
	@@:
528
 
529
	; draw stack lines
530
	mov dword[i],1
531
	mov ebx,[stacks]
532
	mov ecx,[slices]
533
align 4
534
	.cycle_4: ;for (i=1;i
535
		cmp dword[i],ebx
536
		jge .cycle_4_end
537
		; stack line at i==stacks-1 was missing here
538
 
539
		fild dword[i]
540
		fmul dword[drho]
541
		fstp dword[rho] ;rho = i * drho
542
		stdcall glBegin,GL_LINE_LOOP
543
		mov dword[j],0
544
align 4
545
		.cycle_5: ;for (j=0;j
546
			cmp dword[j],ecx
547
			jge .cycle_5_end
548
			fild dword[j]
549
			fmul dword[dtheta]
550
			fst dword[theta] ;theta = j * dtheta;
551
			fcos
552
			fld dword[rho]
553
			fsin
554
			fxch ;толкаем sin(rho) в st1
555
			fmul st0,st1
556
			fstp dword[x] ;x = cos(theta) * sin(rho)
557
			fld dword[theta]
558
			fsin
559
			fmulp ;множим на sin(rho) ранее записанный в st1
560
			fstp dword[y] ;y = sin(theta) * sin(rho)
561
			fld dword[rho]
562
			fcos
563
			fstp dword[z] ;z = cos(rho)
564
			cmp dword[normals],GL_TRUE
565
			jne @f
566
				fld dword[nsign]
567
				fld dword[z]
568
				fmul st0,st1
569
				fstp dword[esp-4]
570
				fld dword[y]
571
				fmul st0,st1
572
				fstp dword[esp-8]
573
				fld dword[x]
574
				fmulp
575
				fstp dword[esp-12]
576
				sub esp,12
577
				stdcall glNormal3f ;x*nsign, y*nsign, z*nsign
578
			@@:
579
			fld dword[radius]
580
			fld dword[z]
581
			fmul st0,st1
582
			fstp dword[esp-4]
583
			fld dword[y]
584
			fmul st0,st1
585
			fstp dword[esp-8]
586
			fld dword[x]
587
			fmulp
588
			fstp dword[esp-12]
589
			sub esp,12
590
			call glVertex3f ;x*radius, y*radius, z*radius
591
			inc dword[j]
592
			jmp .cycle_5
593
		.cycle_5_end:
594
		call glEnd
595
		inc dword[i]
596
		jmp .cycle_4
597
	.cycle_4_end:
598
 
599
	; draw slice lines
600
	mov dword[j],0
601
align 4
602
	.cycle_6: ;for (j=0;j
603
		cmp dword[j],ecx
604
		jge .cycle_6_end
605
		fild dword[j]
606
		fmul dword[dtheta]
607
		fstp dword[theta] ;theta = j * dtheta;
608
		stdcall glBegin,GL_LINE_STRIP
609
		mov dword[i],0
610
align 4
611
		.cycle_7: ;for (i=0;i<=stacks;i++)
612
			cmp dword[i],ebx
613
			jg .cycle_7_end
614
			fild dword[i]
615
			fmul dword[drho]
616
			fst dword[rho] ;rho = i * drho
617
			fsin
618
			fld dword[theta]
619
			fcos
620
			fmul st0,st1
621
			fstp dword[x] ;x = cos(theta) * sin(rho)
622
			fld dword[theta]
623
			fsin
624
			fmulp
625
			fstp dword[y] ;y = sin(theta) * sin(rho)
626
			fld dword[rho]
627
			fcos
628
			fstp dword[z] ;z = cos(rho)
629
			cmp dword[normals],GL_TRUE
630
			jne @f
631
				fld dword[nsign]
632
				fld dword[z]
633
				fmul st0,st1
634
				fstp dword[esp-4]
635
				fld dword[y]
636
				fmul st0,st1
637
				fstp dword[esp-8]
638
				fld dword[x]
639
				fmulp
640
				fstp dword[esp-12]
641
				sub esp,12
642
				stdcall glNormal3f ;x*nsign, y*nsign, z*nsign
643
			@@:
644
			fld dword[radius]
645
			fld dword[z]
646
			fmul st0,st1
647
			fstp dword[esp-4]
648
			fld dword[y]
649
			fmul st0,st1
650
			fstp dword[esp-8]
651
			fld dword[x]
652
			fmulp
653
			fstp dword[esp-12]
654
			sub esp,12
655
			call glVertex3f ;x*radius, y*radius, z*radius
656
			inc dword[i]
657
			jmp .cycle_7
658
		.cycle_7_end:
659
		call glEnd
660
		inc dword[j]
661
		jmp .cycle_6
662
	.cycle_6_end:
663
	jmp .end_f
664
 
665
	.if_glu_point:
666
	cmp dword[eax+offs_qobj_DrawStyle],GLU_POINT ;if (qobj.DrawStyle==GLU_POINT)
667
	jne .end_f
668
 
669
	; top and bottom-most points
670
	stdcall glBegin,GL_POINTS
671
	cmp dword[normals],GL_TRUE
672
	jne @f
673
		stdcall glNormal3f, 0.0,0.0,dword[nsign]
674
	@@:
675
	stdcall glVertex3f, 0.0,0.0,dword[radius]
676
	cmp dword[normals],GL_TRUE
677
	jne @f
678
		sub esp,4
679
		fld dword[nsign]
680
		fchs
681
		fstp dword[esp]
682
		stdcall glNormal3f, 0.0,0.0 ;,-nsign
683
	@@:
684
	sub esp,4
685
	fld dword[radius]
686
	fchs
687
	fstp dword[esp]
688
	stdcall glVertex3f, 0.0,0.0 ;,-radius
689
 
690
	; loop over stacks
691
	mov dword[i],1
692
	mov ebx,[stacks]
693
	mov ecx,[slices]
694
align 4
695
	.cycle_8: ;for (i=1;i
696
		cmp dword[i],ebx
697
		jge .cycle_8_end
698
		fild dword[i]
699
		fmul dword[drho]
700
		fstp dword[rho] ;rho = i * drho
701
 
702
		mov dword[j],0
703
align 4
704
		.cycle_9: ;for (j=0;j
705
			cmp dword[j],ecx
706
			jge .cycle_9_end
707
			fild dword[j]
708
			fmul dword[dtheta]
709
			fst dword[theta] ;theta = j * dtheta;
710
			fcos
711
			fld dword[rho]
712
			fsin
713
			fxch ;толкаем sin(rho) в st1
714
			fmul st0,st1
715
			fstp dword[x] ;x = cos(theta) * sin(rho)
716
			fld dword[theta]
717
			fsin
718
			fmulp ;множим на sin(rho) ранее записанный в st1
719
			fstp dword[y] ;y = sin(theta) * sin(rho)
720
			fld dword[rho]
721
			fcos
722
			fstp dword[z] ;z = cos(rho)
723
			cmp dword[normals],GL_TRUE
724
			jne @f
725
				fld dword[nsign]
726
				fld dword[z]
727
				fmul st0,st1
728
				fstp dword[esp-4]
729
				fld dword[y]
730
				fmul st0,st1
731
				fstp dword[esp-8]
732
				fld dword[x]
733
				fmulp
734
				fstp dword[esp-12]
735
				sub esp,12
736
				stdcall glNormal3f ;x*nsign, y*nsign, z*nsign
737
			@@:
738
			fld dword[radius]
739
			fld dword[z]
740
			fmul st0,st1
741
			fstp dword[esp-4]
742
			fld dword[y]
743
			fmul st0,st1
744
			fstp dword[esp-8]
745
			fld dword[x]
746
			fmulp
747
			fstp dword[esp-12]
748
			sub esp,12
749
			call glVertex3f ;x*radius, y*radius, z*radius
750
			inc dword[j]
751
			jmp .cycle_9
752
		.cycle_9_end:
753
		inc dword[i]
754
		jmp .cycle_8
755
	.cycle_8_end:
756
	call glEnd
757
 
758
	.end_f:
5218 IgorA 759
popad
760
	ret
761
endp