static void pr (const char *fmt, ...) { va_list args; va_start(args, fmt); vpr(fmt, args); va_end(args); }
void warn(const char *fmt, ...) { va_list ap; int code = errno; va_start(ap, fmt); vpr(code, fmt, ap); va_end(ap); }
void err(int eval, const char *fmt, ...) { va_list ap; int code = errno; va_start(ap, fmt); vpr(code, fmt, ap); va_end(ap); exit(eval); }
int kpr (const char *fn, unsigned line, const char *fmt, ...) { va_list args; begin(); pr("TAYSOM: %s<%d> ", fn, line); va_start(args, fmt); vpr(fmt, args); va_end(args); end(); return 1; }
void replace(void) { _module_handle = GetModuleHandle(_module.c_str()); if (!_module_handle) { _module_handle = LoadLibrary(_module.c_str()); if (_module_handle) _module_loaded = true; } if (_module_handle) _original = (void*)GetProcAddress(_module_handle, _symbol.c_str()); std::cout << __FILE__ << __LINE__ << std::endl; if (_original) { virutal_protect_remover vpr(_original, 16); if (backup_opcodes(5)) { instruction* instr = (instruction*)_original; instr->jmp.code = 0xE9; instr->jmp.offset = (unsigned int)_replacement - (unsigned int)_original - 5; printf("original: %p, %p\n", _original, instr->jmp.offset); } } std::cout << __FILE__ << __LINE__ << std::endl; }
main(int argc, char **argv) // ////////////////////////////////////////////////////////////// { Options options; SoSeparator *root; Display *display; Window window; float asisTime, ptsTime, invisTime, freezeTime, noMatTime, noTexTime, noLitTime, noXformTime, noClearTime, oneTexTime; // Init Inventor SoInteraction::init(); // Parse arguments if (! parseArgs(argc, argv, options)) { printUsage(argv[0]); return 1; } // Open scene graphs SoInput sceneInput; if (! sceneInput.openFile(options.inputFileName)) { fprintf(stderr, "Cannot open %s\n", options.inputFileName); return 1; } SbViewportRegion vpr(options.windowX, options.windowY); root = setUpGraph(vpr, &sceneInput, options); // Create and initialize window openWindow(display, window, options.windowX, options.windowY, argv[0]); // Timing tests printf("\t\t\tseconds/frame\tframes/second\n"); // as is rendering asisTime = timeRendering(options, vpr, root); printf("As-Is rendering:\t%10.3f\t%10.2f\n", asisTime, 1.0/asisTime); // time for rendering without clear options.noClear = TRUE; noClearTime = timeRendering(options, vpr, root); options.noClear = FALSE; printf("No Clear:\t\t%10.3f\t%10.2f\n", noClearTime, 1.0/noClearTime); // time for rendering without materials options.noMaterials = TRUE; noMatTime = timeRendering(options, vpr, root); options.noMaterials = FALSE; printf("No Materials:\t\t%10.3f\t%10.2f\n", noMatTime, 1.0/noMatTime); // time for rendering without xforms options.noXforms = TRUE; noXformTime = timeRendering(options, vpr, root); options.noXforms = FALSE; printf("No Transforms:\t\t%10.3f\t%10.2f\n", noXformTime, 1.0/noXformTime); if (options.hasTextures) { // do tests only if scene has textures // time for rendering without any textures options.noTextures = TRUE; noTexTime = timeRendering(options, vpr, root); options.noTextures = FALSE; printf("No Textures:\t\t%10.3f\t%10.2f\n", noTexTime, 1.0/noTexTime); // time for rendering without only one texture options.oneTexture = TRUE; oneTexTime = timeRendering(options, vpr, root); options.oneTexture = FALSE; printf("One Texture:\t\t%10.3f\t%10.2f\n", oneTexTime, 1.0/oneTexTime); } else noTexTime = oneTexTime = asisTime; // time for rendering without fill options.noFill = TRUE; ptsTime = timeRendering(options, vpr, root); options.noFill = FALSE; printf("No Fills:\t\t%10.3f\t%10.2f\n", ptsTime, 1.0/ptsTime); if (options.hasLights) { // do test only if scene has lights // time for rendering with lights turned off options.noLights = TRUE; noLitTime = timeRendering(options, vpr, root); options.noLights = FALSE; printf("No Lights:\t\t%10.3f\t%10.2f\n", noLitTime, 1.0/noLitTime); } else noLitTime = asisTime; printf("\n"); // time for rendering without vertex xforms options.noVtxXforms = TRUE; invisTime = timeRendering(options, vpr, root); options.noVtxXforms = FALSE; printf("Time taken by vertex transformations:\t%10.3f seconds/frame\n", ptsTime-invisTime); // time for rendering with scene graph frozen options.freeze = TRUE; freezeTime = timeRendering(options, vpr, root); options.freeze = FALSE; printf("Time taken to traverse scene graph:\t%10.3f seconds/frame\n\n", asisTime-freezeTime); // kill window XEvent event; XUnmapWindow(display, window); XIfEvent(display, &event, waitForNotify, (char *) window); // draw timing bars if (options.showBars) drawBar(asisTime, noClearTime, noMatTime, noXformTime, noTexTime, oneTexTime, noLitTime, ptsTime, invisTime, freezeTime); return 0; }