"glBufferRegionEnabled",
]
+ def retrace_function(self, function):
+ Retracer.retrace_function(self, function)
+
def call_function(self, function):
if function.name in ("glDrawArrays", "glDrawElements", "glDrawRangeElements", "glMultiDrawElements"):
print ' GLint __array_buffer = 0;'
self.fail_function(function)
print ' }'
+ if function.name == "glEnd":
+ print ' insideGlBeginEnd = false;'
Retracer.call_function(self, function)
+ if function.name == "glBegin":
+ print ' insideGlBeginEnd = true;'
+ else:
+ # glGetError is not allowed inside glBegin/glEnd
+ print ' checkGlError();'
+
def extract_arg(self, function, arg, arg_type, lvalue, rvalue):
if function.name in [
if __name__ == '__main__':
print
- print '#include <stdlib.h>'
print '#include <string.h>'
+ print '#include <iostream>'
print
print '#ifdef WIN32'
print '#include <windows.h>'
print '#include <GL/glut.h>'
print
print 'static bool double_buffer = false;'
+ print 'static bool insideGlBeginEnd = false;'
print
+ print '''
+static void
+checkGlError(void) {
+ if (insideGlBeginEnd) {
+ return;
+ }
+
+ GLenum error = glGetError();
+ if (error == GL_NO_ERROR) {
+ return;
+ }
+
+ std::cerr << "warning: glGetError() = ";
+ switch (error) {
+ case GL_INVALID_ENUM:
+ std::cerr << "GL_INVALID_ENUM";
+ break;
+ case GL_INVALID_VALUE:
+ std::cerr << "GL_INVALID_VALUE";
+ break;
+ case GL_INVALID_OPERATION:
+ std::cerr << "GL_INVALID_OPERATION";
+ break;
+ case GL_STACK_OVERFLOW:
+ std::cerr << "GL_STACK_OVERFLOW";
+ break;
+ case GL_STACK_UNDERFLOW:
+ std::cerr << "GL_STACK_UNDERFLOW";
+ break;
+ case GL_OUT_OF_MEMORY:
+ std::cerr << "GL_OUT_OF_MEMORY";
+ break;
+ case GL_INVALID_FRAMEBUFFER_OPERATION:
+ std::cerr << "GL_INVALID_FRAMEBUFFER_OPERATION";
+ break;
+ case GL_TABLE_TOO_LARGE:
+ std::cerr << "GL_TABLE_TOO_LARGE";
+ break;
+ default:
+ std::cerr << error;
+ break;
+ }
+ std::cerr << "\\n";
+}
+'''
api = glapi.glapi
retracer = GlRetracer()
retracer.retrace_api(glapi.glapi)
print '''
-Trace::Parser parser;
-
-static bool insideGlBeginEnd;
+static Trace::Parser parser;
static void display(void) {
- Trace::Call *call;
-
- while ((call = parser.parse_call())) {
- if (call->name() == "glFlush") {
- glFlush();
- return;
- }
-
- if (call->name() == "glXSwapBuffers" ||
- call->name() == "wglSwapBuffers") {
- if (double_buffer)
- glutSwapBuffers();
- else
+ Trace::Call *call;
+
+ while ((call = parser.parse_call())) {
+ if (call->name() == "glFlush") {
glFlush();
- return;
- }
-
- retrace_call(*call);
-
- if (call->name() == "glBegin") {
- insideGlBeginEnd = true;
- }
-
- if (call->name() == "glEnd") {
- insideGlBeginEnd = false;
- }
-
- if (!insideGlBeginEnd) {
- GLenum error = glGetError();
- if (error != GL_NO_ERROR) {
- std::cerr << "warning: glGetError() = ";
- switch (error) {
- case GL_INVALID_ENUM:
- std::cerr << "GL_INVALID_ENUM";
- break;
- case GL_INVALID_VALUE:
- std::cerr << "GL_INVALID_VALUE";
- break;
- case GL_INVALID_OPERATION:
- std::cerr << "GL_INVALID_OPERATION";
- break;
- case GL_STACK_OVERFLOW:
- std::cerr << "GL_STACK_OVERFLOW";
- break;
- case GL_STACK_UNDERFLOW:
- std::cerr << "GL_STACK_UNDERFLOW";
- break;
- case GL_OUT_OF_MEMORY:
- std::cerr << "GL_OUT_OF_MEMORY";
- break;
- case GL_INVALID_FRAMEBUFFER_OPERATION:
- std::cerr << "GL_INVALID_FRAMEBUFFER_OPERATION";
- break;
- case GL_TABLE_TOO_LARGE:
- std::cerr << "GL_TABLE_TOO_LARGE";
- break;
- default:
- std::cerr << error;
- break;
+ return;
+ }
+
+ if (!retrace_call(*call)) {
+ if (call->name() == "glXSwapBuffers" ||
+ call->name() == "wglSwapBuffers") {
+ if (double_buffer)
+ glutSwapBuffers();
+ else
+ glFlush();
+ return;
}
- std::cerr << "\\n";
- }
- }
- }
+ }
+ }
- glFlush();
- glutIdleFunc(NULL);
+ glFlush();
+ glutIdleFunc(NULL);
}
static void idle(void) {
- glutPostRedisplay();
+ glutPostRedisplay();
}
int main(int argc, char **argv)
{
- int i;
- for (i = 1; i < argc; ++i) {
- const char *arg = argv[i];
-
- if (arg[0] != '-') {
- break;
- }
-
- if (!strcmp(arg, "--")) {
- break;
- }
- else if (!strcmp(arg, "-db")) {
- double_buffer = true;
- } else if (!strcmp(arg, "-v")) {
- ++verbosity;
- } else {
- std::cerr << "error: unknown option " << arg << "\\n";
- return 1;
- }
- }
-
- glutInit(&argc, argv);
- glutInitWindowPosition(0, 0);
- glutInitWindowSize(800, 600);
- glutInitDisplayMode(GLUT_DEPTH | GLUT_RGB | (double_buffer ? GLUT_DOUBLE : GLUT_SINGLE));
- glutCreateWindow(argv[0]);
- glewInit();
-
- glutDisplayFunc(&display);
- glutIdleFunc(&idle);
-
- for (GLuint h = 0; h < 1024; ++h) {
- __list_map[h] = h;
- }
-
- for ( ; i < argc; ++i) {
- if (parser.open(argv[i])) {
- glutMainLoop();
- parser.close();
- }
- }
-
- return 0;
+ int i;
+ for (i = 1; i < argc; ++i) {
+ const char *arg = argv[i];
+
+ if (arg[0] != '-') {
+ break;
+ }
+
+ if (!strcmp(arg, "--")) {
+ break;
+ }
+ else if (!strcmp(arg, "-db")) {
+ double_buffer = true;
+ } else if (!strcmp(arg, "-v")) {
+ ++verbosity;
+ } else {
+ std::cerr << "error: unknown option " << arg << "\\n";
+ return 1;
+ }
+ }
+
+ glutInit(&argc, argv);
+ glutInitWindowPosition(0, 0);
+ glutInitWindowSize(800, 600);
+ glutInitDisplayMode(GLUT_DEPTH | GLUT_RGB | (double_buffer ? GLUT_DOUBLE : GLUT_SINGLE));
+ glutCreateWindow(argv[0]);
+ glewInit();
+
+ glutDisplayFunc(&display);
+ glutIdleFunc(&idle);
+
+ for (GLuint h = 0; h < 1024; ++h) {
+ __list_map[h] = h;
+ }
+
+ for ( ; i < argc; ++i) {
+ if (parser.open(argv[i])) {
+ glutMainLoop();
+ parser.close();
+ }
+ }
+
+ return 0;
}
-'''
+'''
self.retrace_functions(api.functions)
-
-if __name__ == '__main__':
- print
- print '#include <stdlib.h>'
- print '#include <string.h>'
- print
- print '#ifdef WIN32'
- print '#include <windows.h>'
- print '#endif'
- print
- print '#include <GL/glew.h>'
- print '#include <GL/glut.h>'
- print
- retrace_api(glapi.glapi)
- print '''
-
-Trace::Parser parser;
-
-static bool insideGlBeginEnd;
-
-static void display(void) {
- Trace::Call *call;
-
- while ((call = parser.parse_call())) {
- if (call->name() == "glFlush" ||
- call->name() == "glXSwapBuffers" ||
- call->name() == "wglSwapBuffers") {
- glFlush();
- return;
- }
-
- retrace_call(*call);
-
- if (call->name() == "glBegin") {
- insideGlBeginEnd = true;
- }
-
- if (call->name() == "glEnd") {
- insideGlBeginEnd = false;
- }
-
- if (!insideGlBeginEnd) {
- GLenum error = glGetError();
- if (error != GL_NO_ERROR) {
- std::cerr << "warning: glGetError() = ";
- switch (error) {
- case GL_INVALID_ENUM:
- std::cerr << "GL_INVALID_ENUM";
- break;
- case GL_INVALID_VALUE:
- std::cerr << "GL_INVALID_VALUE";
- break;
- case GL_INVALID_OPERATION:
- std::cerr << "GL_INVALID_OPERATION";
- break;
- case GL_STACK_OVERFLOW:
- std::cerr << "GL_STACK_OVERFLOW";
- break;
- case GL_STACK_UNDERFLOW:
- std::cerr << "GL_STACK_UNDERFLOW";
- break;
- case GL_OUT_OF_MEMORY:
- std::cerr << "GL_OUT_OF_MEMORY";
- break;
- case GL_INVALID_FRAMEBUFFER_OPERATION:
- std::cerr << "GL_INVALID_FRAMEBUFFER_OPERATION";
- break;
- case GL_TABLE_TOO_LARGE:
- std::cerr << "GL_TABLE_TOO_LARGE";
- break;
- default:
- std::cerr << error;
- break;
- }
- std::cerr << "\\n";
- }
- }
- }
-
- glFlush();
- glutIdleFunc(NULL);
-}
-
-static void idle(void) {
- glutPostRedisplay();
-}
-
-int main(int argc, char **argv)
-{
- glutInit(&argc, argv);
- glutInitWindowPosition(0, 0);
- glutInitWindowSize(800, 600);
- glutInitDisplayMode(GLUT_DEPTH | GLUT_RGB | GLUT_SINGLE);
- glutCreateWindow(argv[0]);
- glewInit();
-
- glutDisplayFunc(&display);
- glutIdleFunc(&idle);
-
- int i;
- for (i = 1; i < argc; ++i) {
- const char *arg = argv[i];
-
- if (arg[0] != '-') {
- break;
- }
-
- if (!strcmp(arg, "--")) {
- break;
- }
- else if (!strcmp(arg, "-v")) {
- ++verbosity;
- } else {
- std::cerr << "error: unknown option " << arg << "\\n";
- return 1;
- }
- }
-
- for ( ; i < argc; ++i) {
- if (parser.open(argv[i])) {
- glutMainLoop();
- parser.close();
- }
- }
-
- return 0;
-}
-
-'''