Advertisement
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: numit_or@cantv.net
- ;
- ; 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 glColor3f
- extern glVertex3f
- 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:
- push dword GL_COLOR_BUFFER_BIT
- call glClear ; glClear(GL_COLOR_BUFFER_BIT)
- add esp, 4
- push byte GL_POLYGON
- call glBegin ; glBegin(GL_POLYGON)
- add esp, 4
- push byte 0
- push byte 0
- push dword [one]
- call glColor3f ; glColor3f(1, 0, 0)
- add esp, 12
- push byte 0
- push dword [neghalf]
- push dword [neghalf]
- call glVertex3f ; glVertex(-.5, -.5, 0)
- add esp, 12
- push byte 0
- push dword [one]
- push byte 0
- call glColor3f ; glColor3f(0, 1, 0)
- add esp, 12
- push byte 0
- push dword [neghalf]
- push dword [half]
- call glVertex3f ; glVertex(.5, -.5, 0)
- add esp, 12
- push dword [one]
- push byte 0
- push byte 0
- call glColor3f ; glColor3f(0, 0, 1)
- add esp, 12
- push byte 0
- push dword [half]
- push byte 0
- call glVertex3f ; glVertex(0, .5, 0)
- add esp, 12
- call glEnd ; glEnd()
- call glFlush ; glFlush()
- ret
- main:
- push ebp
- mov ebp, esp
- push dword [ebp+12]
- lea eax, [ebp+8]
- push eax
- call glutInit
- push byte 0
- call glutInitDisplayMode
- add esp, 4
- push dword 80
- push dword 80
- call glutInitWindowPosition
- add esp, 8
- push dword 300
- push dword 400
- call glutInitWindowSize
- add esp, 8
- push title
- call glutCreateWindow
- add esp, 4
- push display
- call glutDisplayFunc
- call glutMainLoop
- leave
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement