1 | # Copyright (c) 2001, Stanford University
|
---|
2 | # All rights reserved.
|
---|
3 | #
|
---|
4 | # See the file LICENSE.txt for information on redistributing this software.
|
---|
5 |
|
---|
6 | import sys, re, string
|
---|
7 | import apiutil
|
---|
8 |
|
---|
9 |
|
---|
10 | line_re = re.compile(r'^(\S+)\s+(GL_\S+)\s+(.*)\s*$')
|
---|
11 | extensions_line_re = re.compile(r'^(\S+)\s+(GL_\S+)\s(\S+)\s+(.*)\s*$')
|
---|
12 |
|
---|
13 | params = {}
|
---|
14 | extended_params = {}
|
---|
15 |
|
---|
16 | input = open( sys.argv[2]+"/state_isenabled.txt", 'r' )
|
---|
17 | for line in input.readlines():
|
---|
18 | match = line_re.match( line )
|
---|
19 | if match:
|
---|
20 | type = match.group(1)
|
---|
21 | pname = match.group(2)
|
---|
22 | fields = string.split( match.group(3) )
|
---|
23 | params[pname] = ( type, fields )
|
---|
24 |
|
---|
25 | input = open( sys.argv[2]+"/state_extensions_isenabled.txt", 'r' )
|
---|
26 | for line in input.readlines():
|
---|
27 | match = extensions_line_re.match( line )
|
---|
28 | if match:
|
---|
29 | type = match.group(1)
|
---|
30 | pname = match.group(2)
|
---|
31 | ifdef = match.group(3)
|
---|
32 | fields = string.split( match.group(4) )
|
---|
33 | extended_params[pname] = ( type, ifdef, fields )
|
---|
34 |
|
---|
35 | apiutil.CopyrightC()
|
---|
36 |
|
---|
37 | print """
|
---|
38 | /* DO NOT EDIT - THIS FILE GENERATED BY THE state_isenabled.py SCRIPT */
|
---|
39 | #include <stdio.h>
|
---|
40 | #include <math.h>
|
---|
41 |
|
---|
42 | #include "state.h"
|
---|
43 | #include "state/cr_statetypes.h"
|
---|
44 |
|
---|
45 | GLboolean STATE_APIENTRY crStateIsEnabled( GLenum pname )
|
---|
46 | {
|
---|
47 | CRContext *g = GetCurrentContext();
|
---|
48 |
|
---|
49 | if (g->current.inBeginEnd)
|
---|
50 | {
|
---|
51 | crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glGet called in Begin/End");
|
---|
52 | return 0;
|
---|
53 | }
|
---|
54 |
|
---|
55 | switch ( pname ) {
|
---|
56 | """
|
---|
57 |
|
---|
58 | keys = params.keys()
|
---|
59 | keys.sort();
|
---|
60 |
|
---|
61 | for pname in keys:
|
---|
62 | print "\tcase %s:" % pname
|
---|
63 | print "\t\treturn %s;" % params[pname][1][0]
|
---|
64 |
|
---|
65 | keys = extended_params.keys();
|
---|
66 | keys.sort()
|
---|
67 |
|
---|
68 | for pname in keys:
|
---|
69 | (srctype,ifdef,fields) = extended_params[pname]
|
---|
70 | ext = ifdef[3:] # the extension name with the "GL_" prefix removed
|
---|
71 | ext = ifdef
|
---|
72 | print '#ifdef CR_%s' % ext
|
---|
73 | print "\tcase %s:" % pname
|
---|
74 | print "\t\treturn %s;" % extended_params[pname][2][0]
|
---|
75 | print '#endif /* CR_%s */' % ext
|
---|
76 | print "\tdefault:"
|
---|
77 | print "\t\tcrStateError(__LINE__, __FILE__, GL_INVALID_ENUM, \"glIsEnabled: Unknown enum: %d\", pname);"
|
---|
78 | print "\t\treturn 0;"
|
---|
79 | print "\t}"
|
---|
80 | print "}"
|
---|