~swag/armagetronad/0.2.9-sty+ct+ap-fork

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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/usr/bin/python

# checks bugle trace log for OpenGL problems

import sys

count = 0
lineNo = 0
inList = False
inBlock = False
legalLists = {}
setLists = {}
usedInList = {}
usedInBlock = {}
usedOutBlock = {}

for line in sys.stdin:
    line=line[line.find('gl'):]

    # split line into functional parts
    op=line.find('(')

    # the function mane
    function=line[0:op]
    rest=line[op+1:-1]
    cl=rest.find(')')

    # the argument list
    args=rest[0:cl]
    rest=rest[cl+1:]

    # the result
    result=''
    eq=rest.find('= ')
    if eq >= 0:
        result = rest[eq+2:]

    lineNo=lineNo+1
    
    if False and function.find( 'List' ) >= 0 and function.find( 'Call' ) < 0:
        print "%d (%s) (%s) (%s) (%s)" % (count, line[:-1], function, args, result)

        count = count + 1
        if count > 100:
            exit(-1)

    if function == 'glBegin':
        if inBlock:
            print "Error: Still in block.", lineNo
            exit(-1)
        inBlock = True
    elif function == 'glEnd':
        if not inBlock:
            print "Error: Not in block.", lineNo
            exit(-1)
        inBlock = False
    else:
        blockDict=usedOutBlock
        if inBlock:
            blockDict=usedInBlock
        if not function in blockDict:
            blockDict[function]=lineNo

    if function == 'glGenLists':
        legalLists[result] = True
        if inList:
            print "Error: Still in list generation.", lineNo
            exit(-1)

    if function == 'glEndList':
        if not inList:
            print "Error: Not in list generation.", lineNo
            exit(-1)
        if inBlockAtListStart != inBlock:
            print "Error: glBegin/glEnd mismatch in list.", lineNo
            exit(-1)
        inList=False

    if function == 'glNewList':
        inBlockAtListStart=inBlock
        list=args[0:args.find(',')]
        currentList=list
        if inList:
            print "Error: Still in list generation.", lineNo
            exit(-1)
        if not legalLists[list]:
            print "Error: list %s used, but not generated." % [list], lineNo
            exit(-1)
        setLists[list]=True
        inList=True
    elif inList:
        if not function in usedInList:
            usedInList[function]=lineNo
            #print lineNo, function
        
    if function == 'glCallList':
        list=args
        if not legalLists[list]:
            print "Error: list %s used, but not generated." % [list], lineNo
            exit(-1)
        if inList and currentList == list:
            print "Error: list %s used, but it's just getting generated." % [list], lineNo
            exit(-1)
        if not setLists[list]:
            print "Error: list %s used, but not set." % [list], lineNo
            exit(-1)

    if function == 'glDeleteLists':
        list=args[0:args.find(',')]
        if not legalLists[list]:
            print "Error: list %s used, but not generated." % [list], lineNo
            exit(-1)
        legalLists[list]=False
        setLists[list]=False

print "Used in display lists:"
for f in usedInList:
    print f, usedInList[f]

print
print "Used in glBegin/End:"
for f in usedInBlock:
    print f, usedInBlock[f]

print
print "Used outside glBegin/End:"
for f in usedOutBlock:
    print f, usedOutBlock[f]