+
+ /**
+ * Try to autodetect the API.
+ *
+ * XXX: Ideally we would allow to mix multiple APIs in a single trace,
+ * but as it stands today, retrace is done separately for each API.
+ */
+ if (api == API_UNKNOWN) {
+ const char *n = sig->name;
+ if ((n[0] == 'g' && n[1] == 'l' && n[2] == 'X') || // glX*
+ (n[0] == 'w' && n[1] == 'g' && n[2] == 'l' && n[3] >= 'A' && n[3] <= 'Z') || // wgl[A-Z]*
+ (n[0] == 'C' && n[1] == 'G' && n[2] == 'L')) { // CGL*
+ api = trace::API_GL;
+ } else if (n[0] == 'e' && n[1] == 'g' && n[2] == 'l' && n[3] >= 'A' && n[3] <= 'Z') { // egl[A-Z]*
+ api = trace::API_EGL;
+ } else if ((n[0] == 'D' &&
+ ((n[1] == 'i' && n[2] == 'r' && n[3] == 'e' && n[4] == 'c' && n[5] == 't') || // Direct*
+ (n[1] == '3' && n[2] == 'D'))) || // D3D*
+ (n[0] == 'C' && n[1] == 'r' && n[2] == 'e' && n[3] == 'a' && n[4] == 't' && n[5] == 'e')) { // Create*
+ api = trace::API_DX;
+ } else {
+ /* TODO */
+ }
+ }
+
+ /**
+ * Note down the signature of special functions for future reference.
+ *
+ * NOTE: If the number of comparisons increases we should move this to a
+ * separate function and use bisection.
+ */
+ if (sig->num_args == 0 &&
+ strcmp(sig->name, "glGetError") == 0) {
+ glGetErrorSig = sig;
+ }
+