Subversion Repositories Kolibri OS

Rev

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

  1. use32
  2.         org 0x0
  3.         db 'MENUET01'
  4.         dd 0x1
  5.         dd start
  6.         dd i_end
  7.         dd mem,stacktop
  8.         dd 0,cur_dir_path
  9.  
  10. include '../../../../../../programs/proc32.inc'
  11. include '../../../../../../programs/macros.inc'
  12. include '../../../../../../programs/develop/libraries/box_lib/load_lib.mac'
  13. include '../../../../../../programs/dll.inc'
  14. include '../opengl_const.inc'
  15.  
  16. @use_library
  17.  
  18. align 4
  19. start:
  20.         load_library name_tgl, cur_dir_path, library_path, system_path, \
  21.                 err_message_found_lib, head_f_l, import_lib_tinygl, err_message_import, head_f_i
  22.         cmp eax,-1
  23.         jz button.exit
  24.  
  25.         mcall 40,0x27
  26.  
  27. stdcall [kosglMakeCurrent], 10,10,300,225,ctx1
  28. stdcall [glEnable], GL_DEPTH_TEST
  29. stdcall [gluNewQuadric]
  30. mov [qObj],eax
  31.  
  32. stdcall [glClearColor], 0.5,0.5,0.5,0.0
  33.  
  34. call draw_3d
  35.  
  36. align 4
  37. red_win:
  38.         call draw_window
  39.  
  40. align 4
  41. still:
  42.         mcall 10
  43.         cmp al,1
  44.         jz red_win
  45.         cmp al,2
  46.         jz key
  47.         cmp al,3
  48.         jz button
  49.         jmp still
  50.  
  51. align 4
  52. draw_window:
  53.         pushad
  54.         mcall 12,1
  55.  
  56.         mov edx,0x33ffffff ;0x73ffffff
  57.         mcall 0,(50 shl 16)+330,(30 shl 16)+275,,,caption
  58.         stdcall [kosglSwapBuffers]
  59.  
  60.         mcall 12,2
  61.         popad
  62.         ret
  63.  
  64. align 4
  65. key:
  66.         mcall 2
  67.  
  68.         cmp ah,27 ;Esc
  69.         je button.exit
  70.  
  71.         cmp ah,61 ;+
  72.         jne @f
  73.             fld dword[scale]
  74.             fadd dword[delt_sc]
  75.             fstp dword[scale]
  76.             call draw_3d
  77.             stdcall [kosglSwapBuffers]
  78.         @@:
  79.         cmp ah,45 ;-
  80.         jne @f
  81.             fld dword[scale]
  82.             fsub dword[delt_sc]
  83.             fstp dword[scale]
  84.             call draw_3d
  85.             stdcall [kosglSwapBuffers]
  86.         @@:
  87.         cmp ah,178 ;Up
  88.         jne @f
  89.                 fld dword[angle_y]
  90.                 fadd dword[delt_size]
  91.                 fstp dword[angle_y]
  92.                 call draw_3d
  93.                 stdcall [kosglSwapBuffers]
  94.         @@:
  95.         cmp ah,177 ;Down
  96.         jne @f
  97.                 fld dword[angle_y]
  98.                 fsub dword[delt_size]
  99.                 fstp dword[angle_y]
  100.                 call draw_3d
  101.                 stdcall [kosglSwapBuffers]
  102.         @@:
  103.         cmp ah,176 ;Left
  104.         jne @f
  105.                 fld dword[angle_z]
  106.                 fadd dword[delt_size]
  107.                 fstp dword[angle_z]
  108.                 call draw_3d
  109.                 stdcall [kosglSwapBuffers]
  110.         @@:
  111.         cmp ah,179 ;Right
  112.         jne @f
  113.                 fld dword[angle_z]
  114.                 fsub dword[delt_size]
  115.                 fstp dword[angle_z]
  116.                 call draw_3d
  117.                 stdcall [kosglSwapBuffers]
  118.         @@:
  119.  
  120.         jmp still
  121.  
  122. align 4
  123. button:
  124.         mcall 17
  125.         cmp ah,1
  126.         jne still
  127. .exit:
  128.         stdcall [gluDeleteQuadric], [qObj]
  129.         mcall -1
  130.  
  131.  
  132. align 4
  133. caption db 'Test gluSphere, [Esc] - exit, [<-],[->],[Up],[Down] - rotate',0
  134. align 4
  135. ctx1 db 28 dup (0) ;TinyGLContext or KOSGLContext
  136. ;sizeof.TinyGLContext = 28
  137.  
  138. align 4
  139. draw_3d:
  140. stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT ;очистим буфер цвета и глубины
  141.  
  142. stdcall [glColor3f], 1.0, 1.0, 0.0
  143.  
  144. stdcall [glPushMatrix]
  145.         stdcall [glTranslatef], 0.0,0.0,0.5
  146.         stdcall [glScalef], [scale], [scale], [scale]
  147.  
  148.         stdcall [glRotatef], [angle_z],0.0,0.0,1.0
  149.         stdcall [glRotatef], [angle_y],0.0,1.0,0.0
  150.         stdcall [gluSphere], [qObj], 1.0, 16,16
  151.  
  152.         stdcall [glColor3f], 1.0, 0.0, 0.0
  153.         stdcall [glTranslatef], -1.6,0.0,0.0
  154.         stdcall [gluSphere], [qObj], 0.55, 8,8
  155.  
  156.         stdcall [glColor3f], 0.0, 0.0, 1.0
  157.         stdcall [glTranslatef], 3.2,0.0,0.0
  158.         stdcall [gluSphere], [qObj], 0.55, 8,8
  159. stdcall [glPopMatrix]
  160. ret
  161.  
  162. qObj dd 0
  163.  
  164. scale dd 0.4
  165. delt_sc dd 0.05
  166. angle_z dd 0.0
  167. angle_y dd 0.0
  168. delt_size dd 3.0
  169.  
  170. ;--------------------------------------------------
  171. align 4
  172. import_lib_tinygl:
  173.  
  174. macro E_LIB n
  175. {
  176.         n dd sz_#n
  177. }
  178. include '../export.inc'
  179.         dd 0,0
  180. macro E_LIB n
  181. {
  182.         sz_#n db `n,0
  183. }
  184. include '../export.inc'
  185.  
  186. ;--------------------------------------------------
  187. system_path db '/sys/lib/'
  188. name_tgl db 'tinygl.obj',0
  189. err_message_found_lib db 'Sorry I cannot load library tinygl.obj',0
  190. head_f_i:
  191. head_f_l db 'System error',0
  192. err_message_import db 'Error on load import library tinygl.obj',0
  193. ;--------------------------------------------------
  194.  
  195. i_end:
  196.         rb 1024
  197. stacktop:
  198. cur_dir_path:
  199.         rb 4096
  200. library_path:
  201.         rb 4096
  202. mem:
  203.