void App::render(DisplayWindow &window, GameTime &game_time) { canvas.set_map_mode(MapMode(map_2d_upper_left)); canvas.clear(Colorf(0.0f,0.0f,0.2f, 1.0f)); gui_manager.draw_windows(canvas); draw_font_example(); draw_font_info(); last_fps = game_time.get_updates_per_second(); gui_manager.process(); window.flip(1); KeepAlive::process(); }
void CDC::MapMode(const CSize& rDeviceUnits, const CSize& rLogicalUnits) { MapMode(MM_ANISOTROPIC); SetWindowExtEx(m_hDC, rLogicalUnits.cx, rLogicalUnits.cy, NULL); SetViewportExtEx(m_hDC, rDeviceUnits.cx, rDeviceUnits.cy, NULL); }
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; }