Hacky parser and exporter for minimum values of implementation-defined constants in GL.
I parsed the OpenGL specifications to generate a cpp file containing implementation-defined minimum values for various constants. If you want to tweak it (good luck), the parser that generates it is here.
OpenGL has various implementation-defined constants that have minimum values. Unfortunately, this information is buried within the OpenGL specifications in tables that are hard to find and copy from. At any rate, they're not convenient. Yet, it is sometimes necessary to expect at least a certain functionality from a given implementation and to know what must, at minimum, be supported. Or maybe, your driver lies to you, and you can't depend on the driver giving you reliable values.
This project does all the hard work for you. By hand, I painstakingly copied the tables that contain minimum values, from the following OpenGL specifications into the following raw files:
- OpenGL 1.0 -> gl1.0.txt
- OpenGL 1.1 -> gl1.1.txt
- OpenGL 1.2 -> gl1.2.txt
- OpenGL 1.3 -> gl1.3.txt
- OpenGL 1.4 -> gl1.4.txt
- OpenGL 1.5 -> gl1.5.txt
- OpenGL 2.0 -> gl2.0.txt
- OpenGL 2.1 -> gl2.1.txt
- OpenGL 3.0 -> gl3.0.txt
- OpenGL 3.1 -> gl3.1.txt
- OpenGL 3.2 -> gl3.2.txt
- OpenGL 3.3 -> gl3.3.txt
- OpenGL 4.0 -> gl4.0.txt
- OpenGL 4.1 -> gl4.1.txt
- OpenGL 4.2 -> gl4.2.txt
- OpenGL 4.3 -> gl4.3.txt
- OpenGL 4.4 -> gl4.4.txt
- OpenGL 4.5 -> gl4.5.txt
- OpenGL 4.6 -> gl4.6.txt
Many tables didn't copy over well from the PDFs, so I had to manually adjust/fix them.
From here, I wrote an extremely crufty purpose-built "parser" that operates on raw strings. It gradually creates order from the chaos. At the end, a raw representation of each constant along with minimums for each GL version is generated.
From here, the result can be copied into, say, a cpp file for easy use. This will be the way most users will want to interact with this project.
Contributions are welcome! The parser mostly works and mostly outputs sane data, yet there are still major areas where help is needed:
- A few constants are incorrectly parsed. This happens when the "value" was actually a footnote. The result is typically a small number, and later occurrences of the constant tend to give it a real, larger value. So the results (probably?) aren't very wrong. But this still shouldn't happen.
- Support for more constants. If the value is not easy to find, then the entire constant is ignored. This is sortof bad. For example, if the type is listed as "Z+", then we ought to be able to assume the value is at least 1, even if there's no other information in the specification at all. As another example, some constants are defined in terms of other constants. Figuring out the values for these would (only) require finding the minimum values of those dependencies and then doing the calculation.
- One might like to expand this project to handle initial values too, or perhaps other interesting information, like maximum value or notes given in the specifications.
- Code cleanup. Boy does it need it.
If you'd rather help support development of similar projects, you can donate.
The parser is licensed under the MIT license. The output is licensed under MIT or the public domain, whichever you prefer. If you use this project, starring it will help me keep track of roughly how many people found it helpful! Thanks!