Advertisement
Guest User

Untitled

a guest
Jul 26th, 2012
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.97 KB | None | 0 0
  1. ; ----------------------------------------------------------------------------
  2. ; triangle.asm
  3. ;
  4. ; A very simple *Linux* opengl application using the glut library. it
  5. ; draws a nicely colored triangle in a top-level application window.
  6. ; Version of numit_or: numit_or@cantv.net
  7. ;
  8. ; Compile with:
  9. ; nasm -felf triangle.asm -o triangle.o
  10. ; gcc triangle.o -o triangle -L/usr/X11R6/lib -lGL -lglut -lglu
  11. ;
  12. ; you can find nasm in:
  13. ; http://nasm.sourceforge.net/
  14. ;
  15. ; ----------------------------------------------------------------------------
  16. ;
  17. ; libGL is in
  18. ; libMesaGL1 pack (Mandrake)
  19. ; mesag3 - mesag-dev - mesa-common-dev packs (Debian)
  20. ; libglut and libGLU are in:
  21. ; libMesaglut pack (Mandrake)
  22. ; freeglut3 - freeglut3-dev - libglut3 - libglut3-dev (Debian)
  23. ;
  24. ; ----------------------------------------------------------------------------
  25. global main
  26. extern glClear
  27. extern glBegin
  28. extern glEnd
  29. extern glColor3f
  30. extern glVertex3f
  31. extern glFlush
  32. extern glutInit
  33. extern glutInitDisplayMode
  34. extern glutInitWindowPosition
  35. extern glutInitWindowSize
  36. extern glutCreateWindow
  37. extern glutDisplayFunc
  38. extern glutMainLoop
  39.  
  40. GL_COLOR_BUFFER_BIT equ 16384
  41. GL_POLYGON equ 9
  42.  
  43. section .data
  44. title db 'A Simple Triangle', 0
  45. zero dd 0.0
  46. one dd 1.0
  47. half dd 0.5
  48. neghalf dd -0.5
  49.  
  50. section .text
  51. display:
  52. push dword GL_COLOR_BUFFER_BIT
  53. call glClear ; glClear(GL_COLOR_BUFFER_BIT)
  54. add esp, 4
  55. push byte GL_POLYGON
  56. call glBegin ; glBegin(GL_POLYGON)
  57. add esp, 4
  58. push byte 0
  59. push byte 0
  60. push dword [one]
  61. call glColor3f ; glColor3f(1, 0, 0)
  62. add esp, 12
  63. push byte 0
  64. push dword [neghalf]
  65. push dword [neghalf]
  66. call glVertex3f ; glVertex(-.5, -.5, 0)
  67. add esp, 12
  68. push byte 0
  69. push dword [one]
  70. push byte 0
  71. call glColor3f ; glColor3f(0, 1, 0)
  72. add esp, 12
  73. push byte 0
  74. push dword [neghalf]
  75. push dword [half]
  76. call glVertex3f ; glVertex(.5, -.5, 0)
  77. add esp, 12
  78. push dword [one]
  79. push byte 0
  80. push byte 0
  81. call glColor3f ; glColor3f(0, 0, 1)
  82. add esp, 12
  83. push byte 0
  84. push dword [half]
  85. push byte 0
  86. call glVertex3f ; glVertex(0, .5, 0)
  87. add esp, 12
  88. call glEnd ; glEnd()
  89. call glFlush ; glFlush()
  90. ret
  91.  
  92. main:
  93. push ebp
  94. mov ebp, esp
  95. push dword [ebp+12]
  96. lea eax, [ebp+8]
  97. push eax
  98. call glutInit
  99. push byte 0
  100. call glutInitDisplayMode
  101. add esp, 4
  102. push dword 80
  103. push dword 80
  104. call glutInitWindowPosition
  105. add esp, 8
  106. push dword 300
  107. push dword 400
  108. call glutInitWindowSize
  109. add esp, 8
  110. push title
  111. call glutCreateWindow
  112. add esp, 4
  113. push display
  114. call glutDisplayFunc
  115. call glutMainLoop
  116. leave
  117. ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement