/////////////////////////////////////////////////////////////////////// // Function : dsoLoadCallback // Description : This function will be called for each module // Return Value : // Comments : static int dsoLoadCallback(const char *file,void *ud) { void *module = osLoadModule(file); if (module != NULL) { int i; void **userData = (void **) ud; char *name = (char *) userData[0]; char *prototype = (char *) userData[1]; SHADEOP_SPEC *shadeops; { char tmp[OS_MAX_PATH_LENGTH]; sprintf(tmp,"%s_shadeops",name); shadeops = (SHADEOP_SPEC *) osResolve(module,tmp); } if (shadeops != NULL) { for (i=0;; i++) { char *dsoName,*dsoPrototype; if (strcmp(shadeops[i].definition,"") == 0) break; if (dsoParse(shadeops[i].definition,dsoName,dsoPrototype) == TRUE) { if (strcmp(dsoPrototype,prototype) == 0) { dsoInitFunction *init = (dsoInitFunction *) userData[2]; dsoExecFunction *exec = (dsoExecFunction *) userData[3]; dsoCleanupFunction *cleanup = (dsoCleanupFunction *) userData[4]; // Bingo init[0] = (dsoInitFunction) osResolve(module,shadeops[i].init); exec[0] = (dsoExecFunction) osResolve(module,dsoName); cleanup[0] = (dsoCleanupFunction) osResolve(module,shadeops[i].cleanup); if (exec != NULL) { free(dsoName); free(dsoPrototype); // We have found the DSO return FALSE; } } free(dsoName); free(dsoPrototype); } } } osUnloadModule(module); } else { error(CODE_SYSTEM,"Failed to load DSO \"%s\": %s\n",file,osModuleError()); } // Continue iterating return TRUE; }
/////////////////////////////////////////////////////////////////////// // Class : CShow // Method : CShow // Description : /// \brief Ctor // Return Value : - // Comments : CShow::CShow(int thread) : CShadingContext(thread) { if (thread == 0) { char moduleFile[OS_MAX_PATH_LENGTH]; // First, try to load the dynamic library CView::handle = NULL; if(CRenderer::locateFileEx(moduleFile,"gui",osModuleExtension,CRenderer::modulePath)) { CView::handle = osLoadModule(moduleFile); } if (CView::handle != NULL) { // Is this the library we were expecting ? TGlVisualizeFunction visualize = (TGlVisualizeFunction) osResolve(CView::handle,"pglVisualize"); CView *view = NULL; if (visualize != NULL) { // Try to load the file const char *fileName = CRenderer::hider + 5; FILE *in = fopen(fileName,"rb"); CView::drawTriangles = (TGlTrianglesFunction) osResolve(CView::handle,"pglTriangles"); CView::drawLines = (TGlLinesFunction) osResolve(CView::handle,"pglLines"); CView::drawPoints = (TGlPointsFunction) osResolve(CView::handle,"pglPoints"); CView::drawDisks = (TGlDisksFunction) osResolve(CView::handle,"pglDisks"); CView::drawFile = (TGlFileFunction) osResolve(CView::handle,"pglFile"); assert(CView::drawTriangles != NULL); assert(CView::drawPoints != NULL); if (in != NULL) { unsigned int magic = 0; int version[4],i; char *t; fread(&magic,sizeof(int),1,in); if (magic == magicNumber) { fread(version,sizeof(int),4,in); if (!((version[0] == VERSION_RELEASE) || (version[1] == VERSION_BETA))) { error(CODE_VERSION,"File \"%s\" is from an incompatible version\n",fileName); } else { if (version[3] != sizeof(int*) ) { error(CODE_VERSION,"File \"%s\" is binary an incompatible (generated on a machine with different word size)\n",fileName); } else { fread(&i,sizeof(int),1,in); t = (char *) alloca((i+1)*sizeof(char)); fread(t,sizeof(char),i+1,in); info(CODE_PRINTF,"File: %s\n",fileName); info(CODE_PRINTF,"Version: %d.%d.%d\n",version[0],version[1],version[2]); info(CODE_PRINTF,"Type: %s\n",t); fclose(in); matrix from,to; identitym(from); identitym(to); if (strcmp(t,filePhotonMap) == 0) { view = CRenderer::getPhotonMap(fileName); } else if (strcmp(t,fileIrradianceCache) == 0) { view = CRenderer::getCache(fileName,"R",from,to); } else if (strcmp(t,fileGatherCache) == 0) { view = CRenderer::getCache(fileName,"R",from,to); } else if (strcmp(t,filePointCloud) == 0) { view = CRenderer::getTexture3d(fileName,FALSE,NULL,from,to); } else if (strcmp(t,fileBrickMap) == 0) { view = CRenderer::getTexture3d(fileName,FALSE,NULL,from,to); } // Create / display the window if (view != NULL) visualize(view); } } } else { fseek(in,0,SEEK_SET); view = new CDebugView(in,fileName); visualize(view); delete view; } } } } else { error(CODE_SYSTEM,"Opengl wrapper not found..."); } } }
// --------------------------------------------------------------------------- // Name: gsLoadSystemsOpenGLModule // Description: Loads the system's OpenGL module into the calling process address space. // Return Val: osModuleHandle - Will get a handle to the systems OpenGL module. // Author: Yaki Tebeka // Date: 5/7/2003 // --------------------------------------------------------------------------- osModuleHandle gsLoadSystemsOpenGLModule() { osModuleHandle retVal = OS_NO_MODULE_HANDLE; // Will get the system's OpenGL module path: gtVector<osFilePath> systemOGLModulePath; osGetSystemOpenGLModulePath(systemOGLModulePath); gtString moduleLoadError = L"System OpenGL module not found."; bool rc = false; int numberOfGLPaths = (int)systemOGLModulePath.size(); GT_ASSERT(numberOfGLPaths > 0); for (int i = 0; (i < numberOfGLPaths) && (!rc); i++) { // Output debug log printout: const osFilePath& currentModulePath = systemOGLModulePath[i]; const gtString& currentModulePathStr = currentModulePath.asString(); gtString dbgLogMsg = GS_STR_DebugLog_loadingSystemOGLServer; dbgLogMsg.append(currentModulePathStr); OS_OUTPUT_DEBUG_LOG(dbgLogMsg.asCharArray(), OS_DEBUG_LOG_DEBUG); // Load the system OpenGL module: if (currentModulePath.exists()) { // Some of the paths may fail: gtString currentModuleError; rc = osLoadModule(currentModulePath, retVal, ¤tModuleError, false); if (!rc) { // Log the error for each attempted path: moduleLoadError.append('\n').append(currentModulePathStr).append(L":\n ").append(currentModuleError); } else { // Output debug log printout of the module that was successfully loaded: dbgLogMsg = GS_STR_DebugLog_systemOGLServerLoadedOk; dbgLogMsg.append(currentModulePathStr); OS_OUTPUT_DEBUG_LOG(dbgLogMsg.asCharArray(), OS_DEBUG_LOG_INFO); } } } // If we failed to load the system OpenGL module: if (!rc) { // Trigger an assertion failure: GT_ASSERT_EX(false, GS_STR_DebugLog_systemOGLServerLoadFailed); GT_ASSERT_EX(false, moduleLoadError.asCharArray()); suTechnologyMonitorsManager::reportFailedSystemModuleLoad(moduleLoadError); } else { // Log the system's OpenGL module handle: gsSetSystemsOpenGLModuleHandle(retVal); } return retVal; }