void run() { if (p_updates != param_updates) { p_updates = param_updates; if (directory_path->get() != "") { if (old_path != directory_path->get()) { old_path = directory_path->get(); std::list<vsx_string> files; //vsxfst tt; vsx_string engine_resources_base_path = engine->filesystem->get_base_path(); get_files_recursive(engine_resources_base_path + DIRECTORY_SEPARATOR + directory_path->get(), &files); files_list.reset_used(0); for (std::list<vsx_string>::iterator it = files.begin(); it != files.end(); ++it) { if ((*it).find(".svn/") == -1) { files_list.push_back( (*it).substr(engine_resources_base_path.size()+1)); } } } } if (files_list.size()) { filename_count->set((float)files_list.size()); unsigned long fid = (unsigned long)floor(file_id->get()); if (fid >= files_list.size()) fid = files_list.size()-1; filename_result->set(files_list[fid]); } } }
void vsx_statelist::init(vsx_string base_path,vsx_string init_sound_type) { no_fbo_ati = false; if (vsx_string((char*)glGetString(GL_VENDOR)) == vsx_string("ATI Technologies Inc.")) no_fbo_ati = true; randomizer = true; srand ( time(NULL)+rand() ); randomizer_time = (float)(rand()%1000)*0.001f*15.0f+10.0f; transition_time = 2.0f; message_time = -1.0f; fx_alpha = 0.0f; spd_alpha = 0.0f; render_first = true; transitioning = false; first = 2; show_progress_bar = false; vxe = 0; sound_type = init_sound_type; cmd_out = 0; own_path = base_path; #ifdef VSXU_DEBUG printf("own path: %s\n", own_path.c_str() ); #endif #if PLATFORM == PLATFORM_WINDOWS if (own_path.size()) if (own_path[own_path.size()-1] != '\\') own_path.push_back('\\'); #else if (own_path.size()) if (own_path[own_path.size()-1] != '/') own_path.push_back('/'); #endif visual_path = "visuals_player"; get_files_recursive(own_path+visual_path, &state_file_list,"",""); #ifdef VSXU_DEBUG printf("getting files recursive: %s\n", (own_path+visual_path).c_str() ); #endif for (std::list<vsx_string>::iterator it = state_file_list.begin(); it != state_file_list.end(); ++it) { state_info state; state.state_name = *it; state.state_name_suffix = state.state_name.substr(own_path.size(),state.state_name.size() - own_path.size() ); #ifdef VSXU_DEBUG printf("adding state %s\n",(*it).c_str()); #endif state.fx_level = 1.0f; state.engine = 0; statelist.push_back(state); } load_fx_levels_from_user(); }
Certificate_Store_In_Memory::Certificate_Store_In_Memory(const std::string& dir) { if(dir.empty()) return; std::vector<std::string> maybe_certs = get_files_recursive(dir); for(auto&& cert_file : maybe_certs) { try { m_certs.push_back(std::make_shared<X509_Certificate>(cert_file)); } catch(std::exception&) { } } }
void vsx_statelist::add_visual_path(vsx_string new_visual_path) { get_files_recursive(new_visual_path, &state_file_list,"",""); #ifdef VSXU_DEBUG printf("getting files recursive: %s\n", (new_visual_path).c_str() ); #endif for (std::list<vsx_string>::iterator it = state_file_list.begin(); it != state_file_list.end(); ++it) { state_info state; state.state_name = *it; state.state_name_suffix = state.state_name.substr(new_visual_path.size(),state.state_name.size() - new_visual_path.size() ); #ifdef VSXU_DEBUG printf("adding state %s\n",(*it).c_str()); #endif statelist.push_back(state); } }
void vsx_module_list::init(vsx_string args) { // woops, looks like we already built the list if (module_list.size()) return; // statistics counter - how many modules are loaded in total? unsigned long total_num_modules = 0; // set up engine environment for later use (directories in which modules can look for config) vsx_engine_environment engine_environment; engine_environment.engine_parameter[0] = PLATFORM_SHARED_FILES+"plugin-config/"; // recursively find the plugin so's from the plugins directory // store it in: mfiles std::list<vsx_string> mfiles; get_files_recursive ( vsx_string(CMAKE_INSTALL_PREFIX) + vsx_get_directory_separator() + vsx_string(VSXU_INSTALL_LIB_DIR) + "/vsxu/plugins" , &mfiles , ".so" , "" ); //------------------------------------------------------------------------- //------------------------------------------------------------------------- // Iterate through all the filenames, treat them as plugins with dlopen // and probe them to see if they are vsxu modules. for (std::list<vsx_string>::iterator it = mfiles.begin(); it != mfiles.end(); ++it) { vsx_string dynamic_object_file_name = (*it); //vsx_avector<vsx_string> parts; vsx_dynamic_object_handle plugin_handle; //vsx_string deli = vsx_get_directory_separator(); //explode((*it),deli,parts); // load the plugin plugin_handle = vsx_dlopen::open( dynamic_object_file_name.c_str() ); // if loading fails, print debug output if (!plugin_handle) { printf( "vsx_module_list init: Error: trying to load the plugin \"%s\"\n" " Cause: dlopen returned error: %s\n", dynamic_object_file_name.c_str(), vsx_dlopen::error() ); continue; // try to load the next plugin } // add this module handle to our list of module handles plugin_handles.push_back(plugin_handle); //------------------------------------------------------------------------- // look for the REQUIRED constructor (factory) method if (vsx_dlopen::sym(plugin_handle, "create_module") == 0) { printf( "vsx_module_list init: Error: trying to load the plugin \"%s\"\n" " Cause: sym could not find \"create_module\"\n", dynamic_object_file_name.c_str() ); continue; // try to load the next plugin } // initialize constructor (factory) method vsx_module*(*create_new_module)(unsigned long) = (vsx_module*(*)(unsigned long)) vsx_dlopen::sym( plugin_handle, "create_new_module" ); //------------------------------------------------------------------------- //------------------------------------------------------------------------- // look for the REQUIRED destructor method if (vsx_dlopen::sym(plugin_handle, "destroy_module") == 0) { printf( "vsx_module_list init: Error: trying to load the plugin \"%s\"\n" " Cause: sym could not find \"destroy_module\"\n", dynamic_object_file_name.c_str() ); continue; // try to load the next plugin } // init destructor method void(*destroy_module)(vsx_module*,unsigned long) = (void(*)(vsx_module*,unsigned long)) vsx_dlopen::sym( plugin_handle, "destroy_module" ); //------------------------------------------------------------------------- //------------------------------------------------------------------------- // look for the REQUIRED get_num_modules method if (vsx_dlopen::sym(plugin_handle, "get_num_modules") == 0) { printf( "vsx_module_list init: Error: trying to load the plugin \"%s\"\n" " Cause: sym could not find \"get_num_modules\"\n", dynamic_object_file_name.c_str() ); continue; // try to load the next plugin } // init get_num_modules method unsigned long(*get_num_modules)(void) = (unsigned long(*)(void)) vsx_dlopen::sym( plugin_handle, "get_num_modules" ); //------------------------------------------------------------------------- //------------------------------------------------------------------------- // check for and if found, set the optional environment_info support if (vsx_dlopen::sym(plugin_handle,"set_environment_info")) { void(*set_env)(vsx_engine_environment*) = (void(*)(vsx_engine_environment*)) vsx_dlopen::sym( plugin_handle, "set_environment_info" ); set_env(&engine_environment); } //------------------------------------------------------------------------- // get the number of modules in this plugin unsigned long num_modules_in_this_plugin = get_num_modules(); // iterate through modules in this plugin for ( size_t module_index_iterator = 0; module_index_iterator < num_modules_in_this_plugin; module_index_iterator++ ) { // ask the constructor / factory to create a module instance for us vsx_module* module_object = create_new_module(module_index_iterator); // check for error if (0x0 == module_object) { printf( "vsx_module_list init: Error: trying to load the plugin \"%s\"\n" " Cause: create_new_module returned 0x0 for module_index_iterator %lx\n" " Hint: If you are developing, check to see that get_num_modules returns\n" " the correct module count!\n" , dynamic_object_file_name.c_str(), module_index_iterator ); continue; // try to load the next module } // ask the module to provide its module info vsx_module_info* module_info = new vsx_module_info; module_object->module_info( module_info ); // check to see if this module can run on this system bool can_run = module_object->can_run(); destroy_module( module_object, module_index_iterator ); if (!can_run) continue; // try to load the next module module_info->location = "external"; // create module_plugin_info template vsx_module_plugin_info module_plugin_info_template; module_plugin_info_template.create_new_module = create_new_module; module_plugin_info_template.destroy_module = destroy_module; module_plugin_info_template.module_id = module_index_iterator; // split the module identifier string into its individual names // a module can have multiple names (and locations in the gui tree) // some of these are hidden, thus the name begins with an exclamation mark - ! // example module identifier string: // examples;my_modules;my_module||!old_path;old_category;old_name // Only the first will show up in the gui. The second identifier is still usable in // old state files. vsx_string deli = "||"; vsx_avector<vsx_string> parts; explode(module_info->identifier, deli, parts); vsx_module_plugin_info* applied_plugin_info = 0; // iterate through the individual names for this module for (unsigned long i = 0; i < parts.size(); ++i) { // create a copy of the template applied_plugin_info = new vsx_module_plugin_info; *applied_plugin_info = module_plugin_info_template; vsx_module_info* applied_module_info = new vsx_module_info; *applied_module_info = *module_info; applied_plugin_info->module_info = applied_module_info; vsx_string module_identifier; if (parts[i][0] == '!') { // hidden from gui applied_plugin_info->hidden_from_gui = true; module_identifier = parts[i].substr(1); } else { // normal applied_plugin_info->hidden_from_gui = false; module_identifier = parts[i]; } // set module info identifier applied_module_info->identifier = module_identifier; // add the applied_plugin_info to module_plugin_list module_plugin_list[module_identifier] = applied_plugin_info; // add the module info to the module list module_list[module_identifier] = module_info; } // iterate through the individual names for this module module_infos.push_back(module_info); } // iterate through modules in this plugin } // Iterate through all the filenames, treat them as plugins }
void vsx_statelist::render() { if (render_first) { glewInit(); GLint viewport[4]; glGetIntegerv(GL_VIEWPORT, viewport); if (tex1.has_buffer_support()) { tex1.init_feedback_buffer(viewport[2], viewport[3]); tex_to.init_feedback_buffer(viewport[2], viewport[3]); get_files_recursive(own_path+"visuals_faders", &fader_file_list,"",".svn CVS"); for (std::list<vsx_string>::iterator it = fader_file_list.begin(); it != fader_file_list.end(); ++it) { #ifdef VSXU_DEBUG printf("initializing fader %s\n", (*it).c_str()); #endif vsx_engine* lvxe = new vsx_engine(); lvxe->set_module_list( module_list ); lvxe->start(); lvxe->load_state(*it); faders.push_back(lvxe); fade_id = 0; } } transitioning = false; render_first = false; if ( state_iter == statelist.end() ) return; // mark all state_info instances volatile for (state_iter = statelist.begin(); state_iter != statelist.end(); state_iter++) { (*state_iter).is_volatile = true; } // go through statelist and load and validate every plugin std::vector<state_info> new_statelist; for (state_iter = statelist.begin(); state_iter != statelist.end(); state_iter++) { if (init_current((*state_iter).engine, &(*state_iter)) > 0) { continue; } new_statelist.push_back(*state_iter); if (option_preload_all == true) { while ( (*state_iter).engine->get_modules_left_to_load() ) { (*state_iter).engine->process_message_queue( &(*state_iter).cmd_in, cmd_out = &(*state_iter).cmd_out,false, true); (*state_iter).engine->render(); } } } statelist = new_statelist; // mark all state_info instances non-volatile (engine will be deleted when state_iter will be deleted) for (state_iter = statelist.begin(); state_iter != statelist.end(); state_iter++) { (*state_iter).is_volatile = true; } // reset state_iter to a random state state_iter = statelist.begin(); int steps = rand() % statelist.size(); while (steps) { ++state_iter; if (state_iter == statelist.end()) state_iter = statelist.begin(); --steps; } vxe = (*state_iter).engine; cmd_in = &(*state_iter).cmd_in; cmd_out = &(*state_iter).cmd_out; } // render first // prevent from rendering by mistake if ( !statelist.size() ) return; if ((*state_iter).engine != vxe) // change is on the way { if ( tex_to.has_buffer_support() ) { tex_to.begin_capture_to_buffer(); if ((*state_iter).engine) { (*state_iter).engine->process_message_queue(&(*state_iter).cmd_in,&(*state_iter).cmd_out); (*state_iter).engine->render(); } glColorMask(false, false, false, true); glClearColor(0,0,0,1); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glColorMask(true, true, true, true); tex_to.end_capture_to_buffer(); if ( (*state_iter).engine->get_modules_left_to_load() == 0 && (*state_iter).engine->get_commands_internal_count() && transition_time > 1.0f ) { transition_time = 1.0f; timer.start(); fade_id = rand() % (faders.size()); } } else { transition_time = -1.0f; } if (transition_time <= 0.0) { vxe = (*state_iter).engine; cmd_in = &(*state_iter).cmd_in; cmd_out = &(*state_iter).cmd_out; transitioning = false; transition_time = 2.0f; if (cmd_out && cmd_in) { if (vxe) { vxe->process_message_queue(cmd_in,cmd_out); } cmd_out->clear(true); } if (vxe) { vxe->render(); } } else { if (cmd_out && cmd_in) { if (vxe) { vxe->process_message_queue(cmd_in,cmd_out); } cmd_out->clear(true); } // begin capture if (tex1.has_buffer_support()) { tex1.begin_capture_to_buffer(); } // render if (vxe) { vxe->render(); } glColorMask(false, false, false, true); glClearColor(0,0,0,1); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glColorMask(true, true, true, true); // end capture and send to fader if (tex1.has_buffer_support()) { tex1.end_capture_to_buffer(); vsx_module_param_texture* param_t_a = (vsx_module_param_texture*)faders[fade_id]->get_in_param_by_name("visual_fader", "texture_a_in"); vsx_module_param_texture* param_t_b = (vsx_module_param_texture*)faders[fade_id]->get_in_param_by_name("visual_fader", "texture_b_in"); vsx_module_param_float* param_pos = (vsx_module_param_float*)faders[fade_id]->get_in_param_by_name("visual_fader", "fade_pos_in"); vsx_module_param_float* fade_pos_from_engine = (vsx_module_param_float*)faders[fade_id]->get_in_param_by_name("visual_fader", "fade_pos_from_engine"); faders[fade_id]->process_message_queue(&l_cmd_in, &l_cmd_out); l_cmd_out.clear(); if (param_t_a && param_t_b && param_pos && fade_pos_from_engine) { param_t_a->set(&tex1); param_t_b->set(&tex_to); fade_pos_from_engine->set(1.0f); float t = transition_time; if (t > 1.0f) t = 1.0f; if (t < 0.0f) t = 0.0f; param_pos->set(1.0-t); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); faders[fade_id]->render(); } } if (transition_time <= 1.0f) { transition_time -= timer.dtime(); } } } else { if (cmd_out && cmd_in) { vxe->process_message_queue(cmd_in, cmd_out); cmd_out->clear(); } vxe->render(); if (randomizer) { randomizer_time -= vxe->get_engine_info()->real_dtime; if (randomizer_time < 0.0f) { random_state(); randomizer_time = (float)(rand()%1000)*0.001f*15.0f+10.0f; } } } }