void ExampleInit() { g_UseSoundPool = s3eSoundPoolAvailable() == S3E_TRUE; // Read in sound data // s3eSoundSetInt(S3E_SOUND_DEFAULT_FREQ, 8000); DIR* d = opendir("."); int count = 0; struct dirent* ent; while ((ent = readdir(d))) { int len = strlen(ent->d_name); if (len < 4 || stricmp(ent->d_name+len-4, ".wav")) continue; Load(count, ent->d_name); s3eDebugTracePrintf("loaded sound %d (%d)", g_Samples[count], g_SampleDataLen[count]); ent->d_name[len-4] = '\0'; g_Buttons[count] = strdup(ent->d_name); AddButton(g_Buttons[count], 20, 20 + 70 * count, 300, 50, (s3eKey)(s3eKey1 + count)); if (++count == MAX_SAMPLES) break; } RegisterCallbacks(); }
void VScriptComponent::SetScriptInstance(VScriptInstance* pInstance) { if (m_spInstance != NULL) { DeregisterCallbacks(); // Dispose our instance. Necessary to remove the assignment to its streaming zone (see ticket #25491) // (Note: script instances are unique per component, and thus not shared). m_spInstance->DisposeObject(); } m_spInstance = pInstance; m_iFunctions = 0; if (pInstance != NULL) { pInstance->SetParentComponent(this); m_iFunctions = CheckAvailableFunctions(pInstance); RegisterCallbacks(); TriggerOnExpose(); //on a new script instance, call the OnCreate function of the script if (m_iFunctions & VSCRIPT_FUNC_ONCREATE) m_spInstance->ExecuteFunctionArg("OnCreate", "*"); } }
void AmxHooks::Initialize(void **ppPluginData) { pAMXFunctions = ppPluginData[PLUGIN_DATA_AMX_EXPORTS]; void **amxExports = static_cast<void**>(pAMXFunctions); amx_RegisterHook_.Install( amxExports[PLUGIN_AMX_EXPORT_Register], (void*)amx_Register); amx_FindPublicHook_.Install( amxExports[PLUGIN_AMX_EXPORT_FindPublic], (void*)amx_FindPublic); amx_ExecHook_.Install( amxExports[PLUGIN_AMX_EXPORT_Exec], (void*)amx_Exec); amx_CallbackHook_.Install( amxExports[PLUGIN_AMX_EXPORT_Callback], (void*)amx_Callback); amx_PushHook_.Install( amxExports[PLUGIN_AMX_EXPORT_Push], (void*)amx_Push); amx_PushStringHook_.Install( amxExports[PLUGIN_AMX_EXPORT_PushString], (void*)amx_PushString); RegisterCallbacks(); }
void VDebugProfiling::RebuildMenu() { const char* szGroupName = "Debug Profiling"; DeRegisterCallbacks(); VAppMenu* pMainMenu = GetParent()->GetAppModule<VAppMenu>(); if (pMainMenu == NULL) return; pMainMenu->RemoveGroup(szGroupName); VProfilingNode* pRoot = Vision::Profiling.GetProfilingRootNode(); if (pRoot) { VAppMenuItems items; const unsigned int iCount = Vision::Profiling.GetNumOfGroups(); for (unsigned int i=0; i<iCount; ++i) { VProfilingNode* pNode = pRoot->Children().GetAt(i); if (pNode) items.Add(VAppMenuItem(pNode->GetName(), i, i, true)); } items.Add(VAppMenuItem("Reset Max Values", s_iResetMaxValuesAction, iCount, false)); m_callbacks = pMainMenu->RegisterGroup(szGroupName, items, NULL, VAPP_DEFAULT_SORTING_1, false); RegisterCallbacks(); } }
static void Run(intf_thread_t *intf) { intf_sys_t *sys = intf->p_sys; int fd; int canc = vlc_savecancel(); RegisterCallbacks(intf); while(1) { msg_Info(intf, "Creating IRC connection..."); fd = net_ConnectTCP(VLC_OBJECT(intf), sys->server, 6667); if(fd == -1) { msg_Err(intf, "Error connecting to server"); return; } msg_Info(intf, "Connected to server"); /* initialize context */ sys->fd = fd; sys->line_loc = 0; SendBufferInit(intf); SendBufferAppend(intf, "NICK "); SendBufferAppend(intf, sys->nick); SendBufferAppend(intf, "\r\n"); SendBufferAppend(intf, "USER "); SendBufferAppend(intf, sys->nick); SendBufferAppend(intf, " 8 * vlc\r\n"); sys->playlist = pl_Get(intf); #ifdef STOP_HACK playlist_Pause(sys->playlist); input_thread_t * input = playlist_CurrentInput(sys->playlist); var_SetFloat(input, "position", 0.0); #endif EventLoop(fd, intf); free(sys->send_buffer->buffer); sleep(30); } free(sys); vlc_restorecancel(canc); }
// Initialize. bool UAVOdometry::Initialize(const ros::NodeHandle& n) { name_ = ros::names::append(n.getNamespace(), "uav_odometry"); if (!LoadParameters(n)) { ROS_ERROR("%s: Failed to load parameters.", name_.c_str()); return false; } if (!RegisterCallbacks(n)) { ROS_ERROR("%s: Failed to register callbacks.", name_.c_str()); return false; } return true; }
void VHelp::Init() { Vision::Callbacks.OnUpdateSceneFinished += this; VAppMenu* pMainMenu = GetParent()->GetAppModule<VAppMenu>(); if (pMainMenu == NULL) { SetEnabled(false); m_bToggleEnabled = true; return; } m_callbacks.Append(pMainMenu->RegisterItem(VAppMenuItem("Help", 0, VAPP_DEFAULT_SORTING_3, true))); RegisterCallbacks(); SetEnabled(false); }
// Initialize. bool UAVLocalization::Initialize(const ros::NodeHandle& n, UAVMapper *mapper, UAVOdometry *odometry) { name_ = ros::names::append(n.getNamespace(), "uav_localization"); odometry_ = odometry; mapper_ = mapper; if (!LoadParameters(n)) { ROS_ERROR("%s: Failed to load parameters.", name_.c_str()); return false; } if (!RegisterCallbacks(n)) { ROS_ERROR("%s: Failed to register callbacks.", name_.c_str()); return false; } initialized_ = true; return true; }
bool OSVRInterface::Init(OSVR_ClientContext OSVRClientContext, const FName& InterfaceName) { bool Result(true); #if OSVR_ENABLED OSVR_ReturnCode ReturnCode = osvrClientGetInterface(OSVRClientContext, InterfaceName.GetPlainANSIString(), &OSVRClientInterface); Result = ReturnCode == OSVR_RETURN_SUCCESS; this->OSVRClientContext = OSVRClientContext; RefreshCapabilities(); RegisterCallbacks(); #endif // OSVR_ENABLED Name = InterfaceName; return Result; }
void VDebugShadingModes::Init() { Vision::Callbacks.OnAfterSceneLoaded += this; Vision::Callbacks.OnBeforeSceneUnloaded += this; m_debugShadingEffects.Clear(); m_spDebugShadingShaderLib = NULL; m_spDebugShadingShaderLib = Vision::Shaders.LoadShaderLibrary("Shaders\\DebugShadingEffects.ShaderLib"); if ((m_spDebugShadingShaderLib == NULL) || (m_spDebugShadingShaderLib && !m_spDebugShadingShaderLib->IsLoaded())) return; VAppMenu* pMainMenu = GetParent()->GetAppModule<VAppMenu>(); if (pMainMenu == NULL) return; VAppMenuItems items; VisShaderFXLibManager_cl &manager(Vision::Shaders.GetShaderFXLibManager()); // Enumerate all available effects and add them to a collection for later usage for (int i=0;i<m_spDebugShadingShaderLib->m_Effects.Count();i++) { VCompiledEffect *pFX = m_spDebugShadingShaderLib->m_Effects.GetAt(i)->CompileEffect(NULL, manager.m_ShaderInstances); // Skip the "NotAvailable" shader, because it is only used for fallback reasons in vForge if ((pFX==NULL) || (pFX && VStringHelper::SafeCompare(pFX->GetSourceEffect()->GetName(), "NotAvailable") == 0)) continue; // Use the effect's same as a description pFX->SetUserData((void *)pFX->GetSourceEffect()->GetName()); int iIndex = m_debugShadingEffects.Add(pFX); items.Add(VAppMenuItem(pFX->GetSourceEffect()->GetName(), iIndex, 0, true)); } m_callbacks = pMainMenu->RegisterGroup("Debug Shading", items, NULL, VAPP_DEFAULT_SORTING_2, false); RegisterCallbacks(); }
bool ShaderEditorHandler::Init() { factorylist_t factories; FactoryList_Retrieve( factories ); #ifdef SOURCE_2006 ConVar *pCVarDev = cvar->FindVar( "developer" ); bool bShowPrimDebug = pCVarDev != NULL && pCVarDev->GetInt() != 0; #else ConVarRef devEnabled( "developer", true ); bool bShowPrimDebug = devEnabled.GetInt() != 0; #endif bool bCreateEditor = ( CommandLine() != NULL ) && ( CommandLine()->FindParm( "-shaderedit" ) != 0 ); SEDIT_SKYMASK_MODE iEnableSkymask = SKYMASK_OFF; #ifdef SHADEREDITOR_FORCE_ENABLED bCreateEditor = true; iEnableSkymask = SKYMASK_QUARTER; #endif char modulePath[MAX_PATH*4]; #ifdef SWARM_DLL Q_snprintf( modulePath, sizeof( modulePath ), "%s/bin/shadereditor_swarm.dll\0", engine->GetGameDirectory() ); #elif SOURCE_2006 Q_snprintf( modulePath, sizeof( modulePath ), "%s/bin/shadereditor_2006.dll\0", engine->GetGameDirectory() ); #elif SOURCE_2013 Q_snprintf( modulePath, sizeof( modulePath ), "%s/bin/shadereditor_2013.dll\0", engine->GetGameDirectory() ); #else Q_snprintf( modulePath, sizeof( modulePath ), "%s/bin/shadereditor_2007.dll\0", engine->GetGameDirectory() ); #endif shaderEditorModule = Sys_LoadModule( modulePath ); if ( shaderEditorModule ) { CreateInterfaceFn shaderEditorDLLFactory = Sys_GetFactory( shaderEditorModule ); shaderEdit = shaderEditorDLLFactory ? ((IVShaderEditor *) shaderEditorDLLFactory( SHADEREDIT_INTERFACE_VERSION, NULL )) : NULL; if ( !shaderEdit ) { Warning( "Unable to pull IVShaderEditor interface.\n" ); } else if ( !shaderEdit->Init( factories.appSystemFactory, gpGlobals, sEditMRender, bCreateEditor, bShowPrimDebug, iEnableSkymask ) ) { Warning( "Cannot initialize IVShaderEditor.\n" ); shaderEdit = NULL; } } else { Warning( "Cannot load shadereditor.dll from %s!\n", modulePath ); } m_bReady = shaderEdit != NULL; RegisterCallbacks(); RegisterViewRenderCallbacks(); if ( IsReady() ) { shaderEdit->PrecacheData(); } return true; }
int rmdRescue(const char *path){ int i=0, offset_x, offset_y; unsigned short width, height; ProgData pdata; EncData enc_data; CacheData cache_data; SetupDefaultArgs(&pdata.args); pdata.enc_data=&enc_data; pdata.cache_data=&cache_data; //projname cache_data.projname=malloc(strlen(path)+2); strcpy(cache_data.projname,path); strcat(cache_data.projname,"/");//having two of these doesn't hurt... //image data cache_data.imgdata=malloc(strlen(cache_data.projname)+11); strcpy(cache_data.imgdata,cache_data.projname); strcat(cache_data.imgdata,"img.out"); //audio data cache_data.audiodata=malloc(strlen(cache_data.projname)+10); strcpy(cache_data.audiodata,cache_data.projname); strcat(cache_data.audiodata,"audio.pcm"); //specsfile cache_data.specsfile=malloc(strlen(cache_data.projname)+10); strcpy(cache_data.specsfile,cache_data.projname); strcat(cache_data.specsfile,"specs.txt"); if(ReadSpecsFile(&pdata)) return 1; width=((pdata.brwin.rrect.width + 15) >>4)<<4; height=((pdata.brwin.rrect.height + 15) >>4)<<4; offset_x=((width-pdata.brwin.rrect.width)/2)&~1; offset_y=((height-pdata.brwin.rrect.height)/2)&~1; enc_data.yuv.y=(unsigned char *)malloc(height*width); enc_data.yuv.u=(unsigned char *)malloc(height*width/4); enc_data.yuv.v=(unsigned char *)malloc(height*width/4); enc_data.yuv.y_width=width; enc_data.yuv.y_height=height; enc_data.yuv.y_stride=width; enc_data.yuv.uv_width=width/2; enc_data.yuv.uv_height=height/2; enc_data.yuv.uv_stride=width/2; enc_data.x_offset=offset_x; enc_data.y_offset=offset_y; for(i=0;i<(enc_data.yuv.y_width*enc_data.yuv.y_height);i++) enc_data.yuv.y[i]=0; for(i=0;i<(enc_data.yuv.uv_width*enc_data.yuv.uv_height);i++){ enc_data.yuv.v[i]=enc_data.yuv.u[i]=127; } yblocks=malloc(sizeof(u_int32_t)*(enc_data.yuv.y_width/Y_UNIT_WIDTH)* (enc_data.yuv.y_height/Y_UNIT_WIDTH)); ublocks=malloc(sizeof(u_int32_t)*(enc_data.yuv.y_width/Y_UNIT_WIDTH)* (enc_data.yuv.y_height/Y_UNIT_WIDTH)); vblocks=malloc(sizeof(u_int32_t)*(enc_data.yuv.y_width/Y_UNIT_WIDTH)* (enc_data.yuv.y_height/Y_UNIT_WIDTH)); pdata.frametime=(1000000)/pdata.args.fps; pthread_mutex_init(&pdata.theora_lib_mutex,NULL); pthread_mutex_init(&pdata.vorbis_lib_mutex,NULL); pthread_mutex_init(&pdata.libogg_mutex,NULL); pthread_cond_init(&pdata.theora_lib_clean,NULL); pthread_cond_init(&pdata.vorbis_lib_clean,NULL); pdata.th_encoding_clean=pdata.v_encoding_clean=1; pdata.avd=0; pdata.sound_buffer=NULL; pdata.running = TRUE; pdata.aborted = FALSE; RegisterCallbacks(&pdata); fprintf(stderr,"Restoring %s!!!\n",path); EncodeCache(&pdata); fprintf(stderr,"Done!!!\n"); fprintf(stderr,"Goodbye!\n"); CleanUp(); return 0; }
void VCameraHandling::BuildCameraList() { VAppMenu* pMainMenu = GetParent()->GetAppModule<VAppMenu>(); if (pMainMenu == NULL) return; int iActionIndex = 0; VAppMenuItems menuItems; menuItems.Add(VAppMenuItem("<Switch to Free Camera>", iActionIndex++, 0, false)); #if defined(WIN32) && !defined(_VISION_WINRT) // Add option to disable WASD controls. m_iWASDActionIndex = iActionIndex++; menuItems.Add(VAppMenuItem("<Toggle Free Camera WASD Controls>", m_iWASDActionIndex, 1, true, m_bWASDEnabled)); #endif // Find camera objects in the scene. // Only store element manager indices in order to be able to detect removed objects. unsigned int uiNumOrbitCameras = 0; unsigned int uiNumCameraPositions = 0; unsigned int uiNumPathCameras = 0; const unsigned int uiNumEntities = VisBaseEntity_cl::ElementManagerGetSize(); for (unsigned int uiElementIndex = 0; uiElementIndex < uiNumEntities; uiElementIndex++) { VisBaseEntity_cl* pEntity = VisBaseEntity_cl::ElementManagerGet(uiElementIndex); if (pEntity == NULL) continue; // Try to convert the entity to all of the supported camera types. VOrbitCamera* pOrbitCamera = pEntity->Components().GetComponentOfBaseType<VOrbitCamera>(); CameraPositionEntity* pCameraPosition = vdynamic_cast<CameraPositionEntity*>(pEntity); PathCameraEntity* pPathCamera = vdynamic_cast<PathCameraEntity*>(pEntity); // Menu name data const char* szKey = ""; const char* szCameraType = ""; unsigned int uiSortingKey = 0; unsigned int uiCameraIndex = 0; if (pOrbitCamera != NULL) { // If the owner entity's key is not set, use the model's file name. const char* szKey = pEntity->GetObjectKey(); if (VStringUtil::IsEmpty(szKey)) szKey = (pEntity->GetMesh() ? pEntity->GetMesh()->GetFilename() : ""); szCameraType = "OrbitCamera"; uiSortingKey = 2; uiCameraIndex = uiNumOrbitCameras++; } else if (pCameraPosition != NULL) { szKey = pEntity->GetObjectKey(); szCameraType = "CameraPosition"; uiSortingKey = 3; uiCameraIndex = uiNumCameraPositions++; } else if (pPathCamera != NULL) { szKey = pEntity->GetObjectKey(); szCameraType = "PathCamera"; uiSortingKey = 4; uiCameraIndex = uiNumPathCameras++; } else { // If we haven't found a free camera entity yet, try to store this one. if (m_spFreeCamera == NULL) m_spFreeCamera = vdynamic_cast<VFreeCamera*>(pEntity); // No camera found. continue; } // Generate menu name. VString sMenuName; if (VStringUtil::IsEmpty(szKey)) sMenuName.Format("%s%02d", szCameraType, uiCameraIndex + 1); else sMenuName.Format("%s%02d (%s)", szCameraType, uiCameraIndex + 1, szKey); menuItems.Add(VAppMenuItem(sMenuName, iActionIndex, uiSortingKey, false)); m_actionMap.SetAt(iActionIndex++, EntityAccessor(pEntity, sMenuName)); } m_callbacks.Append(pMainMenu->RegisterGroup(m_sMenuGroupName, menuItems, NULL, VAPP_DEFAULT_SORTING_2 + 1)); RegisterCallbacks(); }
void VDebugOptions::Init() { Vision::Callbacks.OnUpdateSceneBegin += this; Vision::Callbacks.OnBeforeSwapBuffers += this; Vision::Callbacks.OnRenderHook += this; // Setup graph for displaying un-/filtered time steps VGraphProps timeStepGraphProps; timeStepGraphProps.vPosition.set(-0.85f, -0.3f); timeStepGraphProps.fWidth = 0.25f; timeStepGraphProps.fHeight = 0.25f; timeStepGraphProps.iResolution = 64; timeStepGraphProps.bRangeAdaptation = true; m_pTimeStepGraph = new VGraphObject(timeStepGraphProps); m_pTimeStepGraph->AddCurve("Unfiltered Time Step", VColorRef(0, 255, 0), new VUnfilteredTimeDiffUpdater); m_pTimeStepGraph->AddCurve("Filtered Time Step", VColorRef(255, 0, 0), new VFilteredTimeDiffUpdater); m_pTimeStepGraph->Init(); m_pTimeStepGraph->SetVisible(false); #if defined(WIN32) GetParent()->GetInputMap()->MapTrigger(TOGGLE_FPS, VInputManager::GetKeyboard(), CT_KB_F2, VInputOptions::Once(ONCE_ON_RELEASE)); GetParent()->GetInputMap()->MapTrigger(TOGGLE_WIREFRAME, VInputManager::GetKeyboard(), CT_KB_F3, VInputOptions::Once(ONCE_ON_RELEASE)); #endif VAppMenu* pMainMenu = GetParent()->GetAppModule<VAppMenu>(); if (pMainMenu == NULL) return; // General Debug Options // Note: OPTION_FPS, OPTION_WIREFRAME, and OPTION_RELOAD_RESOURCES are added directly to the menu's root, the other options // are added to the menu's root as a group called 'Debug Options' m_callbacks.Append(pMainMenu->RegisterItem(VAppMenuItem("Toggle FPS Display", OPTION_FPS, VAPP_DEFAULT_SORTING_0, true))); // wireframe rendering is not supported on GLES2 #if !defined(_VR_GLES2) m_callbacks.Append(pMainMenu->RegisterItem(VAppMenuItem("Wireframe", OPTION_WIREFRAME, VAPP_DEFAULT_SORTING_0 + 1, true))); #endif m_callbacks.Append(pMainMenu->RegisterItem(VAppMenuItem("Reload Modified Resources", OPTION_RELOAD_RESOURCES, VAPP_DEFAULT_SORTING_0 + 2, false))); VAppMenuItems items; items.Add(VAppMenuItem("Show Time Step Graph", OPTION_TIME_STEP_GRAPH, 0, true)); items.Add(VAppMenuItem("Save Screenshot", OPTION_SAVE_SCREENSHOT, 0, false)); #if defined(SUPPORTS_MULTITOUCH) items.Add(VAppMenuItem("Touch Area Debug Rendering", OPTION_MULTITOUCH, 0, true)); #endif m_callbacks.Append(pMainMenu->RegisterGroup("Debug Options", items, NULL, VAPP_DEFAULT_SORTING_0 + 3, true)); RegisterCallbacks(); // Debug Render Flags items.RemoveAll(); items.Add(VAppMenuItem("Display Object Triangle Count", DEBUGRENDERFLAG_OBJECT_TRIANGLECOUNT, 0, true)); items.Add(VAppMenuItem("Display Object Visibility BoundingBox", DEBUGRENDERFLAG_OBJECT_VISBBOX, 0, true)); items.Add(VAppMenuItem("Display Object vis. Area Assignment", DEBUGRENDERFLAG_OBJECT_VISIBILITYZONES, 0, true)); items.Add(VAppMenuItem("Display Light Influence BoundingBox", DEBUGRENDERFLAG_LIGHT_INFLUENCEBOX, 0, true)); items.Add(VAppMenuItem("Display Trace Lines", DEBUGRENDERFLAG_TRACELINES, 0, true)); items.Add(VAppMenuItem("Display Visibility Objects", DEBUGRENDERFLAG_VISIBILITYOBJECTS, 0, true)); items.Add(VAppMenuItem("Display Portals", DEBUGRENDERFLAG_PORTALS, 0, true)); items.Add(VAppMenuItem("Display Visibility Zones", DEBUGRENDERFLAG_VISIBILITYZONES, 0, true)); items.Add(VAppMenuItem((Vision::GetScriptManager() != NULL) ? "Scripting Statistics" : "Scripting Statistics (no script man.)", DEBUGRENDERFLAG_SCRIPTSTATISTICS, 0, true)); items.Add(VAppMenuItem("Display Object Render Order", DEBUGRENDERFLAG_OBJECTRENDERORDER, 0, true)); items.Add(VAppMenuItem("Display Thread Workload", DEBUGRENDERFLAG_THREADWORKLOAD, 0, true)); items.Add(VAppMenuItem("Display Streaming Zones", DEBUGRENDERFLAG_ZONES, 0, true)); items.Add(VAppMenuItem("Display Resource Stats", DEBUGRENDERFLAG_RESOURCE_STATISTICS, 0, true)); items.Add(VAppMenuItem("Display Memory Stats", DEBUGRENDERFLAG_MEMORY_STATISTICS, 0, true)); m_debugInfos = pMainMenu->RegisterGroup("Debug Infos", items, "Debug Options"); RegisterCallbacks(m_debugInfos); }