Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.99 KB | None | 0 0
  1. format PE GUI 4.0
  2.  
  3. entry start
  4.  
  5. include 'win32w.inc'
  6. include 'egna\opengl32_equate.inc'
  7. ;include 'egna\glu32_equate.inc'
  8.  
  9. ;---------------------------------------
  10.  
  11. section '.data' data readable writeable
  12.  
  13. _class du 'FASMWIN32',0
  14. _title du 'title',0
  15. _error du 'error',0
  16. hwnd dd ?
  17.  
  18. clock dd ?
  19. theta GLfloat 0.6
  20. hdc dd ? ;device context handle
  21. hrc dd ?
  22. pfd PIXELFORMATDESCRIPTOR
  23. rc RECT
  24.  
  25. wc WNDCLASS 0,WindowProc,0,0,NULL,NULL,NULL,COLOR_BTNFACE+1,NULL,_class
  26. msg MSG
  27.  
  28. ;---------------------------------------
  29.  
  30. ;section '.rsrc' resource data readable
  31. ;
  32. ; directory 24,manifests
  33. ; resource manifests,1,LANG_NEUTRAL,manifest
  34. ;
  35. ; resdata manifest
  36. ; file 'include\egna\manifest.xml'
  37. ; endres
  38.  
  39. ;---------------------------------------
  40.  
  41. section '.text' code readable executable
  42.  
  43. start:
  44. invoke GetModuleHandle,0
  45. mov [wc.hInstance],eax
  46. invoke LoadIcon,0,IDI_APPLICATION
  47. mov [wc.hIcon],eax
  48. invoke LoadCursor,0,IDC_ARROW
  49. mov [wc.hCursor],eax
  50.  
  51. invoke RegisterClass,wc
  52. test eax,eax
  53. jz error
  54.  
  55. invoke CreateWindowEx,NULL,_class,_title,WS_VISIBLE+WS_DLGFRAME+WS_MINIMIZEBOX+WS_SYSMENU,500,250,640,640,NULL,NULL,[wc.hInstance],NULL
  56. mov [hwnd],eax
  57. test eax,eax
  58. jz error
  59.  
  60. msg_loop:
  61. invoke GetMessage,msg,NULL,0,0
  62. or eax,eax
  63. jz end_loop
  64. invoke TranslateMessage,msg
  65. invoke DispatchMessage,msg
  66. jmp msg_loop
  67.  
  68.  
  69. error:
  70. invoke MessageBox,NULL,_error,NULL,MB_ICONERROR+MB_OK
  71.  
  72. end_loop:
  73. invoke ExitProcess,[msg.wParam]
  74.  
  75. ;---------------------------------------
  76.  
  77. proc WindowProc uses ebx esi edi,hwnd,wmsg,wparam,lparam ;windows procedure. ebx,esi,edi modifieras aldrig av windås API
  78.  
  79. cmp [wmsg],WM_CREATE
  80. je .wmcreate
  81. ; cmp [wmsg],WM_SIZE
  82. ; je .wmsize
  83. cmp [wmsg],WM_PAINT
  84. je .wmpaint
  85. ; cmp [wmsg],WM_COMMAND
  86. ; je .wmcommand
  87. cmp [wmsg],WM_KEYDOWN
  88. je .wmkeydown
  89. cmp [wmsg],WM_DESTROY
  90. je .wmdestroy
  91.  
  92. .defwndproc:
  93. invoke DefWindowProc,[hwnd],[wmsg],[wparam],[lparam]
  94. jmp .finish
  95.  
  96. .wmcreate:
  97. invoke GetDC,[hwnd]
  98. mov [hdc],eax
  99. mov edi,pfd
  100. mov ecx,sizeof.PIXELFORMATDESCRIPTOR shr 2
  101. xor eax,eax
  102. rep stosd
  103. mov [pfd.nSize],sizeof.PIXELFORMATDESCRIPTOR
  104. mov [pfd.nVersion],1
  105. mov [pfd.dwFlags],PFD_SUPPORT_OPENGL+PFD_DOUBLEBUFFER+PFD_DRAW_TO_WINDOW
  106. mov [pfd.iLayerType],PFD_MAIN_PLANE
  107. mov [pfd.iPixelType],PFD_TYPE_RGBA
  108. mov [pfd.cColorBits],16
  109. mov [pfd.cDepthBits],16
  110. mov [pfd.cAccumBits],0
  111. mov [pfd.cStencilBits],0
  112. invoke ChoosePixelFormat,[hdc],pfd
  113. invoke SetPixelFormat,[hdc],eax,pfd
  114. invoke wglCreateContext,[hdc]
  115. mov [hrc],eax
  116. invoke wglMakeCurrent,[hdc],[hrc]
  117. invoke GetClientRect,[hwnd],rc
  118. invoke glViewport,0,0,[rc.right],[rc.bottom]
  119. invoke GetTickCount
  120. mov [clock],eax
  121. xor eax,eax
  122. jmp .finish
  123.  
  124. ; .wmsize:
  125. ; invoke GetClientRect,[hwnd],rc
  126. ; invoke glViewport,0,0,[rc.right],[rc.bottom]
  127. ; xor eax,eax
  128. ; jmp .finish
  129.  
  130. .wmpaint:
  131. ;invoke ValidateRect,[hwnd],NULL
  132. invoke GetTickCount
  133. sub eax,[clock]
  134. cmp eax,10
  135. jb .animation_ok
  136. add [clock],eax
  137. invoke glRotatef,[theta],0.1,0.5,0.7
  138. .animation_ok:
  139.  
  140. invoke glClear,GL_COLOR_BUFFER_BIT+GL_DEPTH_BUFFER_BIT
  141. invoke glEnable,GL_DEPTH_TEST
  142. invoke glEnable,GL_LIGHTING
  143. invoke glEnable,GL_LIGHT0
  144. invoke glDisable,GL_COLOR_MATERIAL
  145.  
  146. invoke glBegin,GL_QUADS
  147.  
  148. invoke glNormal3f,0.0,0.0,1.0
  149. invoke glColor3f,1.0,0.6,0.4
  150. invoke glVertex3f,-0.5,0.5,0.5
  151. invoke glColor3f,0.4,1.0,0.6
  152. invoke glVertex3f,-0.5,-0.5,0.5
  153. invoke glColor3f,0.6,0.4,1.0
  154. invoke glVertex3f,0.5,-0.5,0.5
  155. invoke glColor3f,1.0,0.6,0.4
  156. invoke glVertex3f,0.5,0.4,0.3
  157.  
  158. invoke glNormal3f,1.0,0.0,0.0
  159. invoke glColor3f,1.0,0.6,0.4
  160. invoke glVertex3f,0.5,0.5,0.5
  161. invoke glColor3f,0.4,1.0,0.6
  162. invoke glVertex3f,0.5,-0.5,0.5
  163. invoke glColor3f,0.6,0.4,1.0
  164. invoke glVertex3f,0.5,-0.5,-0.5
  165. invoke glColor3f,1.0,0.6,0.4
  166. invoke glVertex3f,0.5,0.5,-0.5
  167.  
  168. invoke glNormal3f,-1.0,0.0,0.0
  169. invoke glColor3f,0.3,0.7,1.0
  170. invoke glVertex3f,-0.5,0.5,-0.5
  171. invoke glColor3f,1.0,0.3,0.7
  172. invoke glVertex3f,-0.5,-0.5,-0.5
  173. invoke glColor3f,0.7,1.0,0.3
  174. invoke glVertex3f,-0.5,-0.5,0.5
  175. invoke glColor3f,0.3,0.7,1.0
  176. invoke glVertex3f,-0.5,0.5,0.5
  177.  
  178. invoke glNormal3f,0.0,0.0,-1.0
  179. invoke glColor3f,0.3,0.7,1.0
  180. invoke glVertex3f,0.5,0.5,-0.5
  181. invoke glColor3f,1.0,0.3,0.7
  182. invoke glVertex3f,0.5,-0.5,-0.5
  183. invoke glColor3f,0.7,1.0,0.3
  184. invoke glVertex3f,-0.5,-0.5,-0.5
  185. invoke glColor3f,0.3,0.7,1.0
  186. invoke glVertex3f,-0.5,0.5,-0.5
  187.  
  188. invoke glNormal3f,0.0,-1.0,0.0
  189. invoke glColor3f,1.0,0.0,0.0
  190. invoke glVertex3f,0.5,0.5,0.5
  191. invoke glColor3f,0.0,1.0,0.0
  192. invoke glVertex3f,0.5,0.5,-0.5
  193. invoke glColor3f,0.0,0.0,1.0
  194. invoke glVertex3f,-0.5,0.5,-0.5
  195. invoke glColor3f,1.0,0.0,0.0
  196. invoke glVertex3f,-0.5,0.5,0.5
  197.  
  198. invoke glNormal3f,0.0,-1.0,0.0
  199. invoke glColor3f,0.0,0.0,1.0
  200. invoke glVertex3f,-0.5,-0.5,0.5
  201. invoke glColor3f,0.0,1.0,0.0
  202. invoke glVertex3f,-0.5,-0.5,-0.5
  203. invoke glColor3f,1.0,0.0,0.0
  204. invoke glVertex3f,0.5,-0.5,-0.5
  205. invoke glColor3f,0.0,0.0,1.0
  206. invoke glVertex3f,0.5,-0.5,0.5
  207.  
  208. invoke glEnd
  209. invoke SwapBuffers,[hdc]
  210. xor eax,eax
  211. jmp .finish
  212.  
  213. ; .wmcommand:
  214. ; jmp .finish
  215.  
  216. .wmkeydown:
  217. cmp [wparam],VK_ESCAPE
  218. jne .defwndproc
  219.  
  220. .wmdestroy:
  221. invoke wglMakeCurrent,0,0
  222. invoke wglDeleteContext,[hrc]
  223. invoke ReleaseDC,[hwnd],[hdc]
  224. invoke PostQuitMessage,0
  225. xor eax,eax
  226.  
  227. .finish:
  228. ret
  229.  
  230. endp
  231.  
  232. ;---------------------------------------
  233.  
  234. section '.idata' import data readable writeable
  235.  
  236. library kernel32,'KERNEL32.DLL', user32,'USER32.DLL',\
  237. shell32,'SHELL32.DLL', gdi32,'GDI32.DLL',\
  238. opengl32,'OPENGL32.DLL';,comctl32,'comctl32.dll',\
  239. ;glu32,'GLU32.DLL'
  240. include 'api\kernel32.inc'
  241. include 'api\user32.inc'
  242. include 'api\shell32.inc'
  243. include 'api\gdi32.inc'
  244. ; include 'api\comdlg32.inc'
  245. include 'egna\opengl32.inc'
  246. ; include 'egna\glu32.inc'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement