vsx_string vsx_engine_param::get_default_string() { if (alias) return alias_owner->get_default_string(); vsx_string p; switch (module_param->type) { case VSX_MODULE_PARAM_ID_INT: { sprintf(res,"%d",((vsx_module_param_int*)module_param)->param_data_default[0]); p = res; return p; } case VSX_MODULE_PARAM_ID_FLOAT: { sprintf(res,"%.20f",((vsx_module_param_float*)module_param)->param_data_default[0]); p = res; return p; } case VSX_MODULE_PARAM_ID_DOUBLE: { sprintf(res,"%.20f",((vsx_module_param_double*)module_param)->param_data_default[0]); p = res; return p; } case VSX_MODULE_PARAM_ID_FLOAT3: { sprintf(res,"%.20f",((vsx_module_param_float3*)module_param)->param_data_default[0]); p += res; sprintf(res,",%.20f",((vsx_module_param_float3*)module_param)->param_data_default[1]); p += res; sprintf(res,",%.20f",((vsx_module_param_float3*)module_param)->param_data_default[2]); p += res; return p; } case VSX_MODULE_PARAM_ID_FLOAT4: { sprintf(res,"%.20f",((vsx_module_param_float4*)module_param)->param_data_default[0]); p += res; sprintf(res,",%.20f",((vsx_module_param_float4*)module_param)->param_data_default[1]); p += res; sprintf(res,",%.20f",((vsx_module_param_float4*)module_param)->param_data_default[2]); p += res; sprintf(res,",%.20f",((vsx_module_param_float4*)module_param)->param_data_default[3]); p += res; return p; } case VSX_MODULE_PARAM_ID_QUATERNION: { sprintf(res,"%.20f",((vsx_module_param_quaternion*)module_param)->param_data_default[0]); p += res; sprintf(res,",%.20f",((vsx_module_param_quaternion*)module_param)->param_data_default[1]); p += res; sprintf(res,",%.20f",((vsx_module_param_quaternion*)module_param)->param_data_default[2]); p += res; sprintf(res,",%.20f",((vsx_module_param_quaternion*)module_param)->param_data_default[3]); p += res; return p; } case VSX_MODULE_PARAM_ID_STRING: { return vsx_string(""); } case VSX_MODULE_PARAM_ID_RESOURCE: { return vsx_string(""); } } return ""; }
void vsx_manager::init(const char* base_path, const char* sound_type) { if(!base_path) base_path = std::string(PLATFORM_SHARED_FILES_STLSTRING).c_str(); ((vsx_statelist*)int_state_manager)->init(vsx_string(base_path),vsx_string(sound_type)); }
void vsx_engine_param_list::dump_param_values(vsx_string my_name, vsx_command_list* command_result) { for (unsigned long i = 0; i < param_id_list.size(); ++i) { bool run = true; if (param_id_list[i]->channel) if ((param_id_list[i]->channel->connections.size())) run = false; if (run) { vsx_engine_param* param = param_id_list[i]; vsx_string pval = param->get_string(); if (!param->alias) { if ( pval != param->get_default_string() ) { if (param->module_param->type == VSX_MODULE_PARAM_ID_STRING) { command_result->add_raw(vsx_string("ps64 ")+my_name+" "+param->name+" "+base64_encode(pval)); } else command_result->add_raw(vsx_string("param_set ")+my_name+" "+param->name+" "+pval); } } // dump the param vsxl filter as well #ifndef VSXE_NO_GM if (param->module_param->vsxl_modifier) { vsx_param_vsxl_driver_abs* driver; driver = (vsx_param_vsxl_driver_abs*)((vsx_param_vsxl*)param->module_param->vsxl_modifier)->get_driver(); command_result->add_raw(vsx_string("vsxl_pfi ")+my_name+" "+param->name+" "+base64_encode(driver->script)); } #endif } } }
void load_desktop_a(vsx_string state_name) { //printf("{CLIENT} creating desktop:"); desktop = new vsx_widget_desktop; //printf(" [DONE]\n"); internal_cmd_in.clear(); internal_cmd_out.clear(); // connect server widget to command lists ((vsx_widget_server*)desktop->f("desktop_local"))->cmd_in = &internal_cmd_out; ((vsx_widget_server*)desktop->f("desktop_local"))->cmd_out = &internal_cmd_in; if (state_name != "") ((vsx_widget_server*)desktop->f("desktop_local"))->state_name = str_replace("/",";",str_replace("//",";",str_replace("_states/","",state_name))); internal_cmd_out.add_raw(vsx_string("vsxu_welcome ")+vsx_string(vsxu_ver)+" 0"); desktop->system_command_queue = &system_command_queue; vsx_widget* t_viewer = desktop->f("vsxu_preview"); if (t_viewer) { gui_prod_fullwindow = &((vsx_window_texture_viewer*)desktop->f("vsxu_preview"))->fullwindow; LOG_A("found vsxu_preview widget") } if (!dual_monitor) ((vsx_widget_server*)desktop->f("desktop_local"))->engine = (void*)vxe; desktop->front(desktop->f("vsxu_preview")); //printf("{CLIENT} starting desktop:"); desktop->init(); //printf(" [DONE]\n"); }
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(); }
void vsx_widget_base_edit::process_lines() { if (!process_characters) return; lines_p.clear(); for (unsigned long i = 0; i < lines.size(); ++i) { vsx_string b; char fill = (char)0x01; if (lines[i].size() >= 2) if (lines[i][0] == '/' && lines[i][1] == '/') fill = (char)0x02; for (size_t j = 0; j < lines[i].size(); ++j) { b = b + fill; } if (fill == (char)0x01) for (std::map<vsx_string,char>::iterator it = keywords.begin(); it != keywords.end(); ++it) { char f = (char)(*it).second; b = str_replace_char_pad((*it).first, vsx_string(f), lines[i], b); } lines_p.push_back(b); //lines_p[i] = b; //printf(" line %d: %s\n",i,lines[i].c_str()); //printf("pline %d: %s\n",i,b.c_str()); } }
// PRIVATE void vsx_widget_base_edit::process_line(int n_line) { if (!process_characters) return; int i = n_line; vsx_string b; char fill = (char)0x01; if (lines[i].size() >= 2) if (lines[i][0] == '/' && lines[i][1] == '/') fill = (char)0x02; for (size_t j = 0; j < lines[i].size(); ++j) { b = b + fill; } if (fill == (char)0x01) for (std::map<vsx_string,char>::iterator it = keywords.begin(); it != keywords.end(); ++it) { char f = (char)(*it).second; if (enable_syntax_highlighting) b = str_replace_char_pad((*it).first, vsx_string(f), lines[i], b); } if (n_line > (int)lines_p.size()-1) { lines_p.push_back(b); } else lines_p[n_line] = b; }
void declare_params(vsx_module_param_list& in_parameters, vsx_module_param_list& out_parameters) { loading_done = true; init_joysticks(); //if (!init_joystick()) return; //close( joy_fd ); //joy_fd = -1; for (int j = 0; j < joystick_count; j++) { printf("FOO num of axes: %d\n", joysticks[j].num_of_axis); joysticks[j].axis = (int *) calloc( joysticks[j].num_of_axis, sizeof( int ) ); joysticks[j].button = (char *) calloc( joysticks[j].num_of_buttons, sizeof( char ) ); joysticks[j].name = (vsx_module_param_string*)out_parameters.create(VSX_MODULE_PARAM_ID_STRING, vsx_string("j_"+i2s(j)+"_name").c_str()); joysticks[j].name->set(vsx_string(joysticks[j].name_of_joystick)); for (int i = 0; i < joysticks[j].num_of_buttons; i++) { joysticks[j].buttons[i] = (vsx_module_param_float*)out_parameters.create(VSX_MODULE_PARAM_ID_FLOAT,(vsx_string("j_"+i2s(j)+"_button")+i2s(i)).c_str()); joysticks[j].buttons[i]->set(0.0f); } for (int i = 0; i < joysticks[j].num_of_axis; i++) { joysticks[j].axes[i] = (vsx_module_param_float*)out_parameters.create(VSX_MODULE_PARAM_ID_FLOAT,(vsx_string("j_"+i2s(j)+"_axis")+i2s(i)).c_str()); joysticks[j].axes[i]->set(0.0f); } } //float_in = (vsx_module_param_float*)in_parameters.create(VSX_MODULE_PARAM_ID_FLOAT,"shutdown"); //float_in->set(0); //render_out = (vsx_module_param_render*)out_parameters.create(VSX_MODULE_PARAM_ID_RENDER,"render_out"); //-------------------------------------------------------------------------------------------------- }
void vsx_manager::add_visual_path(const char* new_visual_path) { if(!new_visual_path) return; ((vsx_statelist*)int_state_manager)->add_visual_path(vsx_string(new_visual_path)); }
void app_init() { my_draw = new vsxu_draw(); //--------------------------------------------------------------------------- vsxf filesystem; myf.load( vsx_string(PLATFORM_SHARED_FILES) + "font/font-ascii_output.png", &filesystem ); }
bool init_joysticks() { // printf("start init joysticks\n"); for (int i = 0; i < 10; i++) { joystick_info ji; if (joysticks[i].joy_fd == -2) // uninitialized! if ( ( ji.joy_fd = open( (vsx_string(JOY_DEV)+i2s(i)).c_str() , O_RDONLY)) != -1 ) { // enumerate joystick fcntl( ji.joy_fd, F_SETFL, O_NONBLOCK ); ioctl( ji.joy_fd, JSIOCGAXES, &ji.num_of_axis ); ioctl( ji.joy_fd, JSIOCGBUTTONS, &ji.num_of_buttons ); ioctl( ji.joy_fd, JSIOCGNAME(80), &ji.name_of_joystick ); /*printf("Joystick detected: %s\n\t%d axis\n\t%d buttons\n\n" , ji.name_of_joystick , ji.num_of_axis , ji.num_of_buttons );*/ joysticks[i] = ji; // printf("ji.joy_fd: %d\n", ji.joy_fd); joystick_count++; } } /* joy_fd = -1; num_of_axis = 0; num_of_buttons = 0; if( ( joy_fd = open( JOY_DEV1 , O_RDONLY)) == -1 ) { printf( "Couldn't open joystick\n" ); return false; } fcntl( joy_fd, F_SETFL, O_NONBLOCK ); ioctl( joy_fd, JSIOCGAXES, &num_of_axis ); ioctl( joy_fd, JSIOCGBUTTONS, &num_of_buttons ); ioctl( joy_fd, JSIOCGNAME(80), &name_of_joystick ); printf("Joystick detected: %s\n\t%d axis\n\t%d buttons\n\n" , name_of_joystick , num_of_axis , num_of_buttons );*/ return true; }
void vsx_window_object_inspector::command_process_back_queue(vsx_command_s *t) { if (k_focus == component_rename_edit || t->cmd == "component_rename_button") { if (inspected->widget_type == VSX_WIDGET_TYPE_COMPONENT) { vsx_widget_component* cc = (vsx_widget_component*)inspected; vsx_string curname = ""; vsx_string newname = ""; // if (cc->parent_name != "") { // curname += cc->parent_name+"."; // newname += cc->parent_name+"."; // } newname += ((vsx_widget_base_edit*)component_rename_edit)->get_string(); command_q_b.add_raw("component_rename " +cc->name+" "+newname); cc->server->vsx_command_queue_b(this); } else if (inspected->widget_type == VSX_WIDGET_TYPE_ANCHOR) { //printf("sending\n"); command_q_b.add_raw( "pa_ren "+ // command ((vsx_widget_anchor*)inspected)->component->name+" "+ // component ((vsx_widget_anchor*)inspected)->name+" "+ ((vsx_widget_base_edit*)component_rename_edit)->get_string()+" "+ vsx_string_helper::i2s(((vsx_widget_anchor*)inspected)->io) ); ((vsx_widget_component*)((vsx_widget_anchor*)inspected)->component)->server->vsx_command_queue_b(this); } } if (t->cmd == "component_timing_ok") { label2->title = vsx_string("run time: ")+t->parts[2] + " seconds\noutput time:" + t->parts[3] + " seconds\n"; label2->title = label2->title + "% of total frame time: "+vsx_string_helper::f2s( (vsx_string_helper::s2f(t->parts[2])+vsx_string_helper::s2f(t->parts[3]))*100.0f / vsx_string_helper::s2f(t->parts[4]),3); } //if (t->cmd == "cancel") { visible = 0; return; } //if (((vsx_widget_2d_edit*)edit1)->value.str().size()) //{ //command_q_b.add(name,((vsx_widget_2d_edit*)edit1)->value.str()); //parent->vsx_command_queue_b(this); //((vsx_widget_2d_edit*)edit1)->value.str(""); //((vsx_widget_2d_edit*)edit1)->value.clear(); //} //visible = 0; }
void vsx_manager::init(const char* base_path, const char* sound_type) { vsx_string b_path; if(!base_path) b_path = PLATFORM_SHARED_FILES; else b_path = base_path; vsx_string s_type(sound_type); if (s_type == "media_player") { s_type = "-sound_type_media_player"; } module_list = vsx_module_list_factory_create(); ((vsx_statelist*)int_state_manager)->set_module_list( module_list ); ((vsx_statelist*)int_state_manager)->init(b_path,vsx_string(sound_type)); }
void vsx_widget_desktop::load_configuration() { vsx_command_list main_conf; vsx_string config_file = vsx_get_data_path() + "vsxu.conf"; if (access(config_file.c_str(),0) == 0) { main_conf.load_from_file(config_file.c_str(),true,0); } else { main_conf.load_from_file(PLATFORM_SHARED_FILES+"vsxu.conf",true,0); } #ifdef VSXU_DEBUG printf("conf: %s\n", config_file.c_str()); #endif main_conf.reset(); vsx_command_s* mc = 0; auto_undo = 1; while ( (mc = main_conf.get()) ) { if (mc->cmd == "skin") { skin_path = PLATFORM_SHARED_FILES+vsx_string("gfx")+DIRECTORY_SEPARATOR+mc->cmd_data+DIRECTORY_SEPARATOR; #ifdef VSXU_DEBUG printf("skin path: %s\n",skin_path.c_str()); #endif } else if (mc->cmd == "global_interpolation_speed") { global_interpolation_speed = s2f(mc->cmd_data); } else if (mc->cmd == "automatic_undo") { auto_undo = s2i(mc->cmd_data); } else if (mc->cmd == "global_framerate_limit") { global_framerate_limit = s2f(mc->cmd_data); } else if (mc->cmd == "global_key_speed") { global_key_speed = s2f(mc->cmd_data); } if (mc->cmd != "" && mc->cmd != "#") configuration[mc->cmd] = mc->cmd_data; } }
void vsx_widget_desktop::load_configuration() { vsx_command_list main_conf; vsx_string config_file = vsx_data_path::get_instance()->data_path_get() + "vsxu.conf"; if (access(config_file.c_str(),0) == 0) { main_conf.load_from_file(config_file.c_str(),true,0); } else { main_conf.load_from_file(PLATFORM_SHARED_FILES+"vsxu.conf",true,0); } main_conf.reset(); vsx_command_s* mc = 0; auto_undo = 1; while ( (mc = main_conf.get()) ) { if (mc->cmd == "skin") { vsx_widget_skin::get_instance()->skin_path_set( PLATFORM_SHARED_FILES+vsx_string("gfx")+DIRECTORY_SEPARATOR + mc->cmd_data+DIRECTORY_SEPARATOR ); vsx_widget_skin::get_instance()->init(); } else if (mc->cmd == "global_interpolation_speed") { vsx_widget_global_interpolation::get_instance()->set( vsx_string_helper::s2f(mc->cmd_data) ); } else if (mc->cmd == "automatic_undo") { auto_undo = vsx_string_helper::s2i(mc->cmd_data); } else if (mc->cmd == "global_framerate_limit") { global_framerate_limit = vsx_string_helper::s2f(mc->cmd_data); } else if (mc->cmd == "global_key_speed") { camera.set_key_speed( vsx_string_helper::s2f(mc->cmd_data) ); } if (mc->cmd != "" && mc->cmd != "#") configuration[mc->cmd] = mc->cmd_data; } }
void draw() { if (record_movie) { vxe->set_constant_frame_progression(1.0f / 60.0f); vxe->play(); } if (desktop) { desktop->vsx_command_process_f(); } if (first) { intro = new vsx_logo_intro; } dt = gui_t.dtime(); gui_f_time += dt; gui_g_time += dt; float f_wait; bool run_always = false; if (desktop) { if (desktop->global_framerate_limit == -1) { run_always = true; } else { f_wait = 1.0f/desktop->global_framerate_limit; } } else { f_wait = 1.0f/100.0f; } if (run_always || gui_f_time > f_wait) { ++frame_count; if (desktop) { desktop->dtime = gui_f_time; desktop->time += desktop->dtime; desktop->frames = frame_count; } gui_fullscreen_fpstimer += gui_f_time; current_fps = f2s(round(1.0f/gui_f_time),2); if (gui_fullscreen_fpstimer > 1) { vsx_string h = fpsstring + " @ "+ current_fps+ "fps"; gui_fullscreen_fpstimer = 0; } gui_f_time = 0; if (!*gui_prod_fullwindow) { if (desktop) { desktop->init_frame(); desktop->draw(); desktop->draw_2d(); } } if (!dual_monitor) { vxe->process_message_queue(&internal_cmd_in,&internal_cmd_out); } if (*gui_prod_fullwindow) { glDepthMask(GL_TRUE); glClearColor(0.0f,0.0f,0.0f,1.0f); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); #ifndef NO_INTRO if (vxe->e_state == VSX_ENGINE_STOPPED) { //intro->draw(true); } #endif if (vxe && !dual_monitor) { vxe->render(); glDisable(GL_DEPTH_TEST); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glEnable(GL_BLEND); ++frame_counter; ++delta_frame_counter; delta_frame_time+= dt; total_time += dt; if (delta_frame_counter == 100) { delta_fps = 100.0f/delta_frame_time; delta_frame_counter = 0; delta_frame_time = 0.0f; } if (gui_prod_fullwindow_helptext) { glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4f(0,0,0,0.4f); glBegin(GL_QUADS); // Draw A Quad glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right glVertex3f( 1.0f,0.92f, 0.0f); // Bottom Right glVertex3f(-1.0f,0.92f, 0.0f); // Bottom Left glEnd(); // Done Drawing The Quad myf.print(vsx_vector(-1.0f,0.92f)," Fc "+i2s(frame_counter)+" Fps "+f2s(delta_fps)+" T "+f2s(total_time)+" Tfps "+f2s(frame_counter/total_time)+" MC "+i2s(vxe->get_num_modules())+" VSX Ultra (c) 2003-2010 Vovoid - Alt+T=toggle this text, Ctrl+Alt+P=screenshot (data dir), Alt+F=performance mode ",0.03f); } } if (desktop && desktop->performance_mode) { glClear(GL_DEPTH_BUFFER_BIT); desktop->init_frame(); desktop->draw(); desktop->draw_2d(); } } #ifndef NO_INTRO //intro->draw(); #endif if (!first && !desktop) { pgv.iterations = -1; } pgv.process_garbage(); if (first) { if (!dual_monitor) { vxe->init(); vxe->start(); } load_desktop_a(); first = false; } } else { int zz = (int)((f_wait-gui_f_time)*1000.0f); if (zz < 0) zz = 0; //printf("zz%d ",zz); //Sleep(zz); } //------------------------------------------------------------------ // movie recording //------------------------------------------------------------------ if (record_movie) { GLint viewport[4]; glGetIntegerv(GL_VIEWPORT, viewport); char* pixeldata = (char*)malloc( viewport[2] * viewport[3] * 3 ); char* pixeldata_flipped = (char*)malloc( viewport[2] * viewport[3] * 3 ); take_screenshot = false; glReadPixels(0,0,viewport[2],viewport[3],GL_RGB,GL_UNSIGNED_BYTE, (GLvoid*)pixeldata); int x3 = viewport[2]*3; int hi = viewport[3]; for (int y = 0; y < hi; y++) { for (int x = 0; x < x3; x++) { pixeldata_flipped[y*x3+x] = pixeldata[ (hi-y)*x3+x]; } } CJPEGTest jpeg; jpeg.m_nResX = viewport[2]; jpeg.m_nResY = viewport[3]; jpeg.m_pBuf = (unsigned char*)pixeldata_flipped; //char filename[32768]; #if PLATFORM_FAMILY == PLATFORM_FAMILY_UNIX if (access((vsx_get_data_path()+"videos").c_str(),0) != 0) mkdir((vsx_get_data_path()+"/videos").c_str(),0700); //sprintf(filename, "%sscreenshots/%d_%d_%d_rgb.jpg",vsx_get_data_path().c_str(),(int)time(0),viewport[2],viewport[3]); #endif vsx_string err; char mfilename[32]; sprintf(mfilename, "%05d", movie_frame_count); jpeg.SaveJPEG( vsx_get_data_path()+"videos"+DIRECTORY_SEPARATOR+vsx_string(mfilename)+"_"+ i2s(viewport[2]) + "_" + i2s(viewport[3])+".jpg", err, 100 ); jpeg.m_pBuf = 0; free(pixeldata); free(pixeldata_flipped); movie_frame_count++; } //------------------------------------------------------------------ // screenshots //------------------------------------------------------------------ if (take_screenshot) { GLint viewport[4]; glGetIntegerv(GL_VIEWPORT, viewport); char* pixeldata = (char*)malloc( viewport[2] * viewport[3] * 3 ); char* pixeldata_flipped = (char*)malloc( viewport[2] * viewport[3] * 3 ); take_screenshot = false; glReadPixels(0,0,viewport[2],viewport[3],GL_RGB,GL_UNSIGNED_BYTE, (GLvoid*)pixeldata); int x3 = viewport[2]*3; int hi = viewport[3]; for (int y = 0; y < hi; y++) { for (int x = 0; x < x3; x++) { pixeldata_flipped[y*x3+x] = pixeldata[ (hi-y)*x3+x]; } } CJPEGTest jpeg; jpeg.m_nResX = viewport[2]; jpeg.m_nResY = viewport[3]; jpeg.m_pBuf = (unsigned char*)pixeldata_flipped; //char filename[32768]; #if PLATFORM_FAMILY == PLATFORM_FAMILY_UNIX if (access((vsx_get_data_path()+"screenshots").c_str(),0) != 0) mkdir((vsx_get_data_path()+"/screenshots").c_str(),0700); //sprintf(filename, "%sscreenshots/%d_%d_%d_rgb.jpg",vsx_get_data_path().c_str(),(int)time(0),viewport[2],viewport[3]); #endif /*FILE* fp = fopen(filename,"wb"); fwrite(pixeldata_flipped, 1, viewport[2] * viewport[3] * 3, fp); fclose(fp);*/ vsx_string err; jpeg.SaveJPEG( vsx_get_data_path()+"screenshots"+DIRECTORY_SEPARATOR+i2s(time(0))+"_"+ i2s(viewport[2]) + "_" + i2s(viewport[3])+".jpg", err, 100 ); jpeg.m_pBuf = 0; free(pixeldata); free(pixeldata_flipped); } } // ::draw()
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 }
#include "application.h" #include "vsxg.h" #include <sys/types.h> #include <sys/stat.h> #include <stdio.h> #if PLATFORM_FAMILY == PLATFORM_FAMILY_UNIX #include <time.h> #endif #include "vsx_command_client_server.h" vsx_command_list_server cl_server; // global vars vsx_string fpsstring = "VSX Ultra "+vsx_string(vsxu_version)+" - 2010 Vovoid"; vsx_engine* vxe = 0; // from the perspective (both for gui/server) from here towards the tcp thread vsx_command_list internal_cmd_in; vsx_command_list internal_cmd_out; bool prod_fullwindow = false; bool take_screenshot = false; bool record_movie = false; bool *gui_prod_fullwindow; bool gui_prod_fullwindow_helptext = true; unsigned long frame_counter = 0; unsigned long delta_frame_counter = 0; float delta_frame_time = 0.0f; float delta_fps;
void vsx_window_object_inspector::draw() { if (a_focus != component_rename_edit && inspected != a_focus && a_focus != this) { //resize_to(vsx_vector(0.001,0.001)); //move(1-0.001,1); move(1.0f,1.0f); inspected = a_focus; for (unsigned int i = 0; i < component_list.size(); ++i) component_list[i]->visible = 0; if (inspected->widget_type == VSX_WIDGET_TYPE_ANCHOR) { //label1->title = +a_focus->type; label2->title = vsx_string("Anchor data type:")+((vsx_widget_anchor*)inspected)->p_type; label1->visible = label2->visible = 1; if (((vsx_widget_anchor*)inspected)->alias) { label1->title = "Rename alias:"; component_rename_button->visible = 1; component_rename_edit->visible = 1; } //for (int i = 0; i < component_list.size(); ++i) component_list[i]->visible = 1; ((vsx_widget_base_edit*)component_rename_edit)->set_string(((vsx_widget_anchor*)a_focus)->name); //((vsx_widget_2d_edit*)component_rename_edit)->value.clear(); title = "anchor "+((vsx_widget_anchor*)a_focus)->name; view_type = 0; set_size(vsx_vector3<>(0.2f, 0.175f, 0.0f)); move(1.0f - 0.2f , 1.0f - 0.175f, 0.0f); } else if (inspected->widget_type == VSX_WIDGET_TYPE_CONNECTOR) { label1->title = ((vsx_widget_connector_bezier*)a_focus)->destination->name; view_type = 0; label1->visible = 1; //label2->title = ((vsx_widget_anchor*)inspected)->p_type; } else if (inspected->widget_type == VSX_WIDGET_TYPE_COMPONENT) { label1->title = "Rename module:"; component_rename_button->visible = 1; component_rename_edit->visible = 1; for (unsigned long i = 0; i < component_list.size(); ++i) component_list[i]->visible = 1; //component_rename_button->visible = 1; //component_rename_edit->visible = 1; //label1->title = a_focus->name; ((vsx_widget_base_edit*)component_rename_edit)->set_string(((vsx_widget_component*)a_focus)->real_name); ((vsx_widget_base_edit*)component_rename_edit)->caret_goto_end(); // ((vsx_widget_base_edit*)component_rename_edit)->value.clear(); title = ((vsx_widget_component*)a_focus)->real_name; view_type = 0; //printf("resize to\n"); set_size(vsx_vector3<>(0.2f, 0.175f, 0.0f)); move(1.0f - 0.2f , 1.0f - 0.175f, 0.0f); // request timing data label2->title = "This build of the engine does not\nsupport timing. The reason?\nTiming slows down performance.\n"; #ifdef VSXU_MODULE_TIMING command_q_b.add_raw("component_timing "+((vsx_widget_component*)a_focus)->real_name+" "+vsx_string_helper::i2s(id)); #endif ((vsx_widget_component*)a_focus)->server->vsx_command_queue_b(this); } else if (inspected->widget_type == VSX_WIDGET_TYPE_ULTRA_CHOOSER) { //((vsx_widget_2d_edit*)component_rename_edit)->value.str(((vsx_widget_component*)a_focus)->real_name); //((vsx_widget_2d_edit*)component_rename_edit)->value.clear(); //title = ((vsx_widget_component*)inspected)->component_type; } else view_type = 0; // image viewer } vsx_status_timer -= vsx_widget_time::get_instance()->get_dtime(); if (inspected->widget_type == VSX_WIDGET_TYPE_COMPONENT) { if (vsx_status_timer < 0.0f) { vsx_status_timer = 1.0f; #ifdef VSXU_MODULE_TIMING command_q_b.add_raw("component_timing "+((vsx_widget_component*)inspected)->real_name+" "+vsx_string_helper::i2s(id)); ((vsx_widget_component*)inspected)->server->vsx_command_queue_b(this); #endif } } }