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