void SettingsPanel::onLaserButtonClick( Gwen::Controls::Base* pControl ){ console() << "SettingsPanel::onLaserButtonClick " << std::endl; sOnLaserButtonClick(); }
void VideoTable::setup(){ cTarget = new gallerytools::CursorTarget(); model.setup("SETTINGS.plist","RECIPES.plist"); if(model.useSensors){ pConnector.useEvents(false); } setFullScreen(model.isFullScreen); if(model.isFullScreen) hideCursor(); int numRecipes = model.recipes.size(); for(int i=0;i<model.areas.size();i++){ string thisRecipe_str = model.areas.at(i).recipe; UserAreaModel theUserAreaModel = model.areas.at(i); RecipeModel theRecipeModel = model.getRecipeModel(thisRecipe_str); recipeViews.push_back(RecipeView(theUserAreaModel, theRecipeModel)); } controller.setup(&model,&recipeViews); console() << "there are " << numRecipes << " recipes."; background_tex = gl::Texture( loadImage( model.backgroundPath ) ); foreground_tex = gl::Texture( loadImage( model.foregroundPath ) ); if(model.useSensors){ vector<int> uniqueSensorBoards; for(int i=0;i<model.sensors.size();i++){ TouchSensorModel thisParticularSensor = model.sensors.at(i); int thisParticularInt = thisParticularSensor.board; bool isThisParticularIntUnique = true; for(int j=0;j<uniqueSensorBoards.size();j++){ if(uniqueSensorBoards.at(j) == thisParticularInt){ isThisParticularIntUnique = false; } } if(isThisParticularIntUnique){ uniqueSensorBoards.push_back(thisParticularInt); } } for(int i=0;i<uniqueSensorBoards.size();i++){ pConnector.connect(uniqueSensorBoards.at(i), model.sensorTimeOut); } pg.setup(&pConnector, &model.sensors); } mParams = params::InterfaceGl( "CardBox Functions", Vec2i( 225, 200 ) ); mParams.addButton("select button", std::bind( &VideoTable::selectButtonHandler, this )); mParams.addButton("back button", std::bind( &VideoTable::backButtonHandler, this )); mParams.addButton("skip button", std::bind( &VideoTable::skipButtonHandler, this )); mParams.show(); }
void VideoTable::backButtonHandler(){ console() << "back button handler" << endl; }
void Main::launch_game() { SDLSubsystem sdl_subsystem; ConsoleBuffer console_buffer; timelog("controller"); InputManager input_manager(g_config->keyboard_config, g_config->joystick_config); timelog("commandline"); timelog("video"); std::unique_ptr<VideoSystem> video_system = VideoSystem::create(g_config->video); DrawingContext context(*video_system); init_video(); timelog("audio"); SoundManager sound_manager; sound_manager.enable_sound(g_config->sound_enabled); sound_manager.enable_music(g_config->music_enabled); Console console(console_buffer); timelog("scripting"); scripting::Scripting scripting(g_config->enable_script_debugger); timelog("resources"); TileManager tile_manager; SpriteManager sprite_manager; Resources resources; timelog("addons"); AddonManager addon_manager("addons", g_config->addons); timelog(0); const std::unique_ptr<Savegame> default_savegame(new Savegame(std::string())); GameManager game_manager; ScreenManager screen_manager; if(g_config->start_level != "") { // we have a normal path specified at commandline, not a physfs path. // So we simply mount that path here... std::string dir = FileSystem::dirname(g_config->start_level); std::string fileProtocol = "file://"; std::string::size_type position = dir.find(fileProtocol); if(position != std::string::npos) { dir = dir.replace(position, fileProtocol.length(), ""); } log_debug << "Adding dir: " << dir << std::endl; PHYSFS_addToSearchPath(dir.c_str(), true); if(g_config->start_level.size() > 4 && g_config->start_level.compare(g_config->start_level.size() - 5, 5, ".stwm") == 0) { screen_manager.push_screen(std::unique_ptr<Screen>( new worldmap::WorldMap( FileSystem::basename(g_config->start_level), *default_savegame))); } else { std::unique_ptr<GameSession> session ( new GameSession(FileSystem::basename(g_config->start_level), *default_savegame)); g_config->random_seed = session->get_demo_random_seed(g_config->start_demo); g_config->random_seed = gameRandom.srand(g_config->random_seed); graphicsRandom.srand(0); if(g_config->start_demo != "") session->play_demo(g_config->start_demo); if(g_config->record_demo != "") session->record_demo(g_config->record_demo); screen_manager.push_screen(std::move(session)); } } else { screen_manager.push_screen(std::unique_ptr<Screen>(new TitleScreen(*default_savegame))); } screen_manager.run(context); }
int ExampleText::start(const std::vector<CL_String> &args) { // Create a console window for text-output if not available CL_ConsoleWindow console("Console"); quit = false; // Set a videomode CL_DisplayWindowDescription desc; desc.set_allow_resize(false); desc.set_title("ClanLib CL_SpanLayout Example"); desc.set_size(CL_Size(800, 600), true); CL_DisplayWindow window(desc); // Connect the Window close event CL_Slot slot_quit = window.sig_window_close().connect(this, &ExampleText::on_window_close); // Connect a keyboard handler to on_key_up() CL_Slot slot_keyboard_up = window.get_ic().get_keyboard().sig_key_up().connect(this, &ExampleText::on_keyboard_up); CL_GraphicContext gc = window.get_gc(); CL_TextureGroup texture_group(gc, CL_Size(512, 512)); CL_FontDescription font_desc; font_desc.set_typeface_name("Tahoma"); font_desc.set_anti_alias(true); font_desc.set_height(32); CL_Font_System font_normal(gc, font_desc); font_desc.set_weight(800); font_desc.set_height(40); CL_Font_System font_bold(gc, font_desc); // Share the font texture font_normal.set_texture_group(texture_group); font_bold.set_texture_group(texture_group); CL_Texture texture_text(gc, text_window_size, text_window_size); texture_text.set_wrap_mode(cl_wrap_repeat, cl_wrap_repeat, cl_wrap_repeat); texture_text.set_min_filter(cl_filter_linear); texture_text.set_mag_filter(cl_filter_linear); // Create the framebuffer, and attach the texture text into its color buffer CL_FrameBuffer fb_text; fb_text = CL_FrameBuffer(gc); fb_text.attach_color_buffer(0, texture_text); float angle = 0.0f; std::vector<CL_SpanLayout> layout; // Count number of lines int num_lines = 0; for (const char **text_ptr = TextToShow; *text_ptr; text_ptr++) { num_lines++; } // Extend layout vector layout.resize(num_lines); int ypos = 60; for (int line_count=0; line_count < num_lines; line_count++, ypos += 8) { layout[line_count] = CL_SpanLayout(); layout[line_count].set_position(CL_Point(20, ypos)); layout[line_count].set_align(cl_justify); const char *text_ptr = TextToShow[line_count]; if (text_ptr[0] == '-') { layout[line_count].add_text(text_ptr, font_normal, CL_Colorf::red); } else if (strstr(text_ptr, "Clan")) { layout[line_count].add_text(text_ptr, font_bold, CL_Colorf::yellow); } else { layout[line_count].add_text(text_ptr, font_normal, CL_Colorf::yellow); } layout[line_count].layout(gc, texture_text.get_width() - 60); ypos += layout[line_count].get_size().height; } // Run until someone presses escape while (!quit) { int start_time = CL_System::get_time(); gc.set_map_mode(CL_MapMode(cl_map_2d_upper_left)); // Draw a nice blue gradient in the background CL_Draw::gradient_fill(gc, window.get_viewport(), CL_Gradient(CL_Colorf::lightblue, CL_Colorf::lightblue, CL_Colorf::darkblue, CL_Colorf::darkblue)); // Draw the text into the frame buffer update_text(gc, fb_text, font_normal, layout); angle += 0.5f; if (angle >= 360.0f) angle -= 360.0f; // Draw the text draw_text(gc, texture_text, CL_Angle(angle, cl_degrees)); last_fps = 1000.0f / (CL_System::get_time()-start_time); // Flip the display, showing on the screen what we have drawn window.flip(1); // This call updates input and performs other "housekeeping" call this each frame CL_KeepAlive::process(); } return 0; }
void SimplePuzzleApp::torrentReceived( TorrentRef tr ) { console() << *tr << endl; }
int CBGA::main(int argc, char **argv) { #ifdef _DEBUG // создаём консоль CL_ConsoleWindow console("BGA Console"); console.redirect_stdio(); #endif try { //инициализация CL_SetupCore::init(); CL_SetupDisplay::init(); CL_SetupGL::init(); CL_SetupNetwork::init(); CL_SetupSound::init(); CL_SetupVorbis::init(); CL_SoundOutput output(44100); LOG<<"Bad Guys on Autos\nВерсия "<<VERSION<<endl; LOG<<LOG.Time()<<"Старт игры\n"; LOG<<"Установка графического режима...\n"; //окно #ifdef _DEBUG CL_DisplayWindow window("BGA v"VERSION, SCR_W, SCR_H, false, true); #else CL_DisplayWindow window("BGA v"VERSION, SCR_W, SCR_H, true); #endif window.hide_cursor(); //получаем текущий режим DEVMODE cur_devmode; EnumDisplaySettings(0, ENUM_CURRENT_SETTINGS, &cur_devmode); LOG<<"Установлен графический режим "<<cur_devmode.dmPelsWidth<<"x"<<cur_devmode.dmPelsHeight<<"x"; LOG<<cur_devmode.dmBitsPerPel<<"@"<<cur_devmode.dmDisplayFrequency<<endl; //контекст CL_GraphicContext *gc = window.get_gc(); srand(CL_System::get_time()); CGame Game; #ifndef _DEBUG Intro(Game.GetResman()); CGameMenu game_menu(&Game); game_menu.Intro(); game_menu.MainLoop(); #else //CGameMenu game_menu(&Game); //game_menu.MainLoop(); Game.SetLimits(3,0); Game.SetLocalNames("Tosha","Hitman","Crash","Doom"); Game.NewGame(BGA_GAME_DEATHMATCH,2,"platetown"); Game.MainLoop(); #endif LOG<<LOG.Time()<<"Завершение игры\n"; //деинициализация CL_SetupVorbis::deinit(); CL_SetupSound::deinit(); CL_SetupNetwork::deinit(); CL_SetupCore::deinit(); CL_SetupDisplay::deinit(); CL_SetupGL::deinit(); } catch (CL_Error err) { std::cout << "Exception caught: " << err.message.c_str() << std::endl; LOG<<endl<<LOG.Time()<<"ОШИБКА! "<< err.message.c_str() <<endl; #ifdef _DEBUG // Display console close message and wait for a key console.display_close_message(); #endif } catch (...) { LOG<<endl<<LOG.Time()<<"ОШИБКА! Необработанное исключение!"<<endl; } LOG<<"\n\n\nThe time of Bad Guys will come soon..."; //console.display_close_message(); return 0; }
void CameraAdapter::reconnect() { console()<<"try reconnect ......................"<<std::endl; reconnectTimer.stop(); setup(); }
void Main::launch_game() { SDLSubsystem sdl_subsystem; ConsoleBuffer console_buffer; timelog("controller"); InputManager input_manager(g_config->keyboard_config, g_config->joystick_config); timelog("commandline"); timelog("video"); std::unique_ptr<VideoSystem> video_system = VideoSystem::create(g_config->video); DrawingContext context(*video_system); init_video(); timelog("audio"); SoundManager sound_manager; sound_manager.enable_sound(g_config->sound_enabled); sound_manager.enable_music(g_config->music_enabled); Console console(console_buffer); timelog("scripting"); scripting::Scripting scripting(g_config->enable_script_debugger); timelog("resources"); TileManager tile_manager; SpriteManager sprite_manager; Resources resources; timelog("addons"); AddonManager addon_manager("addons", g_config->addons); timelog(0); const std::unique_ptr<Savegame> default_savegame(new Savegame(std::string())); GameManager game_manager; ScreenManager screen_manager; if(!g_config->start_level.empty()) { // we have a normal path specified at commandline, not a physfs path. // So we simply mount that path here... std::string dir = FileSystem::dirname(g_config->start_level); std::string filename = FileSystem::basename(g_config->start_level); std::string fileProtocol = "file://"; std::string::size_type position = dir.find(fileProtocol); if(position != std::string::npos) { dir = dir.replace(position, fileProtocol.length(), ""); } log_debug << "Adding dir: " << dir << std::endl; PHYSFS_mount(dir.c_str(), NULL, true); if(g_config->start_level.size() > 4 && g_config->start_level.compare(g_config->start_level.size() - 5, 5, ".stwm") == 0) { screen_manager.push_screen(std::unique_ptr<Screen>( new worldmap::WorldMap(filename, *default_savegame))); } else { std::unique_ptr<GameSession> session ( new GameSession(filename, *default_savegame)); g_config->random_seed = session->get_demo_random_seed(g_config->start_demo); g_config->random_seed = gameRandom.srand(g_config->random_seed); graphicsRandom.srand(0); if (g_config->tux_spawn_pos) { session->get_current_sector()->player->set_pos(*g_config->tux_spawn_pos); } if(!g_config->start_demo.empty()) session->play_demo(g_config->start_demo); if(!g_config->record_demo.empty()) session->record_demo(g_config->record_demo); screen_manager.push_screen(std::move(session)); } } else { screen_manager.push_screen(std::unique_ptr<Screen>(new TitleScreen(*default_savegame))); if (g_config->edit_level) { if (PHYSFS_exists(g_config->edit_level->c_str())) { std::unique_ptr<Editor> editor(new Editor()); editor->set_level(*(g_config->edit_level)); editor->setup(); editor->update(0); screen_manager.push_screen(std::move(editor)); MenuManager::instance().clear_menu_stack(); sound_manager.stop_music(0.5); } else { log_warning << "Level " << *(g_config->edit_level) << " doesn't exist." << std::endl; } } } screen_manager.run(context); }
//----------------------------------------------------------------------------------- void CameraAdapter::photoCameraError( EdsError err) { //string temp = (c_str, strnlen(c_str, max_length)); photoCameraErrorMsg = CanonErrorToString(err); console()<<" == photoCameraError = "<<CanonErrorToString(err)<<std::endl; }
void CameraAdapter::photoTaken(EdsDirectoryItemRef directoryItem, EdsError error) { console()<<" == photoTaken = "<<std::endl; mCamera.downloadImage(directoryItem, this); }
// The start of the Application int App::start(const std::vector<CL_String> &args) { quit = false; // Create a console window for text-output if not available CL_ConsoleWindow console("Console", 80, 200); try { // Set the window // This opens a 640 x 480 window, including the frame size // If you want more control over the window, pass CL_DisplayWindowDescription to CL_DisplayWindow // (This is useful to create a borderless window of a specific size) // If you require target specific control over the window, use the derived CL_OpenGLWindowDescription // (This contains the multisampling options) #ifdef USE_SWRENDER CL_DisplayWindowDescription desc; #else CL_OpenGLWindowDescription desc; // desc.set_multisampling(4); #endif desc.set_title("ClanLib 2D Test"); desc.set_size(CL_Size(800, 600), true); CL_DisplayWindow window(desc); // Connect the Window close event CL_Slot slot_quit = window.sig_window_close().connect(this, &App::on_window_close); // Connect a keyboard handler to on_key_up() CL_Slot slot_input_up = (window.get_ic().get_keyboard()).sig_key_up().connect(this, &App::on_input_up); // Get the graphic context CL_GraphicContext gc = window.get_gc(); CL_Texture texture_image(gc, "tux.png"); texture_image.set_wrap_mode(cl_wrap_repeat, cl_wrap_repeat, cl_wrap_repeat); texture_image.set_min_filter(cl_filter_linear); texture_image.set_mag_filter(cl_filter_linear); CL_ResourceManager resources("resources.xml"); CL_Sprite sprite(gc, "test", &resources); //sprite.set_linear_filter(true); CL_Font small_font = CL_Font(gc, "Tahoma", 12); float test_base_angle = 0.0f; float test_angle = 0.0f; float test_angle_pitch = 0.0f; float test_angle_yaw = 0.0f; float test_scale = 1.0f; bool test_scale_dir = false; // Run until someone presses escape while (!quit) { gc.clear(CL_Colorf(0.0f,0.0f,0.2f)); gc.set_map_mode(CL_MapMode(cl_map_2d_upper_left)); // CL_Draw::point() for (int xcnt=0; xcnt<8; xcnt++) { for (int ycnt=0; ycnt<6; ycnt++) { CL_Draw::point(gc, xcnt*2, ycnt*2, CL_Colorf(1.0f, 1.0f, 1.0f, 1.0f)); } } small_font.draw_text(gc, 32, 10, "8*6 Points (0 + 2x), (0 + 2y)"); // CL_Draw::line() for (int xcnt=0; xcnt<4; xcnt++) { for (int ycnt=0; ycnt<3; ycnt++) { const int offset_y = 16; const int line_length = 6; const int spacing = 8; CL_Draw::line(gc, xcnt*spacing, (ycnt*spacing) + offset_y, line_length + (xcnt*spacing), (line_length + (ycnt*spacing)) + offset_y, CL_Colorf(1.0f, 1.0f, 1.0f, 1.0f)); } } small_font.draw_text(gc, 48, 30, "4*3 Lines (0 + 8x), (32 + 8y), (6 + 8x), (38 + 8y)"); // CL_Draw::box() for (int xcnt=0; xcnt<4; xcnt++) { for (int ycnt=0; ycnt<3; ycnt++) { const int offset_y = 48; const int line_length = 6; const int spacing = 8; CL_Draw::box(gc, xcnt*spacing, (ycnt*spacing) + offset_y, line_length + (xcnt*spacing), (line_length + (ycnt*spacing)) + offset_y, CL_Colorf(1.0f, 1.0f, 1.0f, 1.0f)); } } small_font.draw_text(gc, 48, 66, "4*3 Box (0 + 8x), (32 + 8y), (6 + 8x), (38 + 8y)"); // CL_Draw::fill() for (int xcnt=0; xcnt<4; xcnt++) { for (int ycnt=0; ycnt<3; ycnt++) { const int offset_y = 80; const int line_length = 6; const int spacing = 8; CL_Draw::fill(gc, xcnt*spacing, (ycnt*spacing) + offset_y, line_length + (xcnt*spacing), (line_length + (ycnt*spacing)) + offset_y, CL_Colorf(1.0f, 1.0f, 1.0f, 1.0f)); } } small_font.draw_text(gc, 48, 90, "4*3 Fill (0 + 8x), (32 + 8y), (6 + 8x), (38 + 8y)"); // CL_Draw::gradient_fill() CL_Gradient gradient; gradient.top_left = CL_Colorf(1.0f, 1.0f, 1.0f, 1.0f); gradient.top_right = CL_Colorf(1.0f, 0.0f, 0.0f, 1.0f); gradient.bottom_left = CL_Colorf(0.0f, 0.0f, 1.0f, 1.0f); gradient.bottom_right = CL_Colorf(0.0f, 1.0f, 0.0f, 1.0f); for (int xcnt=0; xcnt<4; xcnt++) { for (int ycnt=0; ycnt<3; ycnt++) { const int offset_y = 110; const int line_length = 6; const int spacing = 8; CL_Draw::gradient_fill(gc, xcnt*spacing, (ycnt*spacing) + offset_y, line_length + (xcnt*spacing), (line_length + (ycnt*spacing)) + offset_y, gradient); } } small_font.draw_text(gc, 48, 115, "4*3 GradientFill (0 + 8x), (32 + 8y), (6 + 8x), (38 + 8y)"); small_font.draw_text(gc, 48, 125, "top left = white. top right = red"); small_font.draw_text(gc, 48, 135, "bottom left = blue. bottom right = green"); // CL_Draw::circle() { const int offset_y = 140; int radius = 5; CL_Draw::circle(gc, radius, offset_y + radius, radius, CL_Colorf(1.0f, 1.0f, 1.0f, 1.0f)); const int offset_x = 16; radius = 16; CL_Draw::circle(gc, offset_x + radius, offset_y + radius, radius, CL_Colorf(1.0f, 1.0f, 1.0f, 1.0f)); } small_font.draw_text(gc, 54, 149, "Circle (5, 145) Radius = 5"); small_font.draw_text(gc, 54, 159, "Circle (32, 156) Radius = 16"); // CL_Draw::gradient_circle() { CL_Gradient gradient; gradient.top_left = CL_Colorf(1.0f, 1.0f, 1.0f, 1.0f); gradient.top_right = CL_Colorf(0.0f, 0.0f, 0.0f, 1.0f); gradient.bottom_left = CL_Colorf(0.0f, 0.0f, 0.0f, 1.0f); gradient.bottom_right = CL_Colorf(1.0f, 0.0f, 0.0f, 1.0f); const int offset_y = 180; float radius = 17.0; float xpos = radius; float ypos = offset_y + radius; CL_Draw::gradient_circle(gc, CL_Pointf( xpos, ypos ), CL_Pointf(radius/2.0, 0.0f), radius, gradient); const int offset_x = 40; radius = 17.0; xpos = offset_x + radius; ypos = offset_y + radius; CL_Draw::gradient_circle(gc, CL_Pointf( xpos, ypos), CL_Pointf(0.0f, radius/2.0), radius, gradient); } small_font.draw_text(gc, 80, 189, "Gradient Circle (16, 196) Radius = 17. Gradient right"); small_font.draw_text(gc, 80, 199, "Gradient Circle (56, 196) Radius = 17. Gradient up"); small_font.draw_text(gc, 80, 209, "centre = white, outer = red"); // CL_Draw::triangle() { const float offset_y = 220.0f; const float size = 12.0f; CL_Draw::triangle(gc, CL_Pointf(0.0f, offset_y), CL_Pointf(0.0f, offset_y + size), CL_Pointf(size, offset_y + size), CL_Colorf(1.0f, 1.0f, 1.0f, 1.0f)); float offset_x = 16.0f; CL_Draw::triangle(gc, CL_Pointf(offset_x + 0.0f, offset_y + size), CL_Pointf(offset_x + size, offset_y + size), CL_Pointf(offset_x + 0.0f, offset_y), CL_Colorf(1.0f, 1.0f, 1.0f, 1.0f)); offset_x = 32.0f; CL_Draw::triangle(gc, CL_Pointf(offset_x + size, offset_y + size), CL_Pointf(offset_x + 0.0f, offset_y), CL_Pointf(offset_x + 0.0f, offset_y + size), CL_Colorf(1.0f, 1.0f, 1.0f, 1.0f)); } small_font.draw_text(gc, 48, 229, "3 Triangles (12 pixel size) (Left vertical edge)."); small_font.draw_text(gc, 48, 239, "Top Left: (0,220) (16,220) (32,220)"); // CL_Draw::texture() gc.set_texture(0, texture_image); { float offset_x = 0.0f; float offset_y = 250.0f; CL_Rectf src_rect(offset_x, offset_y, CL_Sizef(31, 47)); CL_Rectf texture_coords(0.0, 0.0, 1.0f, 1.0f); CL_Colorf color(1.0f, 1.0f, 1.0f, 1.0f); CL_Draw::texture(gc, src_rect, color, texture_coords); offset_x = 33.0f; src_rect = CL_Rectf(offset_x, offset_y, CL_Sizef(31, 47)); texture_coords = CL_Rectf(0.25f, 0.25f, 0.75f, 0.75f); color = CL_Colorf(1.0f, 0.0f, 0.0f, 1.0f); CL_Draw::texture(gc, src_rect, color, texture_coords); } gc.reset_texture(0); small_font.draw_text(gc, 76, 260, "Texture (0, 250) size=(31,47)"); small_font.draw_text(gc, 76, 275, "Texture (33, 250) size=(31,47) (red, magnify*2)"); // CL_RoundedRect { CL_RoundedRect roundedrect(CL_Sizef(64.0f, 32.0f), 15.0f); float offset_x = 0.0f; float offset_y = 300.0f; CL_Origin origin = origin_top_left; roundedrect.draw(gc, CL_Pointf(offset_x, offset_y), CL_Colorf(1.0f, 1.0f, 1.0f, 1.0f), origin); offset_y = 340.0f; roundedrect.fill(gc, CL_Pointf(offset_x, offset_y), CL_Colorf(1.0f, 1.0f, 1.0f, 1.0f), origin); offset_y = 380.0f; CL_Gradient gradient; gradient.top_left = CL_Colorf(1.0f, 1.0f, 1.0f, 1.0f); gradient.top_right = CL_Colorf(1.0f, 0.0f, 0.0f, 1.0f); gradient.bottom_left = CL_Colorf(0.0f, 0.0f, 1.0f, 1.0f); gradient.bottom_right = CL_Colorf(0.0f, 1.0f, 0.0f, 1.0f); roundedrect.fill(gc, CL_Pointf(offset_x, offset_y), gradient, origin); offset_y = 420.0f; roundedrect.set_control_point_bl(CL_Pointf(0.4f, 0.8f)); roundedrect.set_rounding_bottom_left(CL_Sizef(0.2f, 0.6f)); roundedrect.set_control_point_tl(CL_Pointf(0.2f, 0.4f)); roundedrect.set_rounding_top_left(CL_Sizef(0.4f, 0.2f)); roundedrect.set_control_point_tr(CL_Pointf(0.6f, 0.2f)); roundedrect.set_rounding_top_right(CL_Sizef(0.8f, 0.4f)); roundedrect.set_control_point_br(CL_Pointf(0.6f, 0.8f)); roundedrect.set_rounding_bottom_right(CL_Sizef(0.8f, 0.6f)); roundedrect.fill(gc, CL_Pointf(offset_x, offset_y), gradient, origin); } small_font.draw_text(gc, 76, 310, "RoundedRect - draw (0, 300) size=(64,32)"); small_font.draw_text(gc, 76, 325, "(RoundedRect - draw gradient - is not implemented)"); small_font.draw_text(gc, 76, 350, "RoundedRect - fill (0, 340) size=(64,32)"); small_font.draw_text(gc, 76, 390, "RoundedRect - fill gradient (0, 380) size=(64,32)"); small_font.draw_text(gc, 76, 400, "top left = white. top right = red"); small_font.draw_text(gc, 76, 410, "bottom left = blue. bottom right = green"); small_font.draw_text(gc, 76, 430, "RoundedRect - fill gradient (0, 420) size=(64,32)"); small_font.draw_text(gc, 76, 440, "Controling control / rounding points"); // CL_Sprite { test_base_angle+=5.0f; if (test_base_angle >= 360.0f) { test_base_angle = 0.0f; } #ifndef USE_SWRENDER clEnable(GL_MULTISAMPLE); #endif sprite.set_base_angle(CL_Angle(test_base_angle, cl_degrees)); sprite.draw(gc, 350, 20); sprite.set_base_angle(CL_Angle(0, cl_degrees)); #ifndef USE_SWRENDER clDisable(GL_MULTISAMPLE); #endif } small_font.draw_text(gc, 370, 20, "Sprite - Base angle"); small_font.draw_text(gc, 370, 35, "Multisampling enabled"); { test_angle+=5.0f; if (test_angle >= 360.0f) { test_angle = 0.0f; } sprite.set_angle(CL_Angle(test_angle, cl_degrees)); sprite.draw(gc, 350, 60); sprite.set_angle(CL_Angle(0, cl_degrees)); } small_font.draw_text(gc, 370, 60, "Sprite - Angle"); { test_angle_pitch+=5.0f; if (test_angle_pitch >= 360.0f) { test_angle_pitch = 0.0f; } sprite.set_angle_pitch(CL_Angle(test_angle_pitch, cl_degrees)); sprite.draw(gc, 350, 100); sprite.set_angle_pitch(CL_Angle(0, cl_degrees)); } small_font.draw_text(gc, 370, 100, "Sprite - Angle Pitch"); { test_angle_yaw+=5.0f; if (test_angle_yaw >= 360.0f) { test_angle_yaw = 0.0f; } sprite.set_angle_yaw(CL_Angle(test_angle_yaw, cl_degrees)); sprite.draw(gc, 350, 140); sprite.set_angle_yaw(CL_Angle(0, cl_degrees)); } small_font.draw_text(gc, 370, 140, "Sprite - Angle Yaw"); { if (test_scale_dir) { test_scale += 0.1f; if (test_scale >= 2.0f) { test_scale = 2.0f; test_scale_dir = false; } }else { test_scale -= 0.1f; if (test_scale <= -2.0f) { test_scale = -2.0f; test_scale_dir = true; } } sprite.set_scale(test_scale, 1.0f); sprite.draw(gc, 350, 180); sprite.set_scale(1.0f, test_scale); sprite.draw(gc, 390, 180); sprite.set_scale(1.0f, 1.0f); } small_font.draw_text(gc, 420, 180, "Sprite - Set Scale (x), (y)"); // Flip the display, showing on the screen what we have drawed // since last call to flip() window.flip(1); // This call processes user input and other events CL_KeepAlive::process(); } small_font = CL_Font(); } catch(CL_Exception& exception) { CL_Console::write_line("Exception caught:"); CL_Console::write_line(exception.message); // Display the stack trace (if available) std::vector<CL_String> stacktrace = exception.get_stack_trace(); int size = stacktrace.size(); if (size > 0) { CL_Console::write_line("Stack Trace:"); for (int cnt=0; cnt < size; cnt++) { CL_Console::write_line(stacktrace[cnt]); } } console.display_close_message(); return -1; } return 0; }
int main(int argc, char* argv[]) { /** 0 = executable's name * 1 = source file path * 2 = source file type * 3 = target file path * 4 = target file type * x = "-g" or "--gui" * y = "-v" or "--verbose" */ QStringList arguments; QStringList options; for (int i = 1; i < argc; i++) { QString argument(argv[i]); argument = argument.toLower(); if (argument.startsWith('-')) options << argument; else arguments << argument; } /** open the GUI if argument "-g" or "--gui" is given */ if ((bool)options.contains("-g") | (bool)options.contains("--gui")) { QApplication a(argc, argv); MainWindow w(arguments, options, 0); w.show(); return a.exec(); } else if (argc == 1) std::cerr << "usage: htmlatex INPUTFILE FORMAT INPUTDEFINITION OUTPUTFILE FORMAT OUTPUTDEFINITION [-g|--gui]\n" << " e.g. htmlatex index.html javadoc input_javadoc.xml manual.tex tex output_tex.xml -g\n" << "\t-g, --gui \tLaunch the GUI\n" << "\t-h, --help \tShow some examples\n" << "\t-v, --verbose \tVerbose mode\n" << "\t-lang=de, -lang=en \tSets the language to German or English\n\n" << "\tSee the \"README\" file for further information." << std::endl; else if (argc == 2) { if ((bool)options.contains("-h") | (bool)options.contains("--help")) { QString helpstring("Examples with GUI:\n\nopen file initially:\n\nhtmlatex index.html javadoc -g\nhtmlatex index.html --gui javadoc"); helpstring += "\n\nconvert file initially:\n\nhtmlatex -g index.html javadoc mytexoutput.tex tex\nhtmlatex index.html javadoc --gui mytexoutput.tex tex"; helpstring += "\n\nExample with console:\n\nconvert file:\n\nhtmlatex index.html javadoc mytexoutput.tex tex"; std::cerr << helpstring.toStdString() << std::endl; } } else { Settings settings; if ((bool)options.contains("-v") | (bool)options.contains("--verbose")) { settings.setValue("verbose", "1"); std::cerr << "verbose mode" << std::endl; } else settings.setValue("verbose", "0"); if ((bool)options.contains("-lang=de") | (bool)options.contains("-lang=en")) { if ((bool)options.contains("-lang=de")) settings.setValue("language", QString::number((int)QLocale::Germany)); else settings.setValue("language", QString::number((int)QLocale::C)); } QCoreApplication a(argc, argv); // Set translation environment for the application texts QLocale::Country language = (QLocale::Country)settings.getValue("language").toInt(); QTranslator translator; if (language == QLocale::Germany) { if(translator.load(QString("htmlatex_de.qm"))) std::cerr << "language set to German" << std::endl; } else { if (translator.load(QString("htmlatex_en.qm"))) std::cerr << "language set to English" << std::endl; } a.installTranslator(&translator); QTextCodec::setCodecForTr(QTextCodec::codecForName("utf8")); Console console(arguments, options); exit(0); return a.exec(); } };
void UIMachineWindow::closeEvent(QCloseEvent *pCloseEvent) { /* Always ignore close-event first: */ pCloseEvent->ignore(); /* Make sure machine is in one of the allowed states: */ if (!uisession()->isRunning() && !uisession()->isPaused() && !uisession()->isStuck()) return; /* If there is a close hook script defined: */ const QString strScript = gEDataManager->machineCloseHookScript(vboxGlobal().managedVMUuid()); if (!strScript.isEmpty()) { /* Execute asynchronously and leave: */ QProcess::startDetached(strScript, QStringList() << machine().GetId()); return; } /* Choose the close action: */ MachineCloseAction closeAction = MachineCloseAction_Invalid; /* If default close-action defined and not restricted: */ MachineCloseAction defaultCloseAction = uisession()->defaultCloseAction(); MachineCloseAction restrictedCloseActions = uisession()->restrictedCloseActions(); if ((defaultCloseAction != MachineCloseAction_Invalid) && !(restrictedCloseActions & defaultCloseAction)) { switch (defaultCloseAction) { /* If VM is stuck, and the default close-action is 'detach', 'save-state' or 'shutdown', * we should ask the user about what to do: */ case MachineCloseAction_Detach: case MachineCloseAction_SaveState: case MachineCloseAction_Shutdown: closeAction = uisession()->isStuck() ? MachineCloseAction_Invalid : defaultCloseAction; break; /* Otherwise we just use what we have: */ default: closeAction = defaultCloseAction; break; } } /* If the close-action still undefined: */ if (closeAction == MachineCloseAction_Invalid) { /* Prepare close-dialog: */ QWidget *pParentDlg = windowManager().realParentWindow(this); QPointer<UIVMCloseDialog> pCloseDlg = new UIVMCloseDialog(pParentDlg, machine(), console().GetGuestEnteredACPIMode(), restrictedCloseActions); /* Make sure close-dialog is valid: */ if (pCloseDlg->isValid()) { /* We are going to show close-dialog: */ bool fShowCloseDialog = true; /* Check if VM is paused or stuck: */ const bool fWasPaused = uisession()->isPaused(); const bool fIsStuck = uisession()->isStuck(); /* If VM is NOT paused and NOT stuck: */ if (!fWasPaused && !fIsStuck) { /* We should pause it first: */ const bool fIsPaused = uisession()->pause(); /* If we were unable to pause VM: */ if (!fIsPaused) { /* If that is NOT the separate VM process UI: */ if (!vboxGlobal().isSeparateProcess()) { /* We are not going to show close-dialog: */ fShowCloseDialog = false; } /* If that is the separate VM process UI: */ else { /* We are going to show close-dialog only * if headless frontend stopped/killed already: */ CMachine machine = uisession()->machine(); KMachineState machineState = machine.GetState(); fShowCloseDialog = !machine.isOk() || machineState == KMachineState_Null; } } } /* If we are going to show close-dialog: */ if (fShowCloseDialog) { /* Show close-dialog to let the user make the choice: */ windowManager().registerNewParent(pCloseDlg, pParentDlg); closeAction = static_cast<MachineCloseAction>(pCloseDlg->exec()); /* Make sure the dialog still valid: */ if (!pCloseDlg) return; /* If VM was not paused before but paused now, * we should resume it if user canceled dialog or chosen shutdown: */ if (!fWasPaused && uisession()->isPaused() && (closeAction == MachineCloseAction_Invalid || closeAction == MachineCloseAction_Detach || closeAction == MachineCloseAction_Shutdown)) { /* If we unable to resume VM, cancel closing: */ if (!uisession()->unpause()) closeAction = MachineCloseAction_Invalid; } } } else { /* Else user misconfigured .vbox file, we will reject closing UI: */ closeAction = MachineCloseAction_Invalid; } /* Cleanup close-dialog: */ delete pCloseDlg; } /* Depending on chosen result: */ switch (closeAction) { case MachineCloseAction_Detach: { /* Just close Runtime UI: */ machineLogic()->closeRuntimeUI(); break; } case MachineCloseAction_SaveState: { /* Save VM state: */ machineLogic()->saveState(); break; } case MachineCloseAction_Shutdown: { /* Shutdown VM: */ machineLogic()->shutdown(); break; } case MachineCloseAction_PowerOff: case MachineCloseAction_PowerOff_RestoringSnapshot: { /* Power VM off: */ machineLogic()->powerOff(closeAction == MachineCloseAction_PowerOff_RestoringSnapshot); break; } default: break; } }
EXPORT_C GSReplay(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow) { int renderer = -1; { char* start = lpszCmdLine; char* end = NULL; long n = strtol(lpszCmdLine, &end, 10); if(end > start) {renderer = n; lpszCmdLine = end;} } while(*lpszCmdLine == ' ') lpszCmdLine++; ::SetPriorityClass(::GetCurrentProcess(), HIGH_PRIORITY_CLASS); if(FILE* fp = fopen(lpszCmdLine, "rb")) { Console console("GSdx", true); GSinit(); uint8 regs[0x2000]; GSsetBaseMem(regs); s_vsync = !!theApp.GetConfig("vsync", 0); HWND hWnd = NULL; _GSopen((void**)&hWnd, "", renderer); uint32 crc; fread(&crc, 4, 1, fp); GSsetGameCRC(crc, 0); GSFreezeData fd; fread(&fd.size, 4, 1, fp); fd.data = new uint8[fd.size]; fread(fd.data, fd.size, 1, fp); GSfreeze(FREEZE_LOAD, &fd); delete [] fd.data; fread(regs, 0x2000, 1, fp); long start = ftell(fp); GSvsync(1); struct Packet {uint8 type, param; uint32 size, addr; vector<uint8> buff;}; list<Packet*> packets; vector<uint8> buff; int type; while((type = fgetc(fp)) != EOF) { Packet* p = new Packet(); p->type = (uint8)type; switch(type) { case 0: p->param = (uint8)fgetc(fp); fread(&p->size, 4, 1, fp); switch(p->param) { case 0: p->buff.resize(0x4000); p->addr = 0x4000 - p->size; fread(&p->buff[p->addr], p->size, 1, fp); break; case 1: case 2: case 3: p->buff.resize(p->size); fread(&p->buff[0], p->size, 1, fp); break; } break; case 1: p->param = (uint8)fgetc(fp); break; case 2: fread(&p->size, 4, 1, fp); break; case 3: p->buff.resize(0x2000); fread(&p->buff[0], 0x2000, 1, fp); break; } packets.push_back(p); } Sleep(100); while(IsWindowVisible(hWnd)) { for(list<Packet*>::iterator i = packets.begin(); i != packets.end(); i++) { Packet* p = *i; switch(p->type) { case 0: switch(p->param) { case 0: GSgifTransfer1(&p->buff[0], p->addr); break; case 1: GSgifTransfer2(&p->buff[0], p->size / 16); break; case 2: GSgifTransfer3(&p->buff[0], p->size / 16); break; case 3: GSgifTransfer(&p->buff[0], p->size / 16); break; } break; case 1: GSvsync(p->param); break; case 2: if(buff.size() < p->size) buff.resize(p->size); GSreadFIFO2(&buff[0], p->size / 16); break; case 3: memcpy(regs, &p->buff[0], 0x2000); break; } } } for(list<Packet*>::iterator i = packets.begin(); i != packets.end(); i++) { delete *i; } packets.clear(); Sleep(100); /* vector<uint8> buff; bool exit = false; int round = 0; while(!exit) { uint32 index; uint32 size; uint32 addr; int pos; switch(fgetc(fp)) { case EOF: fseek(fp, start, 0); exit = !IsWindowVisible(hWnd); //exit = ++round == 60; break; case 0: index = fgetc(fp); fread(&size, 4, 1, fp); switch(index) { case 0: if(buff.size() < 0x4000) buff.resize(0x4000); addr = 0x4000 - size; fread(&buff[addr], size, 1, fp); GSgifTransfer1(&buff[0], addr); break; case 1: if(buff.size() < size) buff.resize(size); fread(&buff[0], size, 1, fp); GSgifTransfer2(&buff[0], size / 16); break; case 2: if(buff.size() < size) buff.resize(size); fread(&buff[0], size, 1, fp); GSgifTransfer3(&buff[0], size / 16); break; case 3: if(buff.size() < size) buff.resize(size); fread(&buff[0], size, 1, fp); GSgifTransfer(&buff[0], size / 16); break; } break; case 1: GSvsync(fgetc(fp)); exit = !IsWindowVisible(hWnd); break; case 2: fread(&size, 4, 1, fp); if(buff.size() < size) buff.resize(size); GSreadFIFO2(&buff[0], size / 16); break; case 3: fread(regs, 0x2000, 1, fp); break; } } */ GSclose(); GSshutdown(); fclose(fp); } }
void GameEngine::set_skin(std::string skin) { CommonResources* p_resources = common_resources_get_instance(); _p_loading_screen = my_new LoadingScreen(_window); _p_loading_screen -> init(); _p_loading_screen -> set_progression(0.0f); Preferences* p_pref = pref_get_instance(); std::string old_skin = p_pref -> skin; CL_GraphicContext& gc = _window.get_gc(); try { p_pref -> skin = skin; if (!_running) return; { p_resources -> load_gfx(gc, p_pref -> skin); _p_loading_screen -> set_progression(1.0f / 10.0f); } if (!_running) return; { _title_state.load_gfx(gc, p_pref -> skin); _p_loading_screen -> set_progression(2.0f / 10.0f); } if (!_running) return; { _common_state.load_gfx(gc, p_pref -> skin); _p_loading_screen -> set_progression(3.0f / 10.0f); } if (!_running) return; { _ingame_state.load_gfx(gc, p_pref -> skin); _p_loading_screen -> set_progression(4.0f / 10.0f); } if (!_running) return; { _gameover_state.load_gfx(gc, p_pref -> skin); _p_loading_screen -> set_progression(5.0f / 10.0f); } if (!_running) return; { _pausemenu_state.load_gfx(gc, p_pref -> skin); _p_loading_screen -> set_progression(6.0f / 10.0f); } if (!_running) return; { _skinsmenu_state.load_gfx(gc, p_pref -> skin); _p_loading_screen -> set_progression(7.0f / 10.0f); } if (!_running) return; { _optionsmenu_state.load_gfx(gc, p_pref -> skin); _p_loading_screen -> set_progression(8.0f / 10.0f); } if (!_running) return; { _title_state.load_gfx(gc, p_pref -> skin); _p_loading_screen -> set_progression(9.0f / 10.0f); } if (!_running) return; { _quitmenu_state.load_gfx(gc, p_pref -> skin); _p_loading_screen -> set_progression(10.0f / 10.0f); } p_pref -> write(); } catch (CL_Exception& err) { CL_ConsoleWindow console("OpenAlchemist Console", 80, 300); CL_Console::write_line("Skin error : " + err.message); CL_Console::write_line("Error in : " + skin); if (old_skin.compare(skin)) { CL_Console::write_line(""); CL_Console::write_line("Now loading default skin."); skin = get_skins_path() + get_path_separator() + "aqua.zip"; CL_Console::write_line(skin); console.display_close_message(); set_skin(skin); } else { throw err; } } my_delete(_p_loading_screen); _p_loading_screen = NULL; }
EXPORT_C GSBenchmark(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow) { ::SetPriorityClass(::GetCurrentProcess(), HIGH_PRIORITY_CLASS); Console console("GSdx", true); if(1) { GSLocalMemory* mem = new GSLocalMemory(); static struct {int psm; const char* name;} s_format[] = { {PSM_PSMCT32, "32"}, {PSM_PSMCT24, "24"}, {PSM_PSMCT16, "16"}, {PSM_PSMCT16S, "16S"}, {PSM_PSMT8, "8"}, {PSM_PSMT4, "4"}, {PSM_PSMT8H, "8H"}, {PSM_PSMT4HL, "4HL"}, {PSM_PSMT4HH, "4HH"}, {PSM_PSMZ32, "32Z"}, {PSM_PSMZ24, "24Z"}, {PSM_PSMZ16, "16Z"}, {PSM_PSMZ16S, "16ZS"}, }; uint8* ptr = (uint8*)_aligned_malloc(1024 * 1024 * 4, 32); for(int i = 0; i < 1024 * 1024 * 4; i++) ptr[i] = (uint8)i; // for(int tbw = 5; tbw <= 10; tbw++) { int n = 256 << ((10 - tbw) * 2); int w = 1 << tbw; int h = 1 << tbw; printf("%d x %d\n\n", w, h); for(size_t i = 0; i < countof(s_format); i++) { const GSLocalMemory::psm_t& psm = GSLocalMemory::m_psm[s_format[i].psm]; GSLocalMemory::writeImage wi = psm.wi; GSLocalMemory::readImage ri = psm.ri; GSLocalMemory::readTexture rtx = psm.rtx; GSLocalMemory::readTexture rtxP = psm.rtxP; GIFRegBITBLTBUF BITBLTBUF; BITBLTBUF.SBP = 0; BITBLTBUF.SBW = w / 64; BITBLTBUF.SPSM = s_format[i].psm; BITBLTBUF.DBP = 0; BITBLTBUF.DBW = w / 64; BITBLTBUF.DPSM = s_format[i].psm; GIFRegTRXPOS TRXPOS; TRXPOS.SSAX = 0; TRXPOS.SSAY = 0; TRXPOS.DSAX = 0; TRXPOS.DSAY = 0; GIFRegTRXREG TRXREG; TRXREG.RRW = w; TRXREG.RRH = h; GSVector4i r(0, 0, w, h); GIFRegTEX0 TEX0; TEX0.TBP0 = 0; TEX0.TBW = w / 64; GIFRegTEXA TEXA; TEXA.TA0 = 0; TEXA.TA1 = 0x80; TEXA.AEM = 0; int trlen = w * h * psm.trbpp / 8; int len = w * h * psm.bpp / 8; clock_t start, end; printf("[%4s] ", s_format[i].name); start = clock(); for(int j = 0; j < n; j++) { int x = 0; int y = 0; (mem->*wi)(x, y, ptr, trlen, BITBLTBUF, TRXPOS, TRXREG); } end = clock(); printf("%6d %6d | ", (int)((float)trlen * n / (end - start) / 1000), (int)((float)(w * h) * n / (end - start) / 1000)); start = clock(); for(int j = 0; j < n; j++) { int x = 0; int y = 0; (mem->*ri)(x, y, ptr, trlen, BITBLTBUF, TRXPOS, TRXREG); } end = clock(); printf("%6d %6d | ", (int)((float)trlen * n / (end - start) / 1000), (int)((float)(w * h) * n / (end - start) / 1000)); const GSOffset* off = mem->GetOffset(TEX0.TBP0, TEX0.TBW, TEX0.PSM); start = clock(); for(int j = 0; j < n; j++) { (mem->*rtx)(off, r, ptr, w * 4, TEXA); } end = clock(); printf("%6d %6d ", (int)((float)len * n / (end - start) / 1000), (int)((float)(w * h) * n / (end - start) / 1000)); if(psm.pal > 0) { start = clock(); for(int j = 0; j < n; j++) { (mem->*rtxP)(off, r, ptr, w, TEXA); } end = clock(); printf("| %6d %6d ", (int)((float)len * n / (end - start) / 1000), (int)((float)(w * h) * n / (end - start) / 1000)); } printf("\n"); } printf("\n"); } _aligned_free(ptr); delete mem; } // if(0) { GSLocalMemory* mem = new GSLocalMemory(); uint8* ptr = (uint8*)_aligned_malloc(1024 * 1024 * 4, 32); for(int i = 0; i < 1024 * 1024 * 4; i++) ptr[i] = (uint8)i; const GSLocalMemory::psm_t& psm = GSLocalMemory::m_psm[PSM_PSMCT32]; GSLocalMemory::writeImage wi = psm.wi; GIFRegBITBLTBUF BITBLTBUF; BITBLTBUF.DBP = 0; BITBLTBUF.DBW = 32; BITBLTBUF.DPSM = PSM_PSMCT32; GIFRegTRXPOS TRXPOS; TRXPOS.DSAX = 0; TRXPOS.DSAY = 1; GIFRegTRXREG TRXREG; TRXREG.RRW = 256; TRXREG.RRH = 256; int trlen = 256 * 256 * psm.trbpp / 8; int x = 0; int y = 0; (mem->*wi)(x, y, ptr, trlen, BITBLTBUF, TRXPOS, TRXREG); delete mem; } // PostQuitMessage(0); }
// The start of the Application int App::start(const std::vector<CL_String> &args) { quit = false; // Create a console window for text-output if not available CL_ConsoleWindow console("Console"); try { CL_DisplayWindow window("ClanLib Font Sprite Test", 1024, 480); // Connect the Window close event CL_Slot slot_quit = window.sig_window_close().connect(this, &App::on_window_close); // Connect a keyboard handler to on_key_up() CL_Slot slot_input_up = (window.get_ic().get_keyboard()).sig_key_up().connect(this, &App::on_input_up); // Get the graphic context CL_GraphicContext gc = window.get_gc(); // Load some fonts from the resource file CL_ResourceManager resources("font.xml"); CL_Font_Sprite font1(gc, "Font1", &resources); CL_Font_Sprite font2(gc, "Font2", &resources); // Run until someone presses escape while (!quit) { gc.set_map_mode(CL_MapMode(cl_map_2d_upper_left)); gc.clear(CL_Colorf::red); font1.draw_text(gc, 25, 25, "ClanLib: Phear the Power!"); font2.draw_text(gc, 3, 155, "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzÆæØøÅå0123456789[]()!#$&%/\\=-+~'`\".,:;*?"); font2.draw_text(gc, 10.0f, 200.0f, 2.0f, 2.0f, "Hello World\nMy Message"); // Flip the display, showing on the screen what we have drawed // since last call to flip() window.flip(1); // This call processes user input and other events CL_KeepAlive::process(); } } catch(CL_Exception& exception) { CL_Console::write_line("Exception caught:"); CL_Console::write_line(exception.message); // Display the stack trace (if available) std::vector<CL_String> stacktrace = exception.get_stack_trace(); int size = stacktrace.size(); if (size > 0) { CL_Console::write_line("Stack Trace:"); for (int cnt=0; cnt < size; cnt++) { CL_Console::write_line(stacktrace[cnt]); } } console.display_close_message(); return -1; } return 0; }
// The start of the Application int App::start(const std::vector<std::string> &args) { try { DisplayWindowDescription win_desc; win_desc.set_allow_resize(true); win_desc.set_title("HDR Example"); win_desc.set_size(Size( 600, 630 ), false); DisplayWindow window(win_desc); Slot slot_quit = window.sig_window_close().connect(this, &App::on_window_close); Slot slot_input_up = (window.get_ic().get_keyboard()).sig_key_up().connect(this, &App::on_input_up); GraphicContext gc = window.get_gc(); // Load and link shaders ProgramObject shader = ProgramObject::load(gc, "Resources/vertex_shader.glsl", "Resources/fragment_shader.glsl"); shader.bind_attribute_location(0, "Position"); shader.bind_attribute_location(2, "TexCoord0"); if (!shader.link()) throw Exception("Unable to link shader program: Error:" + shader.get_info_log()); const float dynamic_range_start = -1.5f; const float dynamic_range_end = 1.5f; const Size image_size(gc.get_width() - 64, 128); Texture image_rgb32f = create_rgb32f(gc, image_size, dynamic_range_start, dynamic_range_end); Font font(gc, "Tahoma", 20); clan::ubyte64 time_last = System::get_time(); bool direction = false; while (!quit) { clan::ubyte64 time_now = System::get_time(); time_delta = ((float) time_now - time_last) / 1000.0f; time_last = time_now; if (direction) { color_offset.r += time_delta * 1.0f; if (color_offset.r > 2.0f) { color_offset.r = 2.0f; direction = false; } } else { color_offset.r -= time_delta * 1.0f; if (color_offset.r < -2.0f) { color_offset.r = -2.0f; direction = true; } } color_offset.g = color_offset.r; color_offset.b = color_offset.r; gc.clear(Colorf(0.2f,0.2f,0.5f)); font.draw_text(gc, 32, 50, "Showing Texture RGB values from " + StringHelp::float_to_text(dynamic_range_start) + " to " + StringHelp::float_to_text(dynamic_range_end)); draw_image(gc, image_rgb32f, 32.0f, 100.0f, shader, Vec4f(0.0f, 0.0f, 0.0f, 0.0f)); font.draw_text(gc, 32, 350, "Showing Texture with an offset to the floating point color component"); draw_image(gc, image_rgb32f, 32.0f, 400.0f, shader, color_offset); KeepAlive::process(0); window.flip(1); } } catch(Exception &exception) { // Create a console window for text-output if not available ConsoleWindow console("Console", 80, 160); Console::write_line("Exception caught: " + exception.get_message_and_stack_trace()); console.display_close_message(); return -1; } return 0; }
bool VideoPanel::load(int layer, String source){ //VideoSource while(layer>layers.size()){ layers.pushBack(""); } if(source==""){ layers[layer-1]=""; return true; } layers[layer-1]=source; if(source.substr(0,7)=="camera:"){ VideoSource* vs; if(!remap.find(source)){ remap[source]=new VideoSource; vs=remap[source]; }else{ return true; } short driver=0; if(source.substr(7,-1)=="1"){ driver=0; }else if(source.substr(7,-1)=="2"){ driver=1; } #ifdef VID_SOFTWARE_RESIZE vs->powerOf2=true; #endif if(!vs->sourceCapture(driver)){ console().write("error, could not access camera"); return false; }else{ //console().write("successfully connected to camera"); } glGenTextures(1, (GLuint*)&vs->texid); glBindTexture(GL_TEXTURE_2D,vs->texid); vs->getFrame(); #ifdef VID_SOFTWARE_RESIZE glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, vs->widthp2,vs->heightp2, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, blank); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // Linear Filtered glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); #else gluBuild2DMipmaps(GL_TEXTURE_2D, 3, vs->width,vs->height, GL_BGR_EXT , GL_UNSIGNED_BYTE, vs->data); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); #endif glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT); }else if(source.substr(0,5)=="file:"){ VideoSource* vs; if(!remap.find(source)){ vs=new VideoSource; remap[source]=vs; }else{ return true; } #ifdef VID_SOFTWARE_RESIZE vs->powerOf2=true; #endif String x=source.substr(5,-1); if( !vs->sourceAvi(x.c_str()) ){ console().write("error loading video"); return false; }else{ //console().write("video loaded successfully"); } glGenTextures(1, (GLuint*)&vs->texid); glBindTexture(GL_TEXTURE_2D,vs->texid); vs->getFrame(); #ifdef VID_SOFTWARE_RESIZE glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, vs->widthp2,vs->heightp2, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, blank); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // Linear Filtered glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); #else gluBuild2DMipmaps(GL_TEXTURE_2D, 3, remap[source]->width, remap[source]->height, GL_BGR_EXT , GL_UNSIGNED_BYTE, remap[source]->data); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); #endif glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT); }else if(source.substr(0,8)=="picture:"){ String file=source.substr(8,-1); int g=texture.load(file); ImageData im=texture.info(g); if(g!=-1){ remapPictures[source]=g; console().write("picture '"+file+"', loaded successfully"); }else{ console().write("Error loading file '"+file+"', "+im.error); return false; } }else{ console().write("error, unknown video source type '"+source+"', should be file:, picture: or camera:"); return false; } return true; }
bool AppImplMswRendererGl::initializeInternal( HWND wnd, HDC dc ) { int pixelFormat; mWnd = wnd; mDC = dc; static PIXELFORMATDESCRIPTOR pfd = // pfd Tells Windows How We Want Things To Be { sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor 1, // Version Number PFD_DRAW_TO_WINDOW | // Format Must Support Window PFD_SUPPORT_OPENGL | // Format Must Support OpenGL PFD_DOUBLEBUFFER, // Must Support Double Buffering PFD_TYPE_RGBA, // Request An RGBA Format 32, // Select Our Color Depth 0, 0, 0, 0, 0, 0, // Color Bits Ignored 0, // No Alpha Buffer 0, // Shift Bit Ignored 0, // No Accumulation Buffer 0, 0, 0, 0, // Accumulation Bits Ignored 16, // 32Bit Z-Buffer (Depth Buffer) 0, // No Stencil Buffer 0, // No Auxiliary Buffer PFD_MAIN_PLANE, // Main Drawing Layer 0, // Reserved 0, 0, 0 // Layer Masks Ignored }; /* Our first pass, Multisampling hasn't been created yet, so we create a window normally If it is supported, then we're on our second pass that means we want to use our pixel format for sampling so set PixelFormat to arbMultiSampleformat instead */ if( ! sMultisampleSupported ) { pixelFormat = ::ChoosePixelFormat( dc, &pfd ); // Find A Compatible Pixel Format if( pixelFormat == 0 ) { // Did We Find A Compatible Format? return false; } } else { pixelFormat = sArbMultisampleFormat; } if( ! ::SetPixelFormat( dc, pixelFormat, &pfd ) ) { // Are We Able To Set The Pixel Format? return false; } if( ! ( mRC = ::wglCreateContext( dc ) ) ) { // Are We Able To Get A Rendering Context? return false; } if( ! ::wglMakeCurrent( dc, mRC ) ){ // Try To Activate The Rendering Context return false; } if (glewInit() != GLEW_OK) { console() << "GLEW failes to init." << std::endl; return false; } if( ( ! sMultisampleSupported ) && ( mRenderer->getAntiAliasing() > RendererGl::AA_NONE ) ) { int level = initMultisample( pfd, mRenderer->getAntiAliasing(), dc ); mRenderer->setAntiAliasing( RendererGl::AA_NONE + level ); if( level > 0 ) { // kill the current context and relaunch ::wglMakeCurrent( NULL, NULL ); ::wglDeleteContext( mRC ); return true; // our caller will run us again } } if( mPrevRC ) { BOOL success = ::wglCopyContext( mPrevRC, mRC, GL_ALL_ATTRIB_BITS ); } if( mPrevRC ) { wglShareLists( mPrevRC, mRC ); } return true; // Success }
int Application::main(const std::vector<CL_String> &args) { try { #ifdef DEBUG // Crea una ventan en consola para la salida de texto si no está disponible CL_ConsoleWindow console("JATG", 80, 1000); // 1000 permite una barra vertical CL_ConsoleLogger logger; #endif // Crea la ventana CL_DisplayWindowDescription desc; desc.set_title("JATG"); desc.set_size(CL_Size(1024,768), true); // Usa esta resolución desc.set_fullscreen(true); desc.set_decorations(false); CL_DisplayWindow window(desc); CL_GraphicContext gc = window.get_gc(); CL_Mat4f matrix = CL_Mat4f::scale( (float) gc.get_width() / 1024.0f, (float) gc.get_height() / 768.0f, 1.0f); gc.set_modelview(matrix); CL_SoundOutput output(44100); //Inicializa Frecuencia // Crea el mundo Mundo mundo(window); // Corre el bucle del juego mundo.gameloop(); } catch (CL_Exception& exception) { CL_Console::write_line("Excepcion Tomada:"); CL_Console::write_line(exception.message); std::vector<CL_String> stacktrace = exception.get_stack_trace(); int tamaño = stacktrace.size(); if (tamaño > 0) { CL_Console::write_line("Stack Trace:"); for (int i=0; i < tamaño; i++) { CL_Console::write_line(stacktrace[i]); } } CL_Console::wait_for_key(); //Espera por una tecla } return 0; }
bool Level::loadObj(Path file){ if(!os().fileExists(file)){ console().write("obj file '"+file.getAbsolute()+"' not found"); #ifdef DEVELOPER #endif return false; } std::ifstream in; in.open(file.getAbsolute().c_str(),std::ios::in); std::string line; String s; ObjectAddress obj; obj.type=NULLOBJECT; Array<FloatVector3d> ivertices; Array<FloatVector3d> inor; Array<FloatVector2d> iuv; int vertexcnt=0; int lnnum=0; while(getline(in, line)){ lnnum++; s=line; if(s.substrIndex(0,2)=="g " || s.substrIndex(0,2)=="o "){ if(obj.type!=NULLOBJECT){ obj.object->setVertexCount(vertexcnt); obj.object->getVertexRaw(0).end=START_TRI; obj.object->getVertexRaw(vertexcnt-1).end=END_TRI; } vertexcnt=0; String name=s.substrIndex(2,s.size()); obj=level->add(name,"polymesh"); if(obj.type==NULLOBJECT){ console().write("error, coulden't open obj because object '"+name+"' already exists"); return false; } obj.object->material=0; obj.object->visible=true; defaultMaterial(); }else if(s.substrIndex(0,2)=="v "){ if(obj.type==NULLOBJECT){createObjDefaultObj(&obj);} float x,y,z; sscanf(s.c_str(),"v %f %f %f",&x,&y,&z); ivertices.pushBack(FloatVector3d(x,y,z)); }else if(s.substrIndex(0,3)=="vn "){ if(obj.type==NULLOBJECT){createObjDefaultObj(&obj);} float x,y,z; sscanf(s.c_str(),"vn %f %f %f",&x,&y,&z); inor.pushBack(FloatVector3d(x,y,z)); }else if(s.substrIndex(0,3)=="vt "){ if(obj.type==NULLOBJECT){createObjDefaultObj(&obj);} float x,y,z; sscanf(s.c_str(),"vt %f %f %f",&x,&y,&z); iuv.pushBack(FloatVector2d(x,y)); }else if(s.substrIndex(0,2)=="f "){ if(obj.type==NULLOBJECT){createObjDefaultObj(&obj);} String sub=s.substrIndex(2,s.size()); Array<String> fc=sub.explode(" "); if(fc.size()==3 || fc.size()==4){ int iter=1; if(fc.size()==4){iter=2;} for(int j=0; j<iter; j++){ for(int i=0; i<3; i++){ int realIndex=i; if(j==1){ if(i==1){ realIndex=2; }else if(i==2){ realIndex=3; } } Array<String> f1=fc[realIndex].explode("/"); if(f1.size()==1){ Vertex v; if(f1[0]!=""){ int ind=-1; sscanf(f1[0].c_str(),"%d",&ind); v.pos=ivertices[ind-1]; } vertexcnt++; obj.object->addVertex(v); obj.object->getVertexRaw(vertexcnt-1).end=0; }else if(f1.size()==3){ Vertex v; if(f1[0]!=""){ int ind=-1; sscanf(f1[0].c_str(),"%d",&ind); v.pos=ivertices[ind-1]; } if(f1[1]!=""){ int ind=-1; sscanf(f1[1].c_str(),"%d",&ind); v.uvLightmap=iuv[ind-1]; v.uv0=iuv[ind-1]; v.uv1=iuv[ind-1]; v.uv2=iuv[ind-1]; v.uv3=iuv[ind-1]; v.uv4=iuv[ind-1]; v.uv5=iuv[ind-1]; v.uv6=iuv[ind-1]; } if(f1[2]!=""){ int ind=-1; sscanf(f1[2].c_str(),"%d",&ind); v.normal=inor[ind-1]; } vertexcnt++; obj.object->addVertex(v); obj.object->getVertexRaw(vertexcnt-1).end=0; }else{ console().write("face dropped, incorrect index size, should only include vertex,uv, and normal indices"); } } } }else{ console().write("Error: non-triangle polygon, has "+String(fc.size())+" sides"); return false; } }else if(s.substrIndex(0,7)=="mtllib "){ }else if(s.substrIndex(0,7)=="usemtl "){ }else if(s.substrIndex(0,2)=="s "){ }else if(s.substrIndex(0,1)=="#"){ }else{ console().write("unknown .obj file content line "+String(lnnum)); return false; } } if(obj.type!=NULLOBJECT){ obj.object->setVertexCount(vertexcnt); obj.object->getVertexRaw(0).end=START_TRI; obj.object->getVertexRaw(vertexcnt-1).end=END_TRI; } in.close(); return true; }
/** * Log incomming OSC msgs * Taken from OSCListener example provided with the Cinder OSC block */ void OSCController::__logMessage( osc::Message msg ) { if( displayMsgLog ){ console() << "Incomming OSC msg: @ " << getId() << std::endl; console() << "Address: " << msg.getAddress() << std::endl; if( displayMsgExtended ){ console() << "Num Arg: " << msg.getNumArgs() << std::endl; for (int i = 0; i < msg.getNumArgs(); i++) { console() << "-- Argument " << i << std::endl; console() << "---- type: " << msg.getArgTypeName(i) << std::endl; if (msg.getArgType(i) == osc::TYPE_INT32){ try { console() << "------ value: "<< msg.getArgAsInt32(i) << std::endl; } catch (...) { console() << "Exception reading argument as int32" << std::endl; } }else if (msg.getArgType(i) == osc::TYPE_FLOAT){ try { console() << "------ value: " << msg.getArgAsFloat(i) << std::endl; } catch (...) { console() << "Exception reading argument as float" << std::endl; } }else if (msg.getArgType(i) == osc::TYPE_STRING){ try { console() << "------ value: " << msg.getArgAsString(i).c_str() << std::endl; } catch (...) { console() << "Exception reading argument as string" << std::endl; } } } } } }
int TestApp::main(const std::vector<std::string> &args) { quit = false; // Create a console window for text-output if not available ConsoleWindow console("Console", 80, 200); try { DisplayWindowDescription desc; desc.set_title("Image clipboard test"); desc.set_size(Size(800,600), true); DisplayWindow window(desc); // Connect the Window close event Slot slot_quit = window.sig_window_close().connect(this, &TestApp::on_window_close); // Connect a keyboard handler to on_key_up() Slot slot_input_up = (window.get_ic().get_keyboard()).sig_key_up().connect(this, &TestApp::on_input_up); //Create the Canvas Canvas canvas(window); //Set the reference to GraphicContext GraphicContext &gc = canvas.get_gc(); PixelBuffer to_clipboard = ImageProviderFactory::load("copy.png"); window.set_clipboard_image(to_clipboard); /* while (!window.get_ic().get_keyboard().get_keycode(KEY_ESCAPE)) { window.get_gc().clear(Colorf::gray70); window.flip(); KeepAlive::process(); System::sleep(50); }*/ /* // Save to file PNGProvider::save(to_clipboard, "copy2.png"); // Save to IODevice_Memory memory buffer DataBuffer data(1024*8); // 8 kb IODevice_Memory mem(data); PNGProvider::save(to_clipboard, mem); File file("copy3.png", File::create_always); DataBuffer mem_data = mem.get_data(); file.write(mem_data.get_data(), mem_data.get_size()); */ PixelBuffer from_clipboard; if (window.is_clipboard_image_available()) { from_clipboard = window.get_clipboard_image(); PNGProvider::save(from_clipboard, "from_clipboard.png"); } if (!from_clipboard.is_null()) { Texture2D texture_image(gc, from_clipboard.get_width(), from_clipboard.get_height(), from_clipboard.get_format()); texture_image.set_image(gc,from_clipboard); texture_image.set_min_filter(filter_linear); texture_image.set_mag_filter(filter_linear); Image image(texture_image,texture_image.get_size()); while (!quit) { canvas.clear(Colorf(0.0f,0.0f,0.2f)); canvas.set_map_mode(MapMode(map_2d_upper_left)); image.draw(canvas,0,0); // Flip the display, showing on the screen what we have drawed // since last call to flip() window.flip(1); // This call processes user input and other events KeepAlive::process(); } } } catch(Exception error) { Console::write_line("Exception caught:"); Console::write_line(error.message); console.display_close_message(); return -1; } return 0; }
void Device::error( long hr ) { if ( !mVerbose ) { return; } switch ( hr ) { case E_POINTER: console() << "Bad pointer."; break; case E_INVALIDARG: console() << "Invalid argument."; break; case E_NUI_DEVICE_NOT_READY: console() << "Device not ready."; break; case E_NUI_FEATURE_NOT_INITIALIZED: console() << "Feature not initialized."; break; case E_NUI_NOTCONNECTED: console() << "Unable to connect to device."; break; case E_FAIL: console() << "Attempt failed."; break; case E_NUI_IMAGE_STREAM_IN_USE: console() << "Image stream already in use."; break; case E_NUI_FRAME_NO_DATA: console() << "No frame data available"; break; case E_OUTOFMEMORY: console() << "Out of memory (maximum number of Kinect devices may have been reached)."; break; case ERROR_TOO_MANY_CMDS: console() << "Too many commands sent. Angle change requests must be made at least 1.5s apart."; break; case ERROR_RETRY: console() << "Device is busy. Retry in a moment."; break; case S_FALSE: console() << "Data not available."; case S_OK: break; default: console() << "Unknown error (Code " + toString( hr ) + ")"; } console() << endl; }
void VideoTable::selectButtonHandler(){ console() << "select button handler" << endl; }
void Device::run() { HANDLE events[ 4 ]; events[ 0 ] = mColorEvent; events[ 1 ] = mDepthEvent; events[ 2 ] = mSkeletonEvent; while ( mCapture ) { if ( mSensor != 0 ) { double time = getElapsedSeconds(); WaitForMultipleObjects( sizeof( events ) / sizeof( events[ 0 ]), events, 0, WAIT_TIME ); const NUI_IMAGE_FRAME* frameColor = 0; const NUI_IMAGE_FRAME* frameDepth = 0; NUI_SKELETON_FRAME frameSkeleton = { 0 }; bool readColor = !mNewColorSurface; bool readDepth = !mNewDepthSurface; bool readSkeleton = !mNewSkeletons; /*if ( mDeviceOptions.isFrameSyncEnabled() && mDeviceOptions.isColorEnabled() && mDeviceOptions.isDepthEnabled() ) { if ( readColor != readDepth ) { readColor = false; readDepth = false; } readSkeleton = readDepth; }*/ readColor = readColor && mDeviceOptions.isColorEnabled(); readDepth = readDepth && mDeviceOptions.isDepthEnabled(); readSkeleton = readSkeleton && mDeviceOptions.isSkeletonTrackingEnabled(); ////////////////////////////////////////////////////////////////////////////////////////////// if ( readDepth && WAIT_OBJECT_0 == WaitForSingleObject( mDepthEvent, 0 ) ) { if ( SUCCEEDED( NuiImageStreamGetNextFrame( mDepthStreamHandle, 0, &frameDepth ) ) && frameDepth != 0 && frameDepth->pFrameTexture != 0 ) { mDepthTimeStamp = frameDepth->liTimeStamp.QuadPart; INuiFrameTexture* texture = frameDepth->pFrameTexture; _NUI_LOCKED_RECT lockedRect; long hr = texture->LockRect( 0, &lockedRect, 0, 0 ); if ( FAILED( hr ) ) { error( hr ); } if ( lockedRect.Pitch == 0 ) { console() << "Invalid buffer length received" << endl; } else { pixelToDepthSurface( (uint16_t*)lockedRect.pBits ); } hr = NuiImageStreamReleaseFrame( mDepthStreamHandle, frameDepth ); if ( FAILED( hr ) ) { error( hr ); } mUserCount = 0; for ( uint32_t i = 0; i < NUI_SKELETON_COUNT; ++i ) { if ( mActiveUsers[ i ] ) { ++mUserCount; } } mNewDepthSurface = true; } } ////////////////////////////////////////////////////////////////////////////////////////////// if ( readColor && WAIT_OBJECT_0 == WaitForSingleObject( mColorEvent, 0 ) ) { if ( SUCCEEDED( NuiImageStreamGetNextFrame( mColorStreamHandle, 0, &frameColor ) ) && frameColor != 0 && frameColor->pFrameTexture != 0 ) { INuiFrameTexture* texture = frameColor->pFrameTexture; _NUI_LOCKED_RECT lockedRect; long hr = texture->LockRect( 0, &lockedRect, 0, 0 ); if ( FAILED( hr ) ) { error( hr ); } if ( lockedRect.Pitch != 0 ) { pixelToColorSurface( (uint8_t*)lockedRect.pBits ); /*if ( mDeviceOptions.isFrameSyncEnabled() ) { mColorFrames.push_back( ColorFrame( mColorSurface, frameColor->liTimeStamp.QuadPart ) ); if ( mColorFrames.size() > 10 ) { mColorFrames.erase( mColorFrames.begin() ); } }*/ } else { console() << "Invalid buffer length received." << endl; } hr = NuiImageStreamReleaseFrame( mColorStreamHandle, frameColor ); if ( FAILED( hr ) ) { error( hr ); } mNewColorSurface = true; } } ////////////////////////////////////////////////////////////////////////////////////////////// if ( readSkeleton && WAIT_OBJECT_0 == WaitForSingleObject( mSkeletonEvent, 0 ) ) { long hr = NuiSkeletonGetNextFrame( 0, &frameSkeleton ); if ( SUCCEEDED( hr ) ) { bool foundSkeleton = false; for ( int32_t i = 0; i < NUI_SKELETON_COUNT; ++i ) { mSkeletons.at( i ).clear(); NUI_SKELETON_TRACKING_STATE trackingState = frameSkeleton.SkeletonData[ i ].eTrackingState; if ( trackingState == NUI_SKELETON_TRACKED || trackingState == NUI_SKELETON_POSITION_ONLY ) { if ( !foundSkeleton ) { _NUI_TRANSFORM_SMOOTH_PARAMETERS transform = kTransformParams[ mTransform ]; hr = mSensor->NuiTransformSmooth( &frameSkeleton, &transform ); if ( FAILED( hr ) ) { error( hr ); } foundSkeleton = true; } if ( mFlipped ) { ( frameSkeleton.SkeletonData + i )->Position.x *= -1.0f; for ( int32_t j = 0; j < (int32_t)NUI_SKELETON_POSITION_COUNT; ++j ) { ( frameSkeleton.SkeletonData + i )->SkeletonPositions[ j ].x *= -1.0f; } } _NUI_SKELETON_BONE_ORIENTATION bones[ NUI_SKELETON_POSITION_COUNT ]; hr = NuiSkeletonCalculateBoneOrientations( frameSkeleton.SkeletonData + i, bones ); if ( FAILED( hr ) ) { error( hr ); } for ( int32_t j = 0; j < (int32_t)NUI_SKELETON_POSITION_COUNT; ++j ) { Bone bone( *( ( frameSkeleton.SkeletonData + i )->SkeletonPositions + j ), *( bones + j ) ); ( mSkeletons.begin() + i )->insert( std::pair<JointName, Bone>( (JointName)j, bone ) ); } } } mNewSkeletons = true; } mFrameRate = (float)( 1.0 / ( time - mReadTime ) ); mReadTime = time; } } } return; }
void VideoTable::skipButtonHandler(){ console() << "skip button handler" << endl; }
int main(const std::vector<CL_String> &args) { try { CL_GUIManager gui; CL_ResourceManager resources("../../../Resources/GUIThemeLuna/resources.xml"); CL_GUIWindowManagerSystem wm; gui.set_window_manager(wm); CL_GUIThemeDefault theme; theme.set_resources(resources); gui.set_theme(theme); //gui.set_css_document("theme.css"); gui.set_css_document("../../../Resources/GUIThemeLuna/theme.css"); CL_DisplayWindowDescription win_desc; win_desc.set_allow_resize(true); win_desc.set_title("Button WM System Test Application"); win_desc.set_position(CL_RectPS(200, 200, 320, 240), false); CL_Window window(&gui, win_desc); window.func_close().set(this, &App::on_close, &window); CL_PushButton button(&window); button.set_geometry(CL_RectPS(10, 10, 160, 40)); button.set_text("Button 1"); CL_PushButton button2(&window); button2.set_geometry(CL_RectPS(10, 50, 160, 40)); button2.set_text("Button 2"); button2.set_enabled(false); CL_PushButton button3(&window); button3.set_geometry(CL_RectPS(10, 90, 160, 40)); button3.set_text("Button 3"); CL_CheckBox check1(&window); check1.set_geometry(CL_RectPS(10, 130, 160, 21)); check1.set_text("Check Box 1"); CL_CheckBox check2(&window); check2.set_geometry(CL_RectPS(10, 160, 160, 21)); check2.set_text("Check Box 2"); check2.set_enabled(false); CL_CheckBox check3(&window); check3.set_geometry(CL_RectPS(10, 190, 160, 21)); check3.set_text("Check Box 3"); gui.exec(); } catch (CL_Exception e) { CL_ConsoleWindow console("Console"); CL_Console::write_line(e.message); console.display_close_message(); } return 0; }