Subversion Repositories Kolibri OS

Rev

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