1 ##########################################################################
3 # Copyright 2010 VMware, Inc.
6 # Permission is hereby granted, free of charge, to any person obtaining a copy
7 # of this software and associated documentation files (the "Software"), to deal
8 # in the Software without restriction, including without limitation the rights
9 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 # copies of the Software, and to permit persons to whom the Software is
11 # furnished to do so, subject to the following conditions:
13 # The above copyright notice and this permission notice shall be included in
14 # all copies or substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 ##########################################################################/
32 class GlRetracer(retrace.Retracer):
37 if __name__ == '__main__':
39 print '#include <stdlib.h>'
40 print '#include <string.h>'
43 print '#include <windows.h>'
46 print '#include <GL/glew.h>'
47 print '#include <GL/glut.h>'
49 print 'static bool double_buffer = false;'
52 retracer = GlRetracer()
53 retracer.retrace_api(glapi.glapi)
58 static bool insideGlBeginEnd;
60 static void display(void) {
63 while ((call = parser.parse_call())) {
64 if (call->name == "glFlush") {
69 if (call->name == "glXSwapBuffers" ||
70 call->name == "wglSwapBuffers") {
80 if (call->name == "glBegin") {
81 insideGlBeginEnd = true;
84 if (call->name == "glEnd") {
85 insideGlBeginEnd = false;
88 if (!insideGlBeginEnd) {
89 GLenum error = glGetError();
90 if (error != GL_NO_ERROR) {
91 std::cerr << "warning: glGetError() = ";
94 std::cerr << "GL_INVALID_ENUM";
96 case GL_INVALID_VALUE:
97 std::cerr << "GL_INVALID_VALUE";
99 case GL_INVALID_OPERATION:
100 std::cerr << "GL_INVALID_OPERATION";
102 case GL_STACK_OVERFLOW:
103 std::cerr << "GL_STACK_OVERFLOW";
105 case GL_STACK_UNDERFLOW:
106 std::cerr << "GL_STACK_UNDERFLOW";
108 case GL_OUT_OF_MEMORY:
109 std::cerr << "GL_OUT_OF_MEMORY";
111 case GL_INVALID_FRAMEBUFFER_OPERATION:
112 std::cerr << "GL_INVALID_FRAMEBUFFER_OPERATION";
114 case GL_TABLE_TOO_LARGE:
115 std::cerr << "GL_TABLE_TOO_LARGE";
130 static void idle(void) {
134 int main(int argc, char **argv)
138 for (i = 1; i < argc; ++i) {
139 const char *arg = argv[i];
145 if (!strcmp(arg, "--")) {
148 else if (!strcmp(arg, "-db")) {
149 double_buffer = true;
150 } else if (!strcmp(arg, "-v")) {
153 std::cerr << "error: unknown option " << arg << "\\n";
158 glutInit(&argc, argv);
159 glutInitWindowPosition(0, 0);
160 glutInitWindowSize(800, 600);
161 glutInitDisplayMode(GLUT_DEPTH | GLUT_RGB | (double_buffer ? GLUT_DOUBLE : GLUT_SINGLE));
162 glutCreateWindow(argv[0]);
165 glutDisplayFunc(&display);
168 for (GLuint h = 0; h < 1024; ++h) {
172 for ( ; i < argc; ++i) {
173 if (parser.open(argv[i])) {