Subversion Repositories Kolibri OS

Rev

Rev 8069 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. use32
  2.         org 0
  3.         db 'MENUET01'
  4.         dd 1,start,i_end,mem,stacktop,0,cur_dir_path
  5.  
  6. include '../../../../../proc32.inc'
  7. include '../../../../../macros.inc'
  8. include '../../../../../KOSfuncs.inc'
  9. include '../../../../../load_lib.mac'
  10. include '../../../../../dll.inc'
  11. include '../opengl_const.inc'
  12.  
  13. @use_library
  14.  
  15. align 4
  16. start:
  17.         load_library name_tgl, library_path, system_path, import_lib_tinygl
  18.         cmp eax,SF_TERMINATE_PROCESS
  19.         jz button.exit
  20.  
  21.         mcall SF_SET_EVENTS_MASK,0x27
  22.  
  23. stdcall [kosglMakeCurrent], 10,10,300,225,ctx1
  24. stdcall [glEnable], GL_DEPTH_TEST
  25.  
  26. call draw_3d
  27.  
  28. align 4
  29. red_win:
  30.         call draw_window
  31.  
  32. align 16
  33. still:
  34.         mcall SF_WAIT_EVENT
  35.         cmp al,1
  36.         jz red_win
  37.         cmp al,2
  38.         jz key
  39.         cmp al,3
  40.         jz button
  41.         jmp still
  42.  
  43. align 4
  44. draw_window:
  45.         pushad
  46.         mcall SF_REDRAW,SSF_BEGIN_DRAW
  47.  
  48.         mov edx,0x33ffffff ;0x73ffffff
  49.         mcall SF_CREATE_WINDOW,(50 shl 16)+330,(30 shl 16)+275,,,caption
  50.         call [kosglSwapBuffers]
  51.  
  52.         mcall SF_REDRAW,SSF_END_DRAW
  53.         popad
  54.         ret
  55.  
  56. align 4
  57. key:
  58.         mcall SF_GET_KEY
  59.  
  60.         cmp ah,27 ;Esc
  61.         je button.exit
  62.  
  63.         ;178 ;Up
  64.         ;177 ;Down
  65.         cmp ah,176 ;Left
  66.         jne @f
  67.                 fld dword[angle_z]
  68.                 fadd dword[delt_size]
  69.                 fstp dword[angle_z]
  70.                 call draw_3d
  71.                 call [kosglSwapBuffers]
  72.                 jmp still
  73.         @@:
  74.         cmp ah,179 ;Right
  75.         jne @f
  76.                 fld dword[angle_z]
  77.                 fsub dword[delt_size]
  78.                 fstp dword[angle_z]
  79.                 call draw_3d
  80.                 call [kosglSwapBuffers]
  81.                 ;jmp still
  82.         @@:
  83.  
  84.         jmp still
  85.  
  86. align 4
  87. button:
  88.         mcall SF_GET_BUTTON
  89.         cmp ah,1
  90.         jne still
  91. .exit:
  92.         mcall SF_TERMINATE_PROCESS
  93.  
  94.  
  95. align 4
  96. caption db 'Test tinygl library, [Esc] - exit, [<-] and [->] - rotate',0
  97.  
  98. align 4
  99. draw_3d:
  100. stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT ;очистим буфер цвета и глубины
  101.  
  102. call [glPushMatrix]
  103.         stdcall [glRotatef], [angle_z],0.0,0.0,1.0
  104.  
  105.         stdcall [glScalef], 0.3,0.3,0.3
  106.  
  107.         stdcall [glColor3f],1.0, 0.0, 0.0
  108.         stdcall [glBegin],GL_LINE_LOOP
  109.                 stdcall [glVertex3f], 0,      0.9, 0.1
  110.                 stdcall [glVertex3f], 0.636,  0.636, 0.1
  111.                 stdcall [glVertex3f], 0.9,    0.0, 0.1
  112.                 stdcall [glVertex3f], 0.636, -0.636, 0.1
  113.                 stdcall [glColor3f],0.0, 0.0, 1.0
  114.                 stdcall [glVertex3f], 0.0,   -0.9, 0.1
  115.                 stdcall [glVertex3f], -0.636,-0.636, 0.1
  116.                 stdcall [glVertex3f], -0.9,   0.0, 0.1
  117.                 stdcall [glVertex3f], -0.636, 0.636, 0.1
  118.         call [glEnd]
  119.  
  120.         stdcall [glBegin],GL_LINE_LOOP
  121.                 stdcall [glVertex3f], 0.0, 1.1, 0.1
  122.                 stdcall [glVertex3f], 0.778, 0.778, 0.1
  123.                 stdcall [glVertex3f], 2.1, 0.0, 0.1
  124.                 stdcall [glVertex3f], 0.778, -0.778, 0.1
  125.                 stdcall [glVertex3f], 0.0, -1.1, 0.1
  126.                 stdcall [glVertex3f], -0.778, -0.778, 0.1
  127.                 stdcall [glVertex3f], -2.1, 0.0, 0.1
  128.                 stdcall [glVertex3f], -0.778, 0.778, 0.1
  129.         call [glEnd]
  130.  
  131. call [glPopMatrix]
  132. ret
  133.  
  134. angle_z dd 0.0
  135. delt_size dd 3.0
  136.  
  137. ;--------------------------------------------------
  138. align 4
  139. import_lib_tinygl:
  140.  
  141. macro E_LIB n
  142. {
  143.         n dd sz_#n
  144. }
  145. include '../export.inc'
  146.         dd 0,0
  147. macro E_LIB n
  148. {
  149.         sz_#n db `n,0
  150. }
  151. include '../export.inc'
  152.  
  153. ;--------------------------------------------------
  154. system_path db '/sys/lib/'
  155. name_tgl db 'tinygl.obj',0
  156. ;--------------------------------------------------
  157.  
  158. align 16
  159. i_end:
  160. ctx1 rb 28 ;TinyGLContext or KOSGLContext
  161. ;sizeof.TinyGLContext = 28
  162. cur_dir_path rb 4096
  163. library_path rb 4096
  164.         rb 1024
  165. stacktop:
  166. mem:
  167.