Subversion Repositories Kolibri OS

Rev

Rev 6108 | Rev 6286 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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