summaryrefslogtreecommitdiffstats
path: root/src/VBox/GuestHost/OpenGL/state_tracker/state_isenabled.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/VBox/GuestHost/OpenGL/state_tracker/state_isenabled.py')
-rwxr-xr-xsrc/VBox/GuestHost/OpenGL/state_tracker/state_isenabled.py75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_isenabled.py b/src/VBox/GuestHost/OpenGL/state_tracker/state_isenabled.py
new file mode 100755
index 00000000..35a3815a
--- /dev/null
+++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_isenabled.py
@@ -0,0 +1,75 @@
+# Copyright (c) 2001, Stanford University
+# All rights reserved.
+#
+# See the file LICENSE.txt for information on redistributing this software.
+
+from __future__ import print_function
+import sys, re, string
+import apiutil
+
+
+line_re = re.compile(r'^(\S+)\s+(GL_\S+)\s+(.*)\s*$')
+extensions_line_re = re.compile(r'^(\S+)\s+(GL_\S+)\s(\S+)\s+(.*)\s*$')
+
+params = {}
+extended_params = {}
+
+input = open( sys.argv[2]+"/state_isenabled.txt", 'r' )
+for line in input.readlines():
+ match = line_re.match( line )
+ if match:
+ type = match.group(1)
+ pname = match.group(2)
+ fields = match.group(3).split()
+ params[pname] = ( type, fields )
+
+input = open( sys.argv[2]+"/state_extensions_isenabled.txt", 'r' )
+for line in input.readlines():
+ match = extensions_line_re.match( line )
+ if match:
+ type = match.group(1)
+ pname = match.group(2)
+ ifdef = match.group(3)
+ fields = match.group(4).split()
+ extended_params[pname] = ( type, ifdef, fields )
+
+apiutil.CopyrightC()
+
+print("""
+/* DO NOT EDIT - THIS FILE GENERATED BY THE state_isenabled.py SCRIPT */
+#include <stdio.h>
+#include <math.h>
+
+#include "state.h"
+#include "state/cr_statetypes.h"
+
+GLboolean STATE_APIENTRY crStateIsEnabled( GLenum pname )
+{
+ CRContext *g = GetCurrentContext();
+
+ if (g->current.inBeginEnd)
+ {
+ crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glGet called in Begin/End");
+ return 0;
+ }
+
+ switch (pname) {
+""")
+
+for pname in sorted(params.keys()):
+ print("\tcase %s:" % pname)
+ print("\t\treturn %s;" % params[pname][1][0])
+
+for pname in sorted(extended_params.keys()):
+ (srctype,ifdef,fields) = extended_params[pname]
+ ext = ifdef[3:] # the extension name with the "GL_" prefix removed
+ ext = ifdef
+ print('#ifdef CR_%s' % ext)
+ print("\tcase %s:" % pname)
+ print("\t\treturn %s;" % extended_params[pname][2][0])
+ print('#endif /* CR_%s */' % ext)
+print("\tdefault:")
+print("\t\tcrStateError(__LINE__, __FILE__, GL_INVALID_ENUM, \"glIsEnabled: Unknown enum: %d\", pname);")
+print("\t\treturn 0;")
+print("\t}")
+print("}")