Guest User

Untitled

a guest
Jul 26th, 2012
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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: [email protected]
  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 glColor3d
  30. extern glVertex3d
  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. mov rdi, GL_COLOR_BUFFER_BIT
  53. call glClear ; glClear(GL_COLOR_BUFFER_BIT)
  54. mov rdi, GL_POLYGON
  55. call glBegin ; glBegin(GL_POLYGON)
  56. mov rdi, 0
  57. mov rsi, 0
  58. mov rdx, one
  59. call glColor3d ; glColor3f(1, 0, 0)
  60. mov rdi, 0
  61. mov rsi, neghalf
  62. mov rdx, neghalf
  63. call glVertex3d ; glVertex(-.5, -.5, 0)
  64. mov rdi, 0
  65. mov rsi, 0
  66. mov rdx, 0
  67. call glColor3d ; glColor3f(0, 0, 1)
  68. mov rdi, 0
  69. mov rsi, half
  70. mov rdx, 0
  71. call glVertex3d ; glVertex(0, .5, 0)
  72. call glEnd ; glEnd()
  73. call glFlush ; glFlush()
  74. ret
  75.  
  76. main:
  77. # push rbp
  78. # mov rbp, rsp
  79. # sub rsp, 16
  80. # push qword [rbp+12]
  81. # lea rax, [rbp+8]
  82. mov rsi, rcx
  83. call glutInit
  84. mov rsi, 0
  85. call glutInitDisplayMode
  86. mov rsi, 100
  87. mov rdi, 100
  88. call glutInitWindowPosition
  89. mov rdi, 400
  90. mov rsi, 300
  91. call glutInitWindowSize
  92. mov rdi, title
  93. call glutCreateWindow
  94. mov rdi, display
  95. call glutDisplayFunc
  96. call glutMainLoop
  97. leave
  98. ret
Advertisement
Add Comment
Please, Sign In to add comment