Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; ----------------------------------------------------------------------------
- ; triangle.asm
- ;
- ; A very simple *Linux* opengl application using the glut library. it
- ; draws a nicely colored triangle in a top-level application window.
- ; Version of numit_or: [email protected]
- ;
- ; Compile with:
- ; nasm -felf triangle.asm -o triangle.o
- ; gcc triangle.o -o triangle -L/usr/X11R6/lib -lGL -lglut -lglu
- ;
- ; you can find nasm in:
- ; http://nasm.sourceforge.net/
- ;
- ; ----------------------------------------------------------------------------
- ;
- ; libGL is in
- ; libMesaGL1 pack (Mandrake)
- ; mesag3 - mesag-dev - mesa-common-dev packs (Debian)
- ; libglut and libGLU are in:
- ; libMesaglut pack (Mandrake)
- ; freeglut3 - freeglut3-dev - libglut3 - libglut3-dev (Debian)
- ;
- ; ----------------------------------------------------------------------------
- global main
- extern glClear
- extern glBegin
- extern glEnd
- extern glColor3d
- extern glVertex3d
- extern glFlush
- extern glutInit
- extern glutInitDisplayMode
- extern glutInitWindowPosition
- extern glutInitWindowSize
- extern glutCreateWindow
- extern glutDisplayFunc
- extern glutMainLoop
- GL_COLOR_BUFFER_BIT equ 16384
- GL_POLYGON equ 9
- section .data
- title db 'A Simple Triangle', 0
- zero dd 0.0
- one dd 1.0
- half dd 0.5
- neghalf dd -0.5
- section .text
- display:
- mov rdi, GL_COLOR_BUFFER_BIT
- call glClear ; glClear(GL_COLOR_BUFFER_BIT)
- mov rdi, GL_POLYGON
- call glBegin ; glBegin(GL_POLYGON)
- mov rdi, 0
- mov rsi, 0
- mov rdx, one
- call glColor3d ; glColor3f(1, 0, 0)
- mov rdi, 0
- mov rsi, neghalf
- mov rdx, neghalf
- call glVertex3d ; glVertex(-.5, -.5, 0)
- mov rdi, 0
- mov rsi, 0
- mov rdx, 0
- call glColor3d ; glColor3f(0, 0, 1)
- mov rdi, 0
- mov rsi, half
- mov rdx, 0
- call glVertex3d ; glVertex(0, .5, 0)
- call glEnd ; glEnd()
- call glFlush ; glFlush()
- ret
- main:
- # push rbp
- # mov rbp, rsp
- # sub rsp, 16
- # push qword [rbp+12]
- # lea rax, [rbp+8]
- mov rsi, rcx
- call glutInit
- mov rsi, 0
- call glutInitDisplayMode
- mov rsi, 100
- mov rdi, 100
- call glutInitWindowPosition
- mov rdi, 400
- mov rsi, 300
- call glutInitWindowSize
- mov rdi, title
- call glutCreateWindow
- mov rdi, display
- call glutDisplayFunc
- call glutMainLoop
- leave
- ret
Advertisement
Add Comment
Please, Sign In to add comment