-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtriangle.asm
More file actions
74 lines (71 loc) · 2.31 KB
/
triangle.asm
File metadata and controls
74 lines (71 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
global _main
extern _glClear@4
extern _glBegin@4
extern _glEnd@0
extern _glColor3f@12
extern _glVertex3f@12
extern _glFlush@0
extern _glutInit@8
extern _glutInitDisplayMode@4
extern _glutInitWindowPosition@8
extern _glutInitWindowSize@8
extern _glutCreateWindow@4
extern _glutDisplayFunc@4
extern _glutMainLoop@0
section .text
title: db 'A Simple Triangle', 0
zero: dd 0.0
one: dd 1.0
half: dd 0.5
neghalf:dd -0.5
display:
push dword 16384
call _glClear@4 ; glClear(GL_COLOR_BUFFER_BIT)
push dword 9
call _glBegin@4 ; glBegin(GL_POLYGON)
push dword 0
push dword 0
push dword [one]
call _glColor3f@12 ; glColor3f(1, 0, 0)
push dword 0
push dword [neghalf]
push dword [neghalf]
call _glVertex3f@12 ; glVertex(-.5, -.5, 0)
push dword 0
push dword [one]
push dword 0
call _glColor3f@12 ; glColor3f(0, 1, 0)
push dword 0
push dword [neghalf]
push dword [half]
call _glVertex3f@12 ; glVertex(.5, -.5, 0)
push dword [one]
push dword 0
push dword 0
call _glColor3f@12 ; glColor3f(0, 0, 1)
push dword 0
push dword [half]
push dword 0
call _glVertex3f@12 ; glVertex(0, .5, 0)
call _glEnd@0 ; glEnd()
call _glFlush@0 ; glFlush()
ret
_main:
push dword [esp+8] ; push argv
lea eax, [esp+8] ; get addr of argc (offset changed :-)
push eax
call _glutInit@8 ; glutInit(&argc, argv)
push dword 0
call _glutInitDisplayMode@4
push dword 80
push dword 80
call _glutInitWindowPosition@8
push dword 300
push dword 400
call _glutInitWindowSize@8
push title
call _glutCreateWindow@4
push display
call _glutDisplayFunc@4
call _glutMainLoop@0
ret